Skip to content

Commit

Permalink
fix: simplify count statements (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 authored Sep 8, 2020
1 parent 591bef4 commit 5825fb4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/iam-assumable-role-with-oidc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ resource "aws_iam_role" "this" {
}

resource "aws_iam_role_policy_attachment" "custom" {
count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0
count = var.create_role ? length(var.role_policy_arns) : 0

role = join("", aws_iam_role.this.*.name)
policy_arn = var.role_policy_arns[count.index]
Expand Down
2 changes: 1 addition & 1 deletion modules/iam-assumable-role/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ resource "aws_iam_role" "this" {
}

resource "aws_iam_role_policy_attachment" "custom" {
count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0
count = var.create_role ? length(var.custom_role_policy_arns) : 0

role = aws_iam_role.this[0].name
policy_arn = element(var.custom_role_policy_arns, count.index)
Expand Down
6 changes: 3 additions & 3 deletions modules/iam-group-with-policies/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ resource "aws_iam_group_policy_attachment" "iam_self_management" {
}

resource "aws_iam_group_policy_attachment" "custom_arns" {
count = length(var.custom_group_policy_arns) > 0 ? length(var.custom_group_policy_arns) : 0
count = length(var.custom_group_policy_arns)

group = local.group_name
policy_arn = element(var.custom_group_policy_arns, count.index)
}

resource "aws_iam_group_policy_attachment" "custom" {
count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0
count = length(var.custom_group_policies)

group = local.group_name
policy_arn = element(aws_iam_policy.custom.*.arn, count.index)
Expand All @@ -51,7 +51,7 @@ resource "aws_iam_policy" "iam_self_management" {
}

resource "aws_iam_policy" "custom" {
count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0
count = length(var.custom_group_policies)

name = var.custom_group_policies[count.index]["name"]
policy = var.custom_group_policies[count.index]["policy"]
Expand Down

0 comments on commit 5825fb4

Please sign in to comment.