Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SQS Policy to allow an S3 bucket to publish messages
{
"Version": "2012-10-17",
"Id": "arn:aws:sqs:YOUR-AWS-REGION:YOUR-AWS-ACCOUNT-ID:YOUR-QUEUE-NAME/SQSDefaultPolicy",
"Statement": [
{
"Sid": "example-statement-ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "SQS:SendMessage",
"Resource": "arn:aws:sqs:YOUR-AWS-REGION:YOUR-AWS-ACCOUNT-ID:YOUR-QUEUE-NAME",
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:s3:*:*:YOUR-S3-BUCKET"
}
}
}
]
}
@spicoflorin
Copy link

spicoflorin commented May 23, 2017

Thank you very much for sharing this.

@dogenius01
Copy link

dogenius01 commented May 31, 2018

Thank you very much for sharing this.

@Necromancerx
Copy link

Necromancerx commented Nov 20, 2018

Thank you very much for sharing this.

@rynsantos
Copy link

rynsantos commented Dec 11, 2018

I'm just wondering if in S3 you also need to add a policy to allow it to notify the SQS? Thanks for sharing it is very helpful.

@bcpenta
Copy link

bcpenta commented Feb 14, 2019

I'm just wondering if in S3 you also need to add a policy to allow it to notify the SQS? Thanks for sharing it is very helpful.

In S3 bucket properties, you can scroll down to events, add a notification rule. and set it to SQS Queue. SO an operation you do will send a message to sqs queue.

@TheoLeanse
Copy link

TheoLeanse commented Aug 7, 2019

LEGEND

@m-abubakar-saddique
Copy link

m-abubakar-saddique commented Jan 15, 2020

Thanks it helped me to solve my problem.

@ashwiniunison
Copy link

ashwiniunison commented Feb 5, 2020

This Solved the problem.

Thanks!!

@chuong-dao
Copy link

chuong-dao commented Feb 11, 2020

Can we do a wildcard "aws:SourceArn": "arn:aws:s3:::bucket-name*" ? I tried and it didn't work for me. Wondering if you guys have any suggestions. I am OK with limiting even to the account level. Thanks!

@nikhilshinde57
Copy link

nikhilshinde57 commented Feb 18, 2020

Thanks Marcelo Gornstein for sharing this information it's really helpful.

@byung-u
Copy link

byung-u commented Jun 26, 2020

Thank you, it's really helpful for me.

@jklacy3
Copy link

jklacy3 commented Jul 25, 2020

hmm. can't get this to work. i created a empty S3 bucket, tried to create sqs notification action. Still getting queue permission error queue. Any ideas?

@melvin-felix
Copy link

melvin-felix commented Oct 8, 2020

<3

@vinay2696
Copy link

vinay2696 commented Jul 21, 2021

what if I want to use the same queue in a multiply bucket, then what all changes need to do in the above Policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment