How to delete SNS Topic using AWS CLI


If you want to delete an AWS SNS Topic via AWS CLI - Command Line Interface, you can make use of the below steps.


Step 1: Get the List of all SNS Topics

% aws sns list-topics

-----------------------------------------------------
|                    ListTopics                     |
+---------------------------------------------------+
||                     Topics                      ||
|+-------------------------------------------------+|
||                    TopicArn                     ||
|+-------------------------------------------------+|
||  arn:aws:sns:us-east-1:5xx2xx665xx1:emailTopic  ||
||  arn:aws:sns:us-east-1:5xx2xx665xx1:smsTopic    ||
|+-------------------------------------------------+|

Step 2: Unsubscribe Subscriptions if Any

% aws sns unsubscribe --subscription-arn arn:aws:sns:us-east-1:5xx2xx665xx1:smsTopic:e25591a4-xx-xx-xx-xx

Step 3: Delete SNS Topic

% aws sns delete-topic --topic-arn arn:aws:sns:us-east-1:5xx2xx665xx1:smsTopic
Example - Delete AWS SNS Topic via CLI Command

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap