From b40ade467bff316f25220eccb5f641d4e1c716ba Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Wed, 26 Oct 2022 13:08:05 -0400 Subject: [PATCH] fix: Correct tflint errors for latest version of tflint (#296) --- modules/iam-assumable-role-with-oidc/main.tf | 4 ++-- modules/iam-assumable-role-with-saml/main.tf | 2 +- modules/iam-group-with-policies/main.tf | 4 ++-- modules/iam-group-with-policies/policies.tf | 8 +------- modules/iam-read-only-policy/main.tf | 6 +++--- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/modules/iam-assumable-role-with-oidc/main.tf b/modules/iam-assumable-role-with-oidc/main.tf index 6ccc5a54..88df06c5 100644 --- a/modules/iam-assumable-role-with-oidc/main.tf +++ b/modules/iam-assumable-role-with-oidc/main.tf @@ -95,7 +95,7 @@ resource "aws_iam_role" "this" { force_detach_policies = var.force_detach_policies permissions_boundary = var.role_permissions_boundary_arn - assume_role_policy = join("", data.aws_iam_policy_document.assume_role_with_oidc.*.json) + assume_role_policy = data.aws_iam_policy_document.assume_role_with_oidc[0].json tags = var.tags } @@ -103,6 +103,6 @@ resource "aws_iam_role" "this" { resource "aws_iam_role_policy_attachment" "custom" { count = var.create_role ? local.number_of_role_policy_arns : 0 - role = join("", aws_iam_role.this.*.name) + role = aws_iam_role.this[0].name policy_arn = var.role_policy_arns[count.index] } diff --git a/modules/iam-assumable-role-with-saml/main.tf b/modules/iam-assumable-role-with-saml/main.tf index 3a82320c..30367f60 100644 --- a/modules/iam-assumable-role-with-saml/main.tf +++ b/modules/iam-assumable-role-with-saml/main.tf @@ -65,6 +65,6 @@ resource "aws_iam_role" "this" { resource "aws_iam_role_policy_attachment" "custom" { count = var.create_role ? local.number_of_role_policy_arns : 0 - role = join("", aws_iam_role.this.*.name) + role = aws_iam_role.this[0].name policy_arn = var.role_policy_arns[count.index] } diff --git a/modules/iam-group-with-policies/main.tf b/modules/iam-group-with-policies/main.tf index 00571a94..aa0675a4 100644 --- a/modules/iam-group-with-policies/main.tf +++ b/modules/iam-group-with-policies/main.tf @@ -1,5 +1,5 @@ locals { - group_name = element(concat(aws_iam_group.this.*.id, [var.name]), 0) + group_name = var.create_group ? aws_iam_group.this[0].id : var.name } resource "aws_iam_group" "this" { @@ -37,7 +37,7 @@ resource "aws_iam_group_policy_attachment" "custom" { count = length(var.custom_group_policies) group = local.group_name - policy_arn = element(aws_iam_policy.custom.*.arn, count.index) + policy_arn = element(aws_iam_policy.custom[*].arn, count.index) } ############### diff --git a/modules/iam-group-with-policies/policies.tf b/modules/iam-group-with-policies/policies.tf index 6631d193..2c8b4b2f 100644 --- a/modules/iam-group-with-policies/policies.tf +++ b/modules/iam-group-with-policies/policies.tf @@ -5,13 +5,7 @@ data "aws_caller_identity" "current" { data "aws_partition" "current" {} locals { - aws_account_id = element( - concat( - data.aws_caller_identity.current.*.account_id, - [var.aws_account_id], - ), - 0, - ) + aws_account_id = try(data.aws_caller_identity.current[0].account_id, var.aws_account_id) } data "aws_iam_policy_document" "iam_self_management" { diff --git a/modules/iam-read-only-policy/main.tf b/modules/iam-read-only-policy/main.tf index 455c15e3..df822e63 100644 --- a/modules/iam-read-only-policy/main.tf +++ b/modules/iam-read-only-policy/main.tf @@ -82,9 +82,9 @@ data "aws_iam_policy_document" "logs_query" { data "aws_iam_policy_document" "combined" { source_policy_documents = concat( [data.aws_iam_policy_document.allowed_services.json], - data.aws_iam_policy_document.console_services.*.json, - data.aws_iam_policy_document.sts.*.json, - data.aws_iam_policy_document.logs_query.*.json, + data.aws_iam_policy_document.console_services[*].json, + data.aws_iam_policy_document.sts[*].json, + data.aws_iam_policy_document.logs_query[*].json, [var.additional_policy_json] ) }