I am using terraform 1.0.11
I am trying to set an output of my secret manger.
main.tf:
resource "aws_secretsmanager_secret" "aws_secret" {
for_each = { for secret in var.secrets : secret.secret_name => secret}
name = each.value.secret_name
}
output.tf:
output "secret_arns" {
value = tolist(aws_secretsmanager_secret.aws_secret[*].arn)
}
However, it is throwing me this error.
╷
│ Error: Unsupported attribute
│
│ on ../Resources/secrets/outputs.tf line 2, in output "secret_arns":
│ 2: value = tolist(aws_secretsmanager_secret. aws_secret[*].arn)
│
│ This object does not have an attribute named "arn".
Is there anything that I did wrongly here?
CodePudding user response:
Your aws_secretsmanager_secret.aws_secret
is a map. So it should be:
output "secret_arns" {
value = values(aws_secretsmanager_secret.aws_secret)[*].arn
}