【问题标题】:How to reference the latest Stream of a DynamoDB table in a Cloudformation template如何在 Cloudformation 模板中引用 DynamoDB 表的最新流
【发布时间】:2018-09-15 14:45:28
【问题描述】:

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

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

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

【问题讨论】:

  • 您找到解决方案了吗?

标签: amazon-web-services amazon-dynamodb amazon-cloudformation serverless-framework amazon-dynamodb-streams


【解决方案1】:

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

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

【讨论】:

  • 感谢 Laurent 的回答。不幸的是,我无权访问原始 DynamoDB Cloudformation 定义,当我需要引用 Stream ARN 时,这两件事可能发生在完全不同的模板中。我现在只有已经创建的 DynamoDB 的 ARN。
  • 我了解,我建议您更新问题以反映这一点。我会留下我的答案,它可能会帮助其他人。
  • 对于未来的人来说,这只有在您拥有相同 CloudFormation 模板中的资源时才有效
  • 对于未来的人来说,这不能按原样工作,并且为了访问此属性 You must specify the StreamSpecification property to use this attribute. 哪个文档 is available here。否则你会得到Attribute: StreamArn was not found for resource
  • 在我的例子中,我正在处理一个现有的表/流,所以我通过模板参数传入所需的 Arn。
猜你喜欢
  • 2019-12-13
  • 2021-04-22
  • 1970-01-01
  • 2022-08-15
  • 2013-08-07
  • 1970-01-01
  • 2017-08-13
  • 1970-01-01
  • 2020-07-12
相关资源
最近更新 更多