Commit 5825fb4f authored by Ilia Lazebnik's avatar Ilia Lazebnik Committed by GitHub

fix: simplify count statements (#93)

parent 591bef48
...@@ -66,7 +66,7 @@ resource "aws_iam_role" "this" { ...@@ -66,7 +66,7 @@ resource "aws_iam_role" "this" {
} }
resource "aws_iam_role_policy_attachment" "custom" { 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) role = join("", aws_iam_role.this.*.name)
policy_arn = var.role_policy_arns[count.index] policy_arn = var.role_policy_arns[count.index]
......
...@@ -72,7 +72,7 @@ resource "aws_iam_role" "this" { ...@@ -72,7 +72,7 @@ resource "aws_iam_role" "this" {
} }
resource "aws_iam_role_policy_attachment" "custom" { 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 role = aws_iam_role.this[0].name
policy_arn = element(var.custom_role_policy_arns, count.index) policy_arn = element(var.custom_role_policy_arns, count.index)
......
...@@ -27,14 +27,14 @@ resource "aws_iam_group_policy_attachment" "iam_self_management" { ...@@ -27,14 +27,14 @@ resource "aws_iam_group_policy_attachment" "iam_self_management" {
} }
resource "aws_iam_group_policy_attachment" "custom_arns" { 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 group = local.group_name
policy_arn = element(var.custom_group_policy_arns, count.index) policy_arn = element(var.custom_group_policy_arns, count.index)
} }
resource "aws_iam_group_policy_attachment" "custom" { 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 group = local.group_name
policy_arn = element(aws_iam_policy.custom.*.arn, count.index) policy_arn = element(aws_iam_policy.custom.*.arn, count.index)
...@@ -51,7 +51,7 @@ resource "aws_iam_policy" "iam_self_management" { ...@@ -51,7 +51,7 @@ resource "aws_iam_policy" "iam_self_management" {
} }
resource "aws_iam_policy" "custom" { 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"] name = var.custom_group_policies[count.index]["name"]
policy = var.custom_group_policies[count.index]["policy"] policy = var.custom_group_policies[count.index]["policy"]
......
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