在 YAML 中使用 Fn::GetAtt 时流集合条目之间缺少逗号

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

我正在尝试在 YAML 中为 DynamoDB 添加事件流,DynamoDB table 是一个根据 它部署到的环境,我正在使用 Fn::GetAtt 来确定 TABLE_NAME 但它给了我一个例外。

  1. 语法正确吗?
  2. 除了 Fn::GetAtt 之外,还有其他方法可以在 YAML 中配置流吗?

异常:

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

代码:

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

在 YAML 流集合中,必须引用包含 {}[ 等字符的字符串,因为 { 启动流映射并且 [ 开始流程序列。 不需要 space。 所以它应该是这样的:

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

有关 YAML 中几乎所有类型的引用的信息,您可以查看 https://www.yaml.info/learn/quote.html(免责声明:我是作者)。