Skip to content

Commit d3a0e22

Browse files
authored
Merge pull request #71 from hackforla/iac/oidc-sub-claim-fix
remove unsupported `pull_request` option
2 parents 3abf4ab + b4cf61e commit d3a0e22

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

terraform/aws-gha-oidc-providers.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module "iam_oidc_gha_incubator" {
33

44
role_name = "gha-incubator"
55
use_wildcard = true
6-
allow_pull_request = true
76
github_branch = "refs/heads/*" # allows any branch
87
github_repo = "hackforla/incubator"
98

terraform/modules/aws-gha-oidc-providers/main.tf

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ locals {
33
oidc_github_idp = "token.actions.githubusercontent.com"
44

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

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

27-
oidc_gha_sub = join(":", var.allow_pull_request ? concat(
28-
local.claims, ["pull_request"]
29-
) : local.claims
30-
)
31-
32-
/*
33-
Alternative, which would place more responsibility on user to specify valid OIDC claims:
34-
35-
`oidc_expected_claims = join(":", [for k,v in var.claim_patterns : "${k}:${v}"])`
36-
*/
29+
# combine all component parts into a ':' delimited string for the
30+
# AWS policy to use for evaluating incoming request 'sub' claims
31+
oidc_gha_sub = join(":", local.claims)
3732

3833
}
3934

terraform/modules/aws-gha-oidc-providers/variables.tf

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,3 @@ variable "use_wildcard" {
3939
type = bool
4040
}
4141

42-
variable "allow_pull_request" {
43-
description = "Authorize the token for pull requests"
44-
type = bool
45-
default = false
46-
}
47-
48-
/*
49-
Alternative, which would place more responsibility on user to specify valid OIDC claims:
50-
51-
`variable "claim_patterns" {
52-
description = "Specifies arbitrary "
53-
type = map(string)
54-
}`
55-
*/
56-

0 commit comments

Comments
 (0)