如何在 Cloudformation 模板中引用 DynamoDB 表的最新流

Tho*_*mas 11 amazon-web-services aws-cloudformation amazon-dynamodb serverless-framework amazon-dynamodb-streams

我正在为无服务器框架编写一个插件,它通过 ARN 引用 DynamoDB Stream。我可以使用手头的信息构建 DynamoDB 表 ARN,但我不知道时间戳部分,这是构建完整流 ARN 所必需的。我无权访问原始 DynamoDB Cloudformation 定义,当我需要引用 Stream ARN 时,这两件事可能会在完全不同的模板中发生。此时我所拥有的只是已创建的 DynamoDB 的 ARN。

有没有办法通过类似于 的变量来引用最新的流 arn:aws:dynamodb:${AWS::Region}::${AWS::AccountId}:table/eventbus-test/stream/${LATEST}

或者我可以通过无服务器配置或 Cloudformation 模板以另一种方式构建它吗?

Lau*_*ard 5

根据 doc。您可以使用Fn::GetAtt带有StreamArn参数的内部函数访问它。例如:

Resources: 
  Table:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
      - AttributeName: leaseKey
        AttributeType: S
      KeySchema:
      - KeyType: HASH
        AttributeName: leaseKey
      ProvisionedThroughput:
        ReadCapacityUnits: '1'
        WriteCapacityUnits: '1'
Outputs:
  TableStreamArn:
    Value: !GetAtt Table.StreamArn
Run Code Online (Sandbox Code Playgroud)

  • 感谢劳伦特的回答。不幸的是,我无权访问原始 DynamoDB Cloudformation 定义,当我需要引用 Stream ARN 时,这两件事可能会在完全不同的模板中发生。此时我所拥有的只是已创建的 DynamoDB 的 ARN。 (2认同)