Configuring tags for an Amazon SNS topic - Amazon Simple Notification Service

Configuring tags for an Amazon SNS topic

You can track your Amazon SNS resources (for example, for cost allocation) by adding, removing, and listing metadata tags for Amazon SNS topics. This page shows how to add, update, and remove tags for a topic using the AWS Management Console and the AWS SDK for Java.


Currently, tag-based access control isn't available.

To list, add, and remove, metadata tags for an Amazon SNS topic using the AWS Management Console

  1. Sign in to the Amazon SNS console.

  2. On the navigation panel, choose Topics.

  3. On the Topics page, choose a topic and then choose Edit.

  4. Expand the Tags section.

    The tags added to the topic are listed.

  5. Modify topic tags:

    • To add a tag, choose Add tag and enter a Key and Value (optional),

    • To remove a tag, choose Remove tag next to a key-value pair.

  6. Choose Save changes

To add metadata tags to a topic using an AWS SDK

To use an AWS SDK, you must configure it with your credentials. For more information, see The shared config and credentials files in the AWS SDKs and Tools Reference Guide.

The following code example shows how to add tags to an Amazon SNS topic.

SDK for Java 2.x

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); } }
  • Find instructions and more code on GitHub.