terraform plan: error: sqs_target should be a list when trying to create a cloudwatch event target

terraform plan: error: sqs_target should be a list when trying to create a cloudwatch event target

我正在尝试使用以下 terraform 代码创建 aws cloudwatch 事件目标:


resource "aws_cloudwatch_event_rule" "push-event-processing-sqs" {
   name =         "Push-to-sqs-event-processing-every-2-hours" 
   description =         "Push to SQS event-processing every 2 hours" 
   schedule_expression = "cron(0 /2 ? * * *)"
   is_enabled = "false"
}



resource "aws_cloudwatch_event_target" "target-event-processing-sqs" {
  arn = "arn:aws:sqs:us-west-2:123456789:my-sqs-queue-dev.fifo"
  rule = "${aws_cloudwatch_event_rule.push-event-processing-sqs.name}"
  sqs_target = "foobar"
}

我得到的错误是:

sqs_target: 应该是一个列表

我查看了https://www.terraform.io/docs/providers/aws/r/cloudwatch_event_target.html,但没有得到太多帮助。

应该是什么样的列表?

所以你的sqs_target用错了。根据文档,它应该采用以下格式:

resource "aws_cloudwatch_event_target" "target-event-processing-sqs" {
  ...
  sqs_target {
    message_group_id = "foobar"
  }
}

message_group_id - (Optional) The FIFO message group ID to use as the target.