Skip to content

Commit

Permalink
Fix terratest by ensuring IAM roles created by examples/complete are …
Browse files Browse the repository at this point in the history
…unique for each run.
  • Loading branch information
korenyoni committed Dec 13, 2021
1 parent 0eab5de commit 82402f1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/complete/deployment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ data "aws_caller_identity" "current" {
count = local.enabled ? 1 : 0
}


module "statement_ids" {
module "role_labels" {
for_each = local.test_deployment_role_prefix_map
source = "cloudposse/label/null"
version = "0.24.1" # requires Terraform >= 0.13.0
version = "0.25.0" # requires Terraform >= 0.13.0

attributes = split("-", each.key)
attributes = concat(split("-", each.key), var.attributes)
delimiter = ""
label_value_case = "title"
regex_replace_chars = "/[^a-zA-Z0-9]/"
Expand All @@ -33,7 +32,7 @@ data "aws_iam_policy_document" "assume_role" {
for_each = local.test_deployment_role_prefix_map

statement {
sid = "Enable${module.statement_ids[each.key].id}"
sid = "Enable${module.role_labels[each.key].id}"
actions = [
"sts:AssumeRole",
"sts:TagSession"
Expand All @@ -49,9 +48,9 @@ data "aws_iam_policy_document" "assume_role" {


resource "aws_iam_role" "test_role" {
for_each = local.test_deployment_role_prefix_map
for_each = module.role_labels

name = each.key
name = each.value.id

assume_role_policy = data.aws_iam_policy_document.assume_role[each.key].json
}

0 comments on commit 82402f1

Please sign in to comment.