예제 4: CloudFormation을 사용하여 스트림에 태그 지정
DynamoDB Streams의 태그는 CloudFormation 템플릿에서 직접 지정할 수 있습니다. 스트림 태그는 표준 테이블의 경우 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 배포 실패 섹션을 참조하세요.