When a topic is deleted, its associated subscriptions are deleted asynchronously. While customers can still access these subscriptions, the subscriptions are no longer associated with the topic–even if you recreate the topic using the same name. If a publisher attempts to publish a message to the deleted topic, the publisher will receive an error message indicating that the topic doesn't exist. Similarly, any attempt to subscribe to the deleted topic will also result in an error message. You can't delete a subscription that's pending confirmation. Amazon SNS automatically deletes unconfirmed subscriptions after 48 hours.
To delete an Amazon SNS topic or
subscription using the AWS Management Console
Deleting an Amazon SNS topic or subscription ensures efficient resource management, preventing unnecessary usage and keeping the Amazon SNS console organized. This step helps avoid potential costs from idle resources and streamlines administration by removing topics or subscriptions that are no longer needed.
To delete a topic using the AWS Management Console
Sign in to the Amazon SNS console
. -
In the left navigation pane, choose Topics.
-
On the Topics page, select a topic, and then choose Delete.
-
In the Delete topic dialog box, enter
delete me
, and then choose Delete.The console deletes the topic.
To delete a subscription using the AWS Management Console
Sign in to the Amazon SNS console
. -
In the left navigation pane, choose Subscriptions.
-
On the Subscriptions page, select a subscription with a status of Confirmed, and then choose Delete.
-
In the Delete subscription dialog box, choose Delete.
The console deletes the subscription.
To delete a subscription and 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 examples show how to use DeleteTopic
.
- AWS SDK for .NET
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. Delete a topic by its topic ARN.
/// <summary> /// Delete a topic by its topic ARN. /// </summary> /// <param name="topicArn">The ARN of the topic.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteTopicByArn(string topicArn) { var deleteResponse = await _amazonSNSClient.DeleteTopicAsync( new DeleteTopicRequest() { TopicArn = topicArn }); return deleteResponse.HttpStatusCode == HttpStatusCode.OK; }
-
For API details, see DeleteTopic in AWS SDK for .NET API Reference.
-