Skip to content

Commit 5825fb4

Browse files
authored
fix: simplify count statements (#93)
1 parent 591bef4 commit 5825fb4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

modules/iam-assumable-role-with-oidc/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ resource "aws_iam_role" "this" {
6666
}
6767

6868
resource "aws_iam_role_policy_attachment" "custom" {
69-
count = var.create_role && length(var.role_policy_arns) > 0 ? length(var.role_policy_arns) : 0
69+
count = var.create_role ? length(var.role_policy_arns) : 0
7070

7171
role = join("", aws_iam_role.this.*.name)
7272
policy_arn = var.role_policy_arns[count.index]

modules/iam-assumable-role/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ resource "aws_iam_role" "this" {
7272
}
7373

7474
resource "aws_iam_role_policy_attachment" "custom" {
75-
count = var.create_role && length(var.custom_role_policy_arns) > 0 ? length(var.custom_role_policy_arns) : 0
75+
count = var.create_role ? length(var.custom_role_policy_arns) : 0
7676

7777
role = aws_iam_role.this[0].name
7878
policy_arn = element(var.custom_role_policy_arns, count.index)

modules/iam-group-with-policies/main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ resource "aws_iam_group_policy_attachment" "iam_self_management" {
2727
}
2828

2929
resource "aws_iam_group_policy_attachment" "custom_arns" {
30-
count = length(var.custom_group_policy_arns) > 0 ? length(var.custom_group_policy_arns) : 0
30+
count = length(var.custom_group_policy_arns)
3131

3232
group = local.group_name
3333
policy_arn = element(var.custom_group_policy_arns, count.index)
3434
}
3535

3636
resource "aws_iam_group_policy_attachment" "custom" {
37-
count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0
37+
count = length(var.custom_group_policies)
3838

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

5353
resource "aws_iam_policy" "custom" {
54-
count = length(var.custom_group_policies) > 0 ? length(var.custom_group_policies) : 0
54+
count = length(var.custom_group_policies)
5555

5656
name = var.custom_group_policies[count.index]["name"]
5757
policy = var.custom_group_policies[count.index]["policy"]

0 commit comments

Comments
 (0)