Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unsupported pull_request option #71

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion terraform/aws-gha-oidc-providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module "iam_oidc_gha_incubator" {

role_name = "gha-incubator"
use_wildcard = true
allow_pull_request = true
github_branch = "refs/heads/*" # allows any branch
github_repo = "hackforla/incubator"

Expand Down
21 changes: 8 additions & 13 deletions terraform/modules/aws-gha-oidc-providers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ locals {
oidc_github_idp = "token.actions.githubusercontent.com"

# compose the OIDC subject using opinionated set of claims
# TODO: discuss alternative with maintainers
# see 'claims_supported' for all possibilities (some of which would require custom GHA):
# for alternatives with maintainers,see 'claims_supported' for
# all possibilities (some of which would require custom GHA):
# https://token.actions.githubusercontent.com/.well-known/openid-configuration
ordered_claim_names = [
"repo", "environment", "ref"
Expand All @@ -15,7 +15,9 @@ locals {
var.github_repo, var.github_environment, var.github_branch
])

# construct 'sub' claim parts by selecting non-empty arg values, then combine
# construct 'sub' claim parts by selecting non-empty arg values, then
# combine; these correspond to the source repo and branch, which
# the GHA token issuer populates when sending requests to AWS
claims = [
for claim in local.ordered_claim_names : format(
"%s:%s",
Expand All @@ -24,16 +26,9 @@ locals {
) if length(local.claims_with_values[claim]) > 0
]

oidc_gha_sub = join(":", var.allow_pull_request ? concat(
local.claims, ["pull_request"]
) : local.claims
)

/*
Alternative, which would place more responsibility on user to specify valid OIDC claims:

`oidc_expected_claims = join(":", [for k,v in var.claim_patterns : "${k}:${v}"])`
*/
# combine all component parts into a ':' delimited string for the
# AWS policy to use for evaluating incoming request 'sub' claims
oidc_gha_sub = join(":", local.claims)

}

Expand Down
15 changes: 0 additions & 15 deletions terraform/modules/aws-gha-oidc-providers/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,3 @@ variable "use_wildcard" {
type = bool
}

variable "allow_pull_request" {
description = "Authorize the token for pull requests"
type = bool
default = false
}

/*
Alternative, which would place more responsibility on user to specify valid OIDC claims:

`variable "claim_patterns" {
description = "Specifies arbitrary "
type = map(string)
}`
*/