

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Esempio 4: etichettatura degli stream utilizzando CloudFormation
<a name="streams-abac-example-4"></a>

Puoi specificare i tag su DynamoDB Streams direttamente nei tuoi modelli. CloudFormation I tag Stream sono definiti all'interno della `StreamSpecification` proprietà per le tabelle standard e all'interno della `ReplicaStreamSpecification` proprietà per le tabelle globali.

## AWS::DynamoDB: :Tabella
<a name="streams-abac-example-4-table"></a>

```
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
<a name="streams-abac-example-4-global-table"></a>

```
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
```

Oltre ai tag di stream espliciti, propaga CloudFormation anche i tag a livello di stack agli stream. Se lo stack ha dei tag configurati, tali tag vengono applicati automaticamente a tutte le risorse dello stack, inclusi gli stream.

**Importante**  
Il ruolo IAM utilizzato per la CloudFormation distribuzione deve disporre delle autorizzazioni `dynamodb:TagResource` e `dynamodb:UntagResource` delle autorizzazioni relative alle risorse di streaming (`arn:aws:dynamodb:*:*:table/*/stream/*`) per applicare i tag agli stream. Se mancano queste autorizzazioni, consulta [CloudFormation le distribuzioni falliscono durante l'etichettatura degli stream](abac-troubleshooting-streams.md#abac-troubleshooting-streams-cfn-tagging) per i dettagli.