

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à.

# Configurare i tag dell'argomento Amazon SNS
<a name="sns-tags-configuring"></a>

Questo argomento spiega come configurare i tag per un [argomento Amazon SNS](sns-tags.md) utilizzando Console di gestione AWS, un AWS SDK o il. AWS CLI

**Importante**  
Non aggiungere Informazioni personali di identificazione (PII) o altre informazioni riservate o sensibili nei tag. I tag sono accessibili ad altri Amazon Web Services, inclusa la fatturazione. I tag non sono destinati ad essere utilizzati per dati privati o sensibili.

## Elencare, aggiungere e rimuovere tag per un argomento di Amazon SNS utilizzando il Console di gestione AWS
<a name="list-add-update-remove-tags-for-topic-aws-console"></a>

1. Accedi alla [console Amazon SNS](https://console.aws.amazon.com/sns/home).

1. Nel pannello di navigazione, scegliere **Argomenti**.

1. Nella pagina **Topics (Argomenti)**, selezionare un argomento quindi scegliere **Edit (Modifica)**.

1. Espandere la sezione **Tag**.

   Vengono elencati i tag aggiunti all'argomento.

1. Modificare i tag dell'argomento:
   + Per aggiungere un tag, scegliere **Add tag (Aggiungi tag)** e specificare **Key (Chiave)** e **Value (Valore)** (opzionale),
   + Per rimuovere un tag, scegliere **Remove tag (Rimuovi tag)** accanto a una coppia chiave-valore.

1. Scegli **Save changes** (Salva modifiche).

## Aggiungere tag a un argomento utilizzando un SDK AWS
<a name="tag-resource-aws-sdks"></a>

Per utilizzare un AWS SDK, devi configurarlo con le tue credenziali. *Per ulteriori informazioni, consulta [I file di configurazione e credenziali condivisi nella and](https://docs.aws.amazon.com/sdkref/latest/guide/creds-config-files.html) Tools Reference AWS SDKs Guide.*

Gli esempi di codice seguenti mostrano come utilizzare `TagResource`.

------
#### [ CLI ]

**AWS CLI**  
**Aggiungere un tag a un argomento**  
Nell’esempio `tag-resource` seguente viene aggiunto un tag di metadati all’argomento Amazon SNS specificato.  

```
aws sns tag-resource \
    --resource-arn arn:aws:sns:us-west-2:123456789012:MyTopic \
    --tags Key=Team,Value=Alpha
```
Questo comando non produce alcun output.  
+  Per i dettagli sull'API, consulta *AWS CLI Command [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sns/tag-resource.html)Reference*. 

------
#### [ Java ]

**SDK per Java 2.x**  
 C'è altro su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel [Repository di esempi di codice AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/sns#code-examples). 

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sns.SnsClient;
import software.amazon.awssdk.services.sns.model.SnsException;
import software.amazon.awssdk.services.sns.model.Tag;
import software.amazon.awssdk.services.sns.model.TagResourceRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 */
public class AddTags {
    public static void main(String[] args) {
        final String usage = """

                Usage:    <topicArn>

                Where:
                   topicArn - The ARN of the topic to which tags are added.

                """;

        if (args.length != 1) {
            System.out.println(usage);
            System.exit(1);
        }

        String topicArn = args[0];
        SnsClient snsClient = SnsClient.builder()
                .region(Region.US_EAST_1)
                .build();

        addTopicTags(snsClient, topicArn);
        snsClient.close();
    }

    public static void addTopicTags(SnsClient snsClient, String topicArn) {
        try {
            Tag tag = Tag.builder()
                    .key("Team")
                    .value("Development")
                    .build();

            Tag tag2 = Tag.builder()
                    .key("Environment")
                    .value("Gamma")
                    .build();

            List<Tag> tagList = new ArrayList<>();
            tagList.add(tag);
            tagList.add(tag2);

            TagResourceRequest tagResourceRequest = TagResourceRequest.builder()
                    .resourceArn(topicArn)
                    .tags(tagList)
                    .build();

            snsClient.tagResource(tagResourceRequest);
            System.out.println("Tags have been added to " + topicArn);

        } catch (SnsException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
    }
}
```
+  Per i dettagli sull'API, [TagResource](https://docs.aws.amazon.com/goto/SdkForJavaV2/sns-2010-03-31/TagResource)consulta *AWS SDK for Java 2.x API Reference*. 

------
#### [ Kotlin ]

**SDK per Kotlin**  
 C'è altro su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel [Repository di esempi di codice AWS](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/sns#code-examples). 

```
suspend fun addTopicTags(topicArn: String) {
    val tag =
        Tag {
            key = "Team"
            value = "Development"
        }

    val tag2 =
        Tag {
            key = "Environment"
            value = "Gamma"
        }

    val tagList = mutableListOf<Tag>()
    tagList.add(tag)
    tagList.add(tag2)

    val request =
        TagResourceRequest {
            resourceArn = topicArn
            tags = tagList
        }

    SnsClient.fromEnvironment { region = "us-east-1" }.use { snsClient ->
        snsClient.tagResource(request)
        println("Tags have been added to $topicArn")
    }
}
```
+  Per i dettagli sull'API, [TagResource](https://sdk.amazonaws.com/kotlin/api/latest/index.html)consulta *AWS SDK for Kotlin* API reference. 

------

## Gestione dei tag con le operazioni dell’API Amazon SNS
<a name="manage-tags-with-sns-api-actions"></a>

Per gestire i tag utilizzando l’API Amazon SNS, utilizza le seguenti operazioni API:
+ [https://docs.aws.amazon.com/sns/latest/api/API_ListTagsForResource.html](https://docs.aws.amazon.com/sns/latest/api/API_ListTagsForResource.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_TagResource.html](https://docs.aws.amazon.com/sns/latest/api/API_TagResource.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_UntagResource.html](https://docs.aws.amazon.com/sns/latest/api/API_UntagResource.html)

## Azioni API che supportano ABAC
<a name="api-actions-that-support-abac"></a>

Di seguito è riportato un elenco di operazioni API che supportano il controllo di accesso basato su attributi (ABAC). Per ulteriori dettagli su ABAC, consulta A [cosa serve ABAC](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_attribute-based-access-control.html)? AWS nella Guida per l'*utente di IAM*.
+ [https://docs.aws.amazon.com/sns/latest/api/API_AddPermission.html](https://docs.aws.amazon.com/sns/latest/api/API_AddPermission.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html](https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_DeleteTopic.html](https://docs.aws.amazon.com/sns/latest/api/API_DeleteTopic.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_GetDataProtectionPolicy.html](https://docs.aws.amazon.com/sns/latest/api/API_GetDataProtectionPolicy.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_GetSubscriptionAttributes.html](https://docs.aws.amazon.com/sns/latest/api/API_GetSubscriptionAttributes.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_GetTopicAttributes.html](https://docs.aws.amazon.com/sns/latest/api/API_GetTopicAttributes.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_ListSubscriptionsByTopic.html](https://docs.aws.amazon.com/sns/latest/api/API_ListSubscriptionsByTopic.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_ListTagsForResource.html](https://docs.aws.amazon.com/sns/latest/api/API_ListTagsForResource.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_Publish.html](https://docs.aws.amazon.com/sns/latest/api/API_Publish.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_PublishBatch.html](https://docs.aws.amazon.com/sns/latest/api/API_PublishBatch.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_PutDataProtectionPolicy.html](https://docs.aws.amazon.com/sns/latest/api/API_PutDataProtectionPolicy.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_RemovePermission.html](https://docs.aws.amazon.com/sns/latest/api/API_RemovePermission.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_SetSubscriptionAttributes.html](https://docs.aws.amazon.com/sns/latest/api/API_SetSubscriptionAttributes.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_SetTopicAttributes.html](https://docs.aws.amazon.com/sns/latest/api/API_SetTopicAttributes.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html](https://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_TagResource.html](https://docs.aws.amazon.com/sns/latest/api/API_TagResource.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_Unsubscribe.html](https://docs.aws.amazon.com/sns/latest/api/API_Unsubscribe.html)
+ [https://docs.aws.amazon.com/sns/latest/api/API_UntagResource.html](https://docs.aws.amazon.com/sns/latest/api/API_UntagResource.html)