File tree Expand file tree Collapse file tree 6 files changed +43
-8
lines changed
examples/iam-assumable-role
modules/iam-assumable-role Expand file tree Collapse file tree 6 files changed +43
-8
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ No provider.
34
34
| ------| --------| ---------|
35
35
| iam_assumable_role_admin | ../../modules/iam-assumable-role | |
36
36
| iam_assumable_role_custom | ../../modules/iam-assumable-role | |
37
+ | iam_assumable_role_sts | ../../modules/iam-assumable-role | |
37
38
| iam_policy | ../../modules/iam-policy | |
38
39
39
40
## Resources
Original file line number Diff line number Diff line change @@ -58,6 +58,38 @@ module "iam_assumable_role_custom" {
58
58
# number_of_custom_role_policy_arns = 3
59
59
}
60
60
61
+ # ###################################################
62
+ # IAM assumable role with multiple sts external ids
63
+ # ###################################################
64
+ module "iam_assumable_role_sts" {
65
+ source = " ../../modules/iam-assumable-role"
66
+
67
+ trusted_role_arns = [
68
+ " arn:aws:iam::307990089504:root" ,
69
+ ]
70
+
71
+ trusted_role_services = [
72
+ " codedeploy.amazonaws.com"
73
+ ]
74
+
75
+ create_role = true
76
+
77
+ role_name = " custom_sts"
78
+ role_requires_mfa = false
79
+
80
+ role_sts_externalid = [
81
+ " some-id-goes-here" ,
82
+ " another-id-goes-here" ,
83
+ ]
84
+
85
+ custom_role_policy_arns = [
86
+ " arn:aws:iam::aws:policy/AmazonCognitoReadOnly" ,
87
+ " arn:aws:iam::aws:policy/AlexaForBusinessFullAccess" ,
88
+ module . iam_policy . arn
89
+ ]
90
+ # number_of_custom_role_policy_arns = 3
91
+ }
92
+
61
93
# ########################################
62
94
# IAM policy
63
95
# ########################################
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ No Modules.
53
53
| role\_ path | Path of IAM role | ` string ` | ` "/" ` | no |
54
54
| role\_ permissions\_ boundary\_ arn | Permissions boundary ARN to use for IAM role | ` string ` | ` "" ` | no |
55
55
| role\_ requires\_ mfa | Whether role requires MFA | ` bool ` | ` true ` | no |
56
- | role\_ sts\_ externalid | STS ExternalId condition value to use with a role (when MFA is not required) | ` string ` | ` null ` | no |
56
+ | role\_ sts\_ externalid | STS ExternalId condition values to use with a role (when MFA is not required) | ` any ` | ` [] ` | no |
57
57
| tags | A map of tags to add to IAM role resources | ` map(string) ` | ` {} ` | no |
58
58
| trusted\_ role\_ actions | Actions of STS | ` list(string) ` | <pre >[ <br > "sts: AssumeRole "<br >] </pre > | no |
59
59
| trusted\_ role\_ arns | ARNs of AWS entities who can assume these roles | ` list(string) ` | ` [] ` | no |
Original file line number Diff line number Diff line change
1
+ locals {
2
+ role_sts_externalid = flatten (list (var. role_sts_externalid ))
3
+ }
4
+
1
5
data "aws_iam_policy_document" "assume_role" {
2
6
statement {
3
7
effect = " Allow"
@@ -15,11 +19,11 @@ data "aws_iam_policy_document" "assume_role" {
15
19
}
16
20
17
21
dynamic "condition" {
18
- for_each = var . role_sts_externalid != null ? [true ] : []
22
+ for_each = length (local . role_sts_externalid ) != 0 ? [true ] : []
19
23
content {
20
24
test = " StringEquals"
21
25
variable = " sts:ExternalId"
22
- values = [ var . role_sts_externalid ]
26
+ values = local . role_sts_externalid
23
27
}
24
28
}
25
29
}
Original file line number Diff line number Diff line change @@ -37,4 +37,3 @@ output "role_sts_externalid" {
37
37
description = " STS ExternalId condition value to use with a role"
38
38
value = var. role_sts_externalid
39
39
}
40
-
Original file line number Diff line number Diff line change @@ -132,8 +132,7 @@ variable "role_description" {
132
132
}
133
133
134
134
variable "role_sts_externalid" {
135
- description = " STS ExternalId condition value to use with a role (when MFA is not required)"
136
- type = string
137
- default = null
135
+ description = " STS ExternalId condition values to use with a role (when MFA is not required)"
136
+ type = any
137
+ default = []
138
138
}
139
-
You can’t perform that action at this time.
0 commit comments