jeudi 11 novembre 2021

Conditional error in Terraform: Error: Incorrect attribute value type

I am calling a module (Terraform v0.13.7) and have this statement to determine an AWS SNS Alarm action (if environment is production, use this, otherwise use this):

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"]

When run, I get an error Error: Incorrect attribute value type. The variable alarm_sns_topic_arn is a string type. foo1 and foo2 should resolve to the correct ARN values, and I confirmed that when hardcoding the values it fails as well.

The full error reads:

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.

Banging my head against the wall — what am I missing?

Aucun commentaire:

Enregistrer un commentaire