User is not authorized to perform: SNS:Publish on resource

3.3k views Asked by At

I want to publish a message to a topic provided by aws (aws has provided me the topic for integration purposes). On topic the policy has all the actions and my account also has AmazonSNSFullAccess policy.

{
Policy= {
 "Version":"version_number",
 "Id":"policy_name",
 "Statement":[
  {
   "Sid":"statement",
   "Effect":"Allow",
   "Principal":{"AWS":"*"},
   "Action": ["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic","SNS:Subscribe","SNS:ListSubscriptionsByTopic","SNS:Publish","SNS:Receive"],
   "Resource":"resource",
   "Condition":{"StringEquals":{"AWS:SourceOwner":"number_of_account"}}},
  }]
  some_other_information_about_subscriptions
 }
}

But when I am trying to publish a message to the topic I receive the error

software.amazon.awssdk.services.sns.model.AuthorizationErrorException: User is not authorized to perform: SNS:Publish on resource: <resource> (Service: Sns, Status Code: 403, Request ID: <request_id>, Extended Request ID: null)

As I have seen the policies are fine, but I can not understant why this error occurs.

Have anyone face it before and knows what is going on?

Thank you!

0

There are 0 answers