How to Check AWS SNS Permissions using CLI


If you want to know the permissions of an AWS SNS Topic, you can do that by making use of the aws sns get-topic-attributes command.

Let's take a look at an example.

Command:
% aws sns get-topic-attributes --topic-arn arn:aws:sns:us-east-1: x13xx47428xx:testSNS --output json
Output:
{
  "Attributes": {
    "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\"],\"Resource\":\"arn:aws:sns:us-east-1:x13xx47428xx:testSNS\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"713664742867\"}}}]}",
    "Owner": "xx3664xx28xx",
    "SubscriptionsPending": "0",
    "TopicArn": "arn:aws:sns:us-east-1:xx366xx428xx:testSNS",
    "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultRequestPolicy\":{\"headerContentType\":\"text/plain; charset=UTF-8\"}}}",
    "SubscriptionsConfirmed": "0",
    "DisplayName": "",
    "SubscriptionsDeleted": "0"
  }
}
-

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


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

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