File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ module "oidc_github_iam_role" {
4444 "arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess"
4545 ]
4646
47+ repo_owners = [
48+ "my-owner"
49+ ]
50+
51+ sub = [
52+ "repo:my-owner/my-repo:ref:refs/heads/*"
53+ ]
54+
4755 tags = {
4856 Project = "my-project"
4957 Service = "my-service"
Original file line number Diff line number Diff line change @@ -16,13 +16,27 @@ data "aws_iam_policy_document" "assume_role_policy" {
1616 condition {
1717 test = " StringEquals"
1818 variable = " token.actions.githubusercontent.com:aud"
19- values = [" sts.amazonaws.com" ]
19+ values = [" sts.amazonaws.com" ]
2020 }
2121
22- condition {
23- test = " StringLike"
24- variable = " token.actions.githubusercontent.com:sub"
25- values = [" repo:${ var . sub } " ]
22+ dynamic "condition" {
23+ for_each = length (var. repo_owners ) > 0 ? [1 ] : []
24+
25+ content {
26+ test = " StringEquals"
27+ variable = " token.actions.githubusercontent.com:repository_owner"
28+ values = var. repo_owners
29+ }
30+ }
31+
32+ dynamic "condition" {
33+ for_each = length (var. sub ) > 0 ? [1 ] : []
34+
35+ content {
36+ test = " StringLike"
37+ variable = " token.actions.githubusercontent.com:sub"
38+ values = var. sub
39+ }
2640 }
2741 }
2842}
Original file line number Diff line number Diff line change @@ -22,9 +22,16 @@ variable "policy_arns" {
2222 default = []
2323}
2424
25+ variable "repo_owners" {
26+ type = set (string )
27+ description = " Set of repo owners for the assume role policy"
28+ default = []
29+ }
30+
2531variable "sub" {
26- type = string
32+ type = set ( string )
2733 description = " The sub pattern for the assume role policy (e.g. org/repo:ref:refs/heads/master)"
34+ default = []
2835}
2936
3037variable "tags" {
You can’t perform that action at this time.
0 commit comments