File tree Expand file tree Collapse file tree 8 files changed +19
-2
lines changed
iam-assumable-role-with-oidc
iam-assumable-role-with-oidc Expand file tree Collapse file tree 8 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ 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
25
26
26
27
oidc_fully_qualified_subjects = [" system:serviceaccount:default:sa1" , " system:serviceaccount:default:sa2" ]
27
28
}
Original file line number Diff line number Diff line change @@ -54,4 +54,5 @@ module "iam_assumable_role_custom" {
54
54
" arn:aws:iam::aws:policy/AmazonCognitoReadOnly" ,
55
55
" arn:aws:iam::aws:policy/AlexaForBusinessFullAccess" ,
56
56
]
57
+ number_of_custom_role_policy_arns = 2
57
58
}
Original file line number Diff line number Diff line change @@ -28,6 +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 custom policies passed to variable role\_ policy\_ arns | ` number ` | ` 0 ` | no |
31
32
| oidc\_ fully\_ qualified\_ subjects | The fully qualified OIDC subjects to be added to the role policy | ` set(string) ` | ` [] ` | no |
32
33
| oidc\_ subjects\_ with\_ wildcards | The OIDC subject using wildcards to be added to the role policy | ` set(string) ` | ` [] ` | no |
33
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 @@ -68,7 +68,7 @@ resource "aws_iam_role" "this" {
68
68
}
69
69
70
70
resource "aws_iam_role_policy_attachment" "custom" {
71
- count = var. create_role ? length ( var. role_policy_arns ) : 0
71
+ count = var. create_role ? var. number_of_role_policy_arns : 0
72
72
73
73
role = join (" " , aws_iam_role. this . * . name )
74
74
policy_arn = var. role_policy_arns [count . index ]
Original file line number Diff line number Diff line change @@ -70,6 +70,13 @@ variable "role_policy_arns" {
70
70
default = []
71
71
}
72
72
73
+ variable "number_of_role_policy_arns" {
74
+ description = " Number of IAM policies to attach to IAM role"
75
+ type = number
76
+ default = 0
77
+ }
78
+
79
+
73
80
variable "oidc_fully_qualified_subjects" {
74
81
description = " The fully qualified OIDC subjects to be added to the role policy"
75
82
type = set (string )
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U
32
32
| force\_ detach\_ policies | Whether policies should be detached from this role when destroying | ` bool ` | ` false ` | no |
33
33
| max\_ session\_ duration | Maximum CLI/API session duration in seconds between 3600 and 43200 | ` number ` | ` 3600 ` | no |
34
34
| mfa\_ age | Max age of valid MFA (in seconds) for roles which require MFA | ` number ` | ` 86400 ` | no |
35
+ | number\_ of\_ custom\_ role\_ policy\_ arns | Number of custom policies passed to variable custom\_ role\_ policy\_ arns | ` number ` | ` 0 ` | no |
35
36
| poweruser\_ role\_ policy\_ arn | Policy ARN to use for poweruser role | ` string ` | ` "arn:aws:iam::aws:policy/PowerUserAccess" ` | no |
36
37
| readonly\_ role\_ policy\_ arn | Policy ARN to use for readonly role | ` string ` | ` "arn:aws:iam::aws:policy/ReadOnlyAccess" ` | no |
37
38
| role\_ description | IAM Role description | ` string ` | ` "" ` | no |
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ resource "aws_iam_role" "this" {
72
72
}
73
73
74
74
resource "aws_iam_role_policy_attachment" "custom" {
75
- count = var. create_role ? length ( var. custom_role_policy_arns ) : 0
75
+ count = var. create_role ? var. number_of_custom_role_policy_arns : 0
76
76
77
77
role = aws_iam_role. this [0 ]. name
78
78
policy_arn = element (var. custom_role_policy_arns , count. index )
Original file line number Diff line number Diff line change @@ -76,6 +76,12 @@ variable "custom_role_policy_arns" {
76
76
default = []
77
77
}
78
78
79
+ variable "number_of_custom_role_policy_arns" {
80
+ description = " Number of IAM policies to attach to IAM role"
81
+ type = number
82
+ default = 0
83
+ }
84
+
79
85
# Pre-defined policies
80
86
variable "admin_role_policy_arn" {
81
87
description = " Policy ARN to use for admin role"
You can’t perform that action at this time.
0 commit comments