I want to send Amazon SNS Messages to Amazon SQS Queues from the backend Java application. According to SNS Developer Guide (http://docs.aws.amazon.com/sns/latest/dg/sns-dg.pdf), in the section "Sending Amazon SNS Messages to Amazon SQS Queues", under the topic - "Step 2. Give permission to the Amazon SNS topic to send messages to the Amazon SQS queue", it is written as,
If you wanted to create the policy document yourself, you would create a policy like the following. The policy allows MyTopic to send messages to MyQueue.
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"MySQSPolicy001",
"Effect":"Allow",
"Principal":"*",
"Action":"sqs:SendMessage",
"Resource":"arn:aws:sqs:us-east-1:123456789012:MyQueue",
"Condition":{
"ArnEquals":{
"aws:SourceArn":"arn:aws:sns:us-east-1:123456789012:MyTopic"
}
}
}
]
}
My doubt is how to use this policy document(.json file if I am not wrong) in my java application and where to use it exactly? Because I must set a policy on the queue that allows the Amazon SNS topic to perform the sqs:SendMessage action. TIA.
You don't have to do it in a Java application.
Go to AWS console, select IAM service, choose a user (or create one) and then, under Permissions, you attach Policies.
This is how it looks like:
Policies (the JSON documents) can be chosen from a list, generated using a wizard or entered manually (that's what you want).