View a markdown version of this page

示例 4:使用 CloudFormation 为流添加标签 - Amazon DynamoDB
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)。

示例 4:使用 CloudFormation 为流添加标签

您可以直接在 CloudFormation 模板中为 DynamoDB Streams 指定标签。流标签在标准表的 StreamSpecification 属性中定义,以及在全局表的 ReplicaStreamSpecification 属性中定义。

AWS::DynamoDB::Table

Resources: MyTable: Type: AWS::DynamoDB::Table Properties: TableName: MyTable AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: id KeyType: HASH BillingMode: PAY_PER_REQUEST Tags: - Key: TableEnv Value: Production StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES Tags: - Key: StreamEnv Value: Production - Key: StreamTeam Value: Payments

AWS::DynamoDB::GlobalTable

Resources: MyGlobalTable: Type: AWS::DynamoDB::GlobalTable Properties: TableName: MyGlobalTable AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: id KeyType: HASH BillingMode: PAY_PER_REQUEST StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES Replicas: - Region: us-east-1 Tags: - Key: TableEnv Value: Production ReplicaStreamSpecification: Tags: - Key: StreamEnv Value: Production - Key: StreamTeam Value: Payments - Region: eu-west-1 Tags: - Key: TableEnv Value: Production ReplicaStreamSpecification: Tags: - Key: StreamEnv Value: Production - Key: StreamTeam Value: Payments

除了显式流标签外,CloudFormation 还会将堆栈级别的标签传播到流。如果您的堆栈配置了标签,这些标签将自动应用于堆栈中的所有资源,包括流。

重要

用于 CloudFormation 部署的 IAM 角色必须对流资源 (arn:aws:dynamodb:*:*:table/*/stream/*) 拥有 dynamodb:TagResource 和 dynamodb:UntagResource 权限,才能将标签应用于流。如果缺少这些权限,请参阅为流添加标签时 CloudFormation 部署失败以了解详细信息。