Deleting an Amazon SNS subscription and topic - Amazon Simple Notification Service

Deleting an Amazon SNS subscription and topic

You can delete a subscription from an Amazon SNS topic, or you can delete the whole topic. Note that you can't delete a subscription that's pending confirmation. After three days, Amazon SNS deletes the unconfirmed subscription automatically.

To delete an Amazon SNS subscription and topic using the AWS Management Console

To delete a subscription using the AWS Management Console

  1. Sign in to the Amazon SNS console.

  2. In the left navigation pane, choose Subscriptions.

  3. On the Subscriptions page, select a subscription with a Status of Confirmed, and then choose Delete.

  4. In the Delete subscription dialog box, choose Delete.

    The console deletes the subscription.

When you delete a topic, Amazon SNS deletes the subscriptions associated with the topic.

To delete a topic using the AWS Management Console

  1. Sign in to the Amazon SNS console.

  2. In the left navigation pane, choose Topics.

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

  4. In the Delete topic dialog box, enter delete me, and then choose Delete.

    The console deletes the topic.

To delete an Amazon SNS subscription and topic using the AWS SDK for Java

  1. Specify your AWS credentials. For more information, see Set up AWS Credentials and Region for Development in the AWS SDK for Java 2.x Developer Guide.

  2. Write your code. For more information, see Using the SDK for Java 2.x.

    The following code excerpt deletes a topic and then prints the DeleteTopicRequest request ID.

    Important

    When you delete a topic, you also delete all subscriptions to the topic.

    // Delete an Amazon SNS topic. final DeleteTopicRequest deleteTopicRequest = new DeleteTopicRequest(topicArn); snsClient.deleteTopic(deleteTopicRequest); // Print the request ID for the DeleteTopicRequest action. System.out.println("DeleteTopicRequest: " + snsClient.getCachedResponseMetadata(deleteTopicRequest));
  3. Compile and run your code.

    The topic is deleted and the DeleteTopicRequest request ID is printed, for example:

    DeleteTopicRequest: 1234a567-bc89-012d-3e45-6fg7h890123i

To delete an Amazon SNS subscription and topic using the AWS SDK for .NET

  1. Specify your AWS credentials. For more information, see Configuring AWS Credentials in the AWS SDK for .NET Developer Guide.

  2. Write your code. For more information, see Programming with the AWS SDK for .NET.

    The following code excerpt deletes a topic and then prints the DeleteTopicRequest request ID.

    Important

    When you delete a topic, you also delete all subscriptions to the topic.

    // Delete an Amazon SNS topic. DeleteTopicRequest deleteTopicRequest = new DeleteTopicRequest(topicArn); DeleteTopicResponse deleteTopicResponse = snsClient.DeleteTopic(deleteTopicRequest); // Print the request ID for the DeleteTopicRequest action. Console.WriteLine("DeleteTopicRequest: " + deleteTopicResponse.ResponseMetadata.RequestId);
  3. Compile and run your code.

    The topic is deleted and the DeleteTopicRequest request ID is printed, for example:

    DeleteTopicRequest: 1234a567-bc89-012d-3e45-6fg7h890123i