When I use the Java SNS lib provided by AWS and I use the function:
DeleteTopicResponse deleteTopic(DeleteTopicRequest deleteTopicRequest)
I expect the Topic
to be deleted (which it does) and all the Subscriptions
to be deleted as well (which it doesn't).
Having run this application for a while, we found many 'floating' subscriptions in AWS.
The documentation of deleteTopic gives me the impression that it should delete all subscriptions:
Deletes a topic and all its subscriptions. Deleting a topic might prevent some messages previously sent to the topic from being delivered to subscribers. This action is idempotent, so deleting a topic that does not exist does not result in an error.
Any insight on why there are Subscriptions
without a Topic
in our SNS?
Is this a bug? or am misunderstanding this method?
How can this be avoided?
Deleting all subscriptions manually might be a strain on the system, so if possible I would like to avoid that.
According to https://aws.amazon.com/premiumsupport/knowledge-center/sns-cannot-delete-topic-subscription/:
Note: After three days, Amazon SNS automatically removes subscriptions that are in the Deleted and Pending Confirmation status from your account.
This should include the subscriptions associated with the deleted topic.
Note that you may run into issues recreating the subscription if you try to use the same topic name and endpoint before the previous one was deleted.