Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
terraform-aws-iam
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Terraform Modules
terraform-aws-iam
Commits
fd70c071
Unverified
Commit
fd70c071
authored
Mar 11, 2021
by
Mike Carey
Committed by
GitHub
Mar 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Allows multiple STS External IDs to be provided to an assumable role (#138)
parent
564ea413
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
8 deletions
+43
-8
README.md
examples/iam-assumable-role/README.md
+1
-0
main.tf
examples/iam-assumable-role/main.tf
+32
-0
README.md
modules/iam-assumable-role/README.md
+1
-1
main.tf
modules/iam-assumable-role/main.tf
+6
-2
outputs.tf
modules/iam-assumable-role/outputs.tf
+0
-1
variables.tf
modules/iam-assumable-role/variables.tf
+3
-4
No files found.
examples/iam-assumable-role/README.md
View file @
fd70c071
...
@@ -34,6 +34,7 @@ No provider.
...
@@ -34,6 +34,7 @@ No provider.
|------|--------|---------|
|------|--------|---------|
| iam_assumable_role_admin | ../../modules/iam-assumable-role | |
| iam_assumable_role_admin | ../../modules/iam-assumable-role | |
| iam_assumable_role_custom | ../../modules/iam-assumable-role | |
| iam_assumable_role_custom | ../../modules/iam-assumable-role | |
| iam_assumable_role_sts | ../../modules/iam-assumable-role | |
| iam_policy | ../../modules/iam-policy | |
| iam_policy | ../../modules/iam-policy | |
## Resources
## Resources
...
...
examples/iam-assumable-role/main.tf
View file @
fd70c071
...
@@ -58,6 +58,38 @@ module "iam_assumable_role_custom" {
...
@@ -58,6 +58,38 @@ module "iam_assumable_role_custom" {
# number_of_custom_role_policy_arns = 3
# number_of_custom_role_policy_arns = 3
}
}
####################################################
# IAM assumable role with multiple sts external ids
####################################################
module
"iam_assumable_role_sts"
{
source
=
"../../modules/iam-assumable-role"
trusted_role_arns
=
[
"arn:aws:iam::307990089504:root"
,
]
trusted_role_services
=
[
"codedeploy.amazonaws.com"
]
create_role
=
true
role_name
=
"custom_sts"
role_requires_mfa
=
false
role_sts_externalid
=
[
"some-id-goes-here"
,
"another-id-goes-here"
,
]
custom_role_policy_arns
=
[
"arn:aws:iam::aws:policy/AmazonCognitoReadOnly"
,
"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess"
,
module
.
iam_policy
.
arn
]
# number_of_custom_role_policy_arns = 3
}
#########################################
#########################################
# IAM policy
# IAM policy
#########################################
#########################################
...
...
modules/iam-assumable-role/README.md
View file @
fd70c071
...
@@ -53,7 +53,7 @@ No Modules.
...
@@ -53,7 +53,7 @@ No Modules.
| role
\_
path | Path of IAM role |
`string`
|
`"/"`
| no |
| role
\_
path | Path of IAM role |
`string`
|
`"/"`
| no |
| role
\_
permissions
\_
boundary
\_
arn | Permissions boundary ARN to use for IAM role |
`string`
|
`""`
| no |
| role
\_
permissions
\_
boundary
\_
arn | Permissions boundary ARN to use for IAM role |
`string`
|
`""`
| no |
| role
\_
requires
\_
mfa | Whether role requires MFA |
`bool`
|
`true`
| no |
| role
\_
requires
\_
mfa | Whether role requires MFA |
`bool`
|
`true`
| no |
| role
\_
sts
\_
externalid | STS ExternalId condition value
to use with a role (when MFA is not required) |
`string`
|
`null
`
| no |
| role
\_
sts
\_
externalid | STS ExternalId condition value
s to use with a role (when MFA is not required) |
`any`
|
`[]
`
| no |
| tags | A map of tags to add to IAM role resources |
`map(string)`
|
`{}`
| no |
| tags | A map of tags to add to IAM role resources |
`map(string)`
|
`{}`
| no |
| trusted
\_
role
\_
actions | Actions of STS |
`list(string)`
|
<pre>
[
<br> "sts:AssumeRole"<br>
]
</pre>
| no |
| trusted
\_
role
\_
actions | Actions of STS |
`list(string)`
|
<pre>
[
<br> "sts:AssumeRole"<br>
]
</pre>
| no |
| trusted
\_
role
\_
arns | ARNs of AWS entities who can assume these roles |
`list(string)`
|
`[]`
| no |
| trusted
\_
role
\_
arns | ARNs of AWS entities who can assume these roles |
`list(string)`
|
`[]`
| no |
...
...
modules/iam-assumable-role/main.tf
View file @
fd70c071
locals
{
role_sts_externalid
=
flatten
(
list
(
var
.
role_sts_externalid
))
}
data
"aws_iam_policy_document"
"assume_role"
{
data
"aws_iam_policy_document"
"assume_role"
{
statement
{
statement
{
effect
=
"Allow"
effect
=
"Allow"
...
@@ -15,11 +19,11 @@ data "aws_iam_policy_document" "assume_role" {
...
@@ -15,11 +19,11 @@ data "aws_iam_policy_document" "assume_role" {
}
}
dynamic
"condition"
{
dynamic
"condition"
{
for_each
=
var
.
role_sts_externalid
!
=
null
?
[
true
]
:
[]
for_each
=
length
(
local
.
role_sts_externalid
)
!
=
0
?
[
true
]
:
[]
content
{
content
{
test
=
"StringEquals"
test
=
"StringEquals"
variable
=
"sts:ExternalId"
variable
=
"sts:ExternalId"
values
=
[
var
.
role_sts_externalid
]
values
=
local
.
role_sts_externalid
}
}
}
}
}
}
...
...
modules/iam-assumable-role/outputs.tf
View file @
fd70c071
...
@@ -37,4 +37,3 @@ output "role_sts_externalid" {
...
@@ -37,4 +37,3 @@ output "role_sts_externalid" {
description
=
"STS ExternalId condition value to use with a role"
description
=
"STS ExternalId condition value to use with a role"
value
=
var
.
role_sts_externalid
value
=
var
.
role_sts_externalid
}
}
modules/iam-assumable-role/variables.tf
View file @
fd70c071
...
@@ -132,8 +132,7 @@ variable "role_description" {
...
@@ -132,8 +132,7 @@ variable "role_description" {
}
}
variable
"role_sts_externalid"
{
variable
"role_sts_externalid"
{
description
=
"STS ExternalId condition value to use with a role (when MFA is not required)"
description
=
"STS ExternalId condition value
s
to use with a role (when MFA is not required)"
type
=
string
type
=
any
default
=
null
default
=
[]
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment