Policy sqsPolicy =
new Policy().withStatements(
new Statement(Effect.Allow)
.withPrincipals(Principal.AllUsers)
.withActions(SQSActions.SendMessage)
.withResources(new Resource(queueARN))
.withConditions(ConditionFactory.newSourceArnCondition(topicArn)));
sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson())));
sns.subscribe(new SubscribeRequest(topicArn, "sqs", queueARN));
}