@@ -5,10 +5,6 @@ locals {
5
5
for url in compact (distinct (concat (var. provider_urls , [var . provider_url ]))) :
6
6
replace (url, " https://" , " " )
7
7
]
8
- identifiers = [
9
- for url in local . urls :
10
- " arn:${ data . aws_partition . current . partition } :iam::${ local . aws_account_id } :oidc-provider/${ url } "
11
- ]
12
8
number_of_role_policy_arns = coalesce (var. number_of_role_policy_arns , length (var. role_policy_arns ))
13
9
}
14
10
@@ -19,33 +15,38 @@ data "aws_partition" "current" {}
19
15
data "aws_iam_policy_document" "assume_role_with_oidc" {
20
16
count = var. create_role ? 1 : 0
21
17
22
- statement {
23
- effect = " Allow "
18
+ dynamic " statement" {
19
+ for_each = local . urls
24
20
25
- actions = [" sts:AssumeRoleWithWebIdentity" ]
21
+ content {
22
+ effect = " Allow"
26
23
27
- principals {
28
- type = " Federated"
24
+ actions = [" sts:AssumeRoleWithWebIdentity" ]
29
25
30
- identifiers = local . identifiers
31
- }
26
+ principals {
27
+ type = " Federated "
32
28
33
- dynamic "condition" {
34
- for_each = length (var. oidc_fully_qualified_subjects ) > 0 ? local. urls : []
35
- content {
36
- test = " StringEquals"
37
- variable = " ${ condition . value } :sub"
38
- values = var. oidc_fully_qualified_subjects
29
+ identifiers = [" arn:${ data . aws_partition . current . partition } :iam::${ local . aws_account_id } :oidc-provider/${ statement . value } " ]
30
+ }
31
+
32
+ dynamic "condition" {
33
+ for_each = length (var. oidc_fully_qualified_subjects ) > 0 ? local. urls : []
34
+
35
+ content {
36
+ test = " StringEquals"
37
+ variable = " ${ statement . value } :sub"
38
+ values = var. oidc_fully_qualified_subjects
39
+ }
39
40
}
40
- }
41
41
42
+ dynamic "condition" {
43
+ for_each = length (var. oidc_subjects_with_wildcards ) > 0 ? local. urls : []
42
44
43
- dynamic "condition" {
44
- for_each = length (var. oidc_subjects_with_wildcards ) > 0 ? local. urls : []
45
- content {
46
- test = " StringLike"
47
- variable = " ${ condition . value } :sub"
48
- values = var. oidc_subjects_with_wildcards
45
+ content {
46
+ test = " StringLike"
47
+ variable = " ${ statement . value } :sub"
48
+ values = var. oidc_subjects_with_wildcards
49
+ }
49
50
}
50
51
}
51
52
}
0 commit comments