【发布时间】:2021-12-24 00:09:53
【问题描述】:
我正在调用一个模块 (Terraform v0.13.7) 并使用此语句来确定 AWS SNS 警报操作(如果环境是生产环境,则使用此,否则使用此):
alarm_sns_topic_arn = var.environment == "production" ? data.terraform_remote_state.outputs.alarm_sns_topic_arn["foo1"] : data.terraform_remote_state.outputs.alarm_sns_topic_arn["foo2"]
运行时,我收到错误Error: Incorrect attribute value type。变量alarm_sns_topic_arn 是字符串类型。 foo1 和 foo2 应该解析为正确的 ARN 值,并且我确认在硬编码值时它也会失败。
完整的错误如下:
Error: Incorrect attribute value type
on ../../../modules/aws/elasticache_cluster/cloudwatch.tf line 70, in resource "aws_cloudwatch_metric_alarm" "elasticache_alarm":
70: alarm_actions = var.alarm_sns_topic_arn # This variable is currently a null default
Inappropriate value for attribute "alarm_actions": set of string required.
把我的头撞到墙上——我错过了什么?
【问题讨论】:
-
请提供../../../modules/aws/elasticache_cluster/variables.tf中提到的数据源terraform_remote_state定义和“alarm_sns_topic_arn”变量类型
-
我发现了我的问题,当属性需要它时没有指定列表。
标签: if-statement terraform conditional-statements terraform-provider-aws