属性值Event对于S3存储桶,TopicConfigurations中的CloudFormation类型必须为String

时间:2016-12-01 13:03:24

标签: json amazon-s3 amazon-sqs amazon-cloudformation

我在cloudformation模板中有这个代码:

     "MyBucket": {
     "Type" : "AWS::S3::Bucket",
     "Properties" : {
     "NotificationConfiguration": {
              "TopicConfigurations": [
                {
                  "Event": ["s3:ObjectCreated:Put" , "s3:ObjectCreated:Post"], 
                  "Topic": { "Ref": "TopicSNS" }
                }
              ]
            }
}
}

通过在CloudFormation中创建堆栈来测试此代码后,我收到此错误:Value of property Event must be of type String并且创建失败。 那是什么存在的理由? 谢谢

1 个答案:

答案 0 :(得分:0)

您已将列表传递给Event媒体资源,但Event requires a string value。要配置多个事件,请创建多个TopicConfigurations个对象:

"MyBucket": {
  "Type": "AWS::S3::Bucket",
  "Properties": {
    "NotificationConfiguration": {
      "TopicConfigurations": [
        {
          "Event": "s3:ObjectCreated:Put",
          "Topic": {
            "Ref": "TopicSNS"
          }
        },
        {
          "Event": "s3:ObjectCreated:Post",
          "Topic": {
            "Ref": "TopicSNS"
          }
        }
      ]
    }
  }
}