Search code examples
yamlserverless-frameworkserverlessamazon-dynamodb-streams

Missed comma between flow collection entries when using Fn::GetAtt in YAML


I'm trying to add an event stream for DynamoDB in YAML, DynamoDB table is a variable that changes based on the environment it gets deployed to, I'm using Fn::GetAtt to determine TABLE_NAME but it's giving me an exception.

  1. Is the syntax right?
  2. Is there a way to configure the stream in YAML other than Fn::GetAtt ?

Exception:

missed comma between flow collection entries in "erverless.yml" at line 60, 
column28:Fn::GetAtt: [ ${self:custom.TABLE_NAME ...

Code:

  custom:
      TABLE_NAME : mix of account + env + name
  events:
  - stream:
      type: dynamodb
      arn:
        Fn::GetAtt: [ ${self:custom.TABLE_NAME}, StreamArn ]

Solution

  • Inside YAML flow collections, strings with characters like {, }, [ etc. have to be quoted, because { starts a flow mapping and [ starts a flow sequence. There is no space required for that. So this is how it should look like:

          arn:
            Fn::GetAtt: [ '${self:custom.TABLE_NAME}', StreamArn ]
    

    For information on pretty much all types of quoting in YAML you can have a look at https://www.yaml.info/learn/quote.html (disclaimer: I'm the author).