How do I recreate a "Deleted" Amazon SNS topic subscription for an Amazon SQS queue in another AWS account?

Last updated: 2021-11-22

My Amazon Simple Queue Service (Amazon SQS) queue was subscribed to an Amazon Simple Notification Service (Amazon SNS) topic in a different AWS account. I deleted the cross-account subscription, and the topic subscription is now in "Deleted" status. How do I recreate a deleted Amazon SNS topic subscription for an Amazon SQS queue in another account?

Short description

If you call the Amazon SNS Unsubscribe API from an account that doesn't own the subscription, the subscription enters Deleted status for 72 hours. While the SNS topic subscription is in Deleted status, the account that owns the subscription can't resubscribe the same endpoint to the topic.

After 72 hours, Amazon SNS clears the Deleted subscription and the account that owns the subscription can resubscribe the same endpoint to the topic.

If you don't want to wait 72 hours to resubscribe, you can manually recreate the subscription by doing any of the following.

Note: It's a best practice to run Subscribe and Unsubscribe API calls from the same AWS account. When you call the Subscribe API, the AWS account that you use to make the call becomes the subscription owner.

Resolution

Important: The following procedures apply to HTTP and HTTPS endpoint subscribers. It doesn't apply to AWS Lambda function subscribers.

Send an HTTP GET method request to the SubscribeURL in the UnsubscribeConfirmation message you received

1.    In the UnsubscribeConfirmation message sent to the SQS queue after you deleted the subscription, find the SubscribeURL. Then, copy and paste the URL to a text document.

2.    Send an HTTP GET method request to the SubscribeURL.

HTTP GET method request example

curl -X GET "https://sns.us-west-2.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-west-2:123456789012:MyTopic&Token=<token>"

Call the Amazon SNS Subscribe API from the AWS account that owns the SNS topic, then confirm the subscription

1.    Call the Amazon SNS Subscribe API from the AWS account that owns the SNS topic.

2.    Have an AWS user with permissions to read messages from the SQS queue confirm the subscription.

Create a new Amazon SNS topic to replace the current topic, then subscribe to the new topic

1.    Create a new SNS topic to replace the current topic.

2.    Subscribe the SQS queue to the new topic.