I’m attempting to create a data source IAM policy document that includes three SSM Parameters as resources, but having difficulty working out the correct syntax. The code below generates the following error:
│ Error: Unsupported attribute
│
│ on data.tf line 36, in data “aws_iam_policy_document” “deployment_group_api”:
│ 36: for parameter in aws_ssm_parameter.deployment_group_api[*] : parameter.arn
│
│ This object does not have an attribute named “arn”.
resource "aws_ssm_parameter" "deployment_group_api" {
for_each = local.envs
.
.
}
data "aws_iam_policy_document" "deployment_group_api" {
statement {
effect = "Allow"
actions = [
"ssm:GetParameter"
]
resources = [
for parameter in aws_ssm_parameter.deployment_group_api[*] : parameter.arn
]
}
}
Documentation for the resource type aws_ssm_parameter states that it does have the attribute named arn, so I’m not understanding what is going wrong.
The end result I’m looking to achieve is equivalent to:
data "aws_iam_policy_document" "deployment_group_api" {
statement {
effect = "Allow"
actions = [
"ssm:GetParameter"
]
resources = [
aws_ssm_parameter.deployment_group_api["one"].arn,
aws_ssm_parameter.deployment_group_api["two"].arn,
aws_ssm_parameter.deployment_group_api["three"].arn
]
}
}
Any help provided would be greatly appreciated.