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à.
Questo argomento spiega come configurare i tag per un argomento Amazon SNS utilizzando AWS Management Console, un AWS SDK o il. AWS CLI
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.
 
		
		Accedi alla console Amazon SNS.
- 
				
Nel pannello di navigazione, scegliere Argomenti.
			 - 
				
Nella pagina Topics (Argomenti), selezionare un argomento quindi scegliere Edit (Modifica).
			 - 
				
Espandere la sezione Tag.
				Vengono elencati i tag aggiunti all'argomento.
			 - 
				
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.
					 
 
			 - 
				
Scegli Save changes (Salva modifiche).
			 
 
	 
		Aggiunta di tag a un argomento utilizzando un SDK AWS
		Per utilizzare un AWS SDK, devi configurarlo con le tue credenziali. Per ulteriori informazioni, consulta I file di configurazione e credenziali condivisi nella and 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.
             
            
         
    
 
         
    - Java
 - 
            
     
        - SDK per Java 2.x
 
        - 
             
                
                
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);
        }
    }
}
             
            
         
    
 
         
    - Kotlin
 - 
            
     
        - SDK per Kotlin
 
        - 
             
                
                
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 gestire i tag utilizzando l’API Amazon SNS, utilizza le seguenti operazioni API:
		
	 
		Azioni API che supportano ABAC
		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? AWS nella Guida per l'utente di IAM.