File tree Expand file tree Collapse file tree 5 files changed +5
-4
lines changed
examples/iam-assumable-role-with-oidc
modules/iam-assumable-role-with-oidc Expand file tree Collapse file tree 5 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 2
2
terraform.tfstate
3
3
* .tfstate *
4
4
terraform.tfvars
5
+ .terraform.lock.hcl
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ module "iam_assumable_role_admin" {
22
22
role_policy_arns = [
23
23
" arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy" ,
24
24
]
25
- number_of_role_policy_arns = 1
26
25
27
26
oidc_fully_qualified_subjects = [" system:serviceaccount:default:sa1" , " system:serviceaccount:default:sa2" ]
28
27
}
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ This module supports IAM Roles for kubernetes service accounts as described in t
28
28
| create\_ role | Whether to create a role | ` bool ` | ` false ` | no |
29
29
| force\_ detach\_ policies | Whether policies should be detached from this role when destroying | ` bool ` | ` false ` | no |
30
30
| max\_ session\_ duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | ` number ` | ` 3600 ` | no |
31
- | number\_ of\_ role\_ policy\_ arns | Number of IAM policies to attach to IAM role | ` number ` | ` 0 ` | no |
31
+ | number\_ of\_ role\_ policy\_ arns | Number of IAM policies to attach to IAM role | ` number ` | ` null ` | no |
32
32
| oidc\_ fully\_ qualified\_ subjects | The fully qualified OIDC subjects to be added to the role policy | ` set(string) ` | ` [] ` | no |
33
33
| oidc\_ subjects\_ with\_ wildcards | The OIDC subject using wildcards to be added to the role policy | ` set(string) ` | ` [] ` | no |
34
34
| provider\_ url | URL of the OIDC Provider. Use provider\_ urls to specify several URLs. | ` string ` | ` "" ` | no |
Original file line number Diff line number Diff line change 9
9
for url in local . urls :
10
10
" arn:${ data . aws_partition . current . partition } :iam::${ local . aws_account_id } :oidc-provider/${ url } "
11
11
]
12
+ number_of_role_policy_arns = coalesce (var. number_of_role_policy_arns , length (var. role_policy_arns ))
12
13
}
13
14
14
15
data "aws_caller_identity" "current" {}
@@ -68,7 +69,7 @@ resource "aws_iam_role" "this" {
68
69
}
69
70
70
71
resource "aws_iam_role_policy_attachment" "custom" {
71
- count = var. create_role ? var . number_of_role_policy_arns : 0
72
+ count = var. create_role ? local . number_of_role_policy_arns : 0
72
73
73
74
role = join (" " , aws_iam_role. this . * . name )
74
75
policy_arn = var. role_policy_arns [count . index ]
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ variable "role_policy_arns" {
73
73
variable "number_of_role_policy_arns" {
74
74
description = " Number of IAM policies to attach to IAM role"
75
75
type = number
76
- default = 0
76
+ default = null
77
77
}
78
78
79
79
You can’t perform that action at this time.
0 commit comments