小编not*_*uru的帖子

如何在 serverless.yml 中将 DynamoDB 流引用为 Lambda 函数触发事件?

我正在使用无服务器框架来部署我的 AWS Lambda 函数。我有一个 serverless.yml 文件,它声明了我的所有资源和功能。

例如:


...
resources:
  Resources:
    MyTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: my-table
        AttributeDefinitions:
          -
            AttributeName: "id"
            AttributeType: "S"
        KeySchema:
          -
            AttributeName: "id"
            KeyType: "HASH"
        ProvisionedThroughput:
          ReadCapacityUnits: "5"
          WriteCapacityUnits: "5"
        StreamSpecification:
          StreamViewType: NEW_AND_OLD_IMAGES
    ...      
...
my-handler:
    ...
    events:
      - stream:
          type: dynamodb
          arn: ...

Run Code Online (Sandbox Code Playgroud)

我的 Lambda 函数是从 DynamoDB 流触发的。那么在事件定义中,如何在不对其 ARN 进行硬编码的情况下引用“MyTable”的 DynamoDB 流?

lambda amazon-web-services amazon-dynamodb serverless-framework

5
推荐指数
1
解决办法
1081
查看次数