Skip to content

Commit e4e2392

Browse files
committed
prevent empty resources in flow log IAM policy when using external log group
1 parent 3ffbd46 commit e4e2392

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

vpc-flow-logs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ locals {
2121
flow_log_destination_arn = local.create_flow_log_cloudwatch_log_group ? try(aws_cloudwatch_log_group.flow_log[0].arn, null) : var.flow_log_destination_arn
2222
flow_log_iam_role_arn = var.flow_log_destination_type != "s3" && local.create_flow_log_cloudwatch_iam_role ? try(aws_iam_role.vpc_flow_log_cloudwatch[0].arn, null) : var.flow_log_cloudwatch_iam_role_arn
2323
flow_log_cloudwatch_log_group_name_suffix = var.flow_log_cloudwatch_log_group_name_suffix == "" ? local.vpc_id : var.flow_log_cloudwatch_log_group_name_suffix
24-
flow_log_group_arns = [
24+
flow_log_group_arns = local.create_flow_log_cloudwatch_log_group ? [
2525
for log_group in aws_cloudwatch_log_group.flow_log :
2626
"arn:${data.aws_partition.current[0].partition}:logs:${data.aws_region.current[0].region}:${data.aws_caller_identity.current[0].account_id}:log-group:${log_group.name}:*"
27-
]
27+
] : var.flow_log_destination_arn != null && var.flow_log_destination_arn != "" ? ["${var.flow_log_destination_arn}:*"] : []
2828
}
2929

3030
################################################################################

0 commit comments

Comments
 (0)