Search code examples
amazon-web-servicescommand-line-interfaceamazon-sns

List Pending Subscriptions in AWS SNS topic


I have subscribed with SNS with multiple emails and few emails are wrong and I see the status as "Pending Confirmation". I'm looking for a command to list the subscriptions array having only PendingConfirmation subscriptedARns.

By using the below command I'm getting all the subscription list but I just need Pending Confirmation Subscriptions: aws sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-east-1:xxxxx:qwertyuuyt

{
    "Subscriptions": [
        {
            "SubscriptionArn": "arn:aws:sns:us-east-1:xxxxxxx:qwertyuuyt:ccffgv-e904-4f68-9a8f-vvggbb",
            "Owner": "xxxxxxx",
            "Protocol": "email",
            "Endpoint": "qwerty@amazon.com",
            "TopicArn": "arn:aws:sns:us-east-1:xxxxxxx:qwertyuuyt"
        },
        {
            "SubscriptionArn": "PendingConfirmation",
            "Owner": "xxxxxxx",
            "Protocol": "email",
            "Endpoint": "qwer@amazo.com",
            "TopicArn": "arn:aws:sns:us-east-1:xxxxxxx:qwertyuuyt"
        },
        {
            "SubscriptionArn": "PendingConfirmation",
            "Owner": "xxxxxxx",
            "Protocol": "email",
            "Endpoint": "qwettet@amazn.com",
            "TopicArn": "arn:aws:sns:us-east-1:xxxxxxx:qwertyuuyt"
        }`cv`
    ]
}

Solution

  • You should be able to do it using the following --query:

    aws sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-east-1:xxxxx:qwertyuuyt --query "Subscriptions[?SubscriptionArn=='PendingConfirmation']"