Commit 893f08a1 authored by LAKostis's avatar LAKostis Committed by GitHub

feat: Added support for sts:ExternalId in modules/iam-assumable-role (#90)

parent 4b2a189e
......@@ -48,6 +48,8 @@ module "iam_assumable_role_custom" {
role_name = "custom"
role_requires_mfa = false
role_sts_externalid = "some-id-goes-here"
custom_role_policy_arns = [
"arn:aws:iam::aws:policy/AmazonCognitoReadOnly",
"arn:aws:iam::aws:policy/AlexaForBusinessFullAccess",
......
......@@ -39,6 +39,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U
| role\_path | Path of 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\_sts\_externalid | STS ExternalId condition value to use with a role (when MFA is not required) | `string` | `null` | 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\_arns | ARNs of AWS entities who can assume these roles | `list(string)` | `[]` | no |
......@@ -49,6 +50,7 @@ Trusted resources can be any [IAM ARNs](https://docs.aws.amazon.com/IAM/latest/U
| Name | Description |
|------|-------------|
| role\_requires\_mfa | Whether IAM role requires MFA |
| role\_sts\_externalid | STS ExternalId condition value to use with a role |
| this\_iam\_instance\_profile\_arn | ARN of IAM instance profile |
| this\_iam\_instance\_profile\_name | Name of IAM instance profile |
| this\_iam\_instance\_profile\_path | Path of IAM instance profile |
......
......@@ -13,6 +13,15 @@ data "aws_iam_policy_document" "assume_role" {
type = "Service"
identifiers = var.trusted_role_services
}
dynamic "condition" {
for_each = var.role_sts_externalid != null ? [true] : []
content {
test = "StringEquals"
variable = "sts:ExternalId"
values = [var.role_sts_externalid]
}
}
}
}
......
......@@ -32,3 +32,9 @@ output "this_iam_instance_profile_path" {
description = "Path of IAM instance profile"
value = element(concat(aws_iam_instance_profile.this.*.path, [""]), 0)
}
output "role_sts_externalid" {
description = "STS ExternalId condition value to use with a role"
value = var.role_sts_externalid
}
......@@ -125,3 +125,9 @@ variable "role_description" {
default = ""
}
variable "role_sts_externalid" {
description = "STS ExternalId condition value to use with a role (when MFA is not required)"
type = string
default = null
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment