AWS CloudFormation YAML gotcha

科技动态 2018-07-06

I just got stuck on a CloudFormation gotcha for an hour. I was trying to add an access policy to an SQS queue to allow SNS to post messages to it, but it gave this error:

An error occurred: myQueue – Invalid value for the parameter Policy. (Service: AmazonSQS; Status Code: 400; Error Code: InvalidAttributeValue).

The CloudFormation YAML for that queue was:

Type: AWS::SQS::QueuePolicy
    - Ref: myQueue
    Id: QueuePolicy
    Version: 2012-10-17
      - Sid: sendMessagesToQueue
        Effect: Allow
          AWS: "*"
         - sqs:SendMessage
        Resource: "*"
              Ref: myTopic

The problem with this policy is that YAML automatically parses anything that looks like an ISO-formatted date
, so when Serverless
converted my YAML CloudFormation to JSON to be uploaded, that “2012-10-17” date was transformed to:

"Version": "2012-10-17T00:00:00.000Z"

Whoops! Adding quotes around the date in the Version field fixes this problem:

Version: "2012-10-17"

责编内容by:Nicholas Sherlock (源链)。感谢您的支持!


Podlike templates We've seen now that we can run co-located and coupled services on Docker Swar...
Program JSON and YAML with Dhall This is short post to announce a new dhall-json library which lets you compi...
Making CloudFormation Awesome CloudFormation is the inhouse cloud provisioning tool of AWS for declarative...
Kubectl Cheatsheet Kubctl 命令是操作 kubernetes 集群的最直接和最 skillful 的途径,这个60多MB大小的二进制文件,到底有啥能耐呢?本文是对官方文档的...
helm-chart-2-chart结构和简单模板 1, chart 结构介绍 我们创建一个chart 并查看其结构 右侧注释为其文件的的解释 $ helm create mychart $ cd ...