/** * Generate a policy that will allow messages published to an SNS topic * to be sent to all queues subscribed to that topic * @param topicArn the topic to create policy for * @return The policy */ private Policy makePolicy(String topicArn) { //SQSActions.SendMessage does not work!! Action sendMessageAction = new Action() { @Override public String getActionName() { return "SQS:SendMessage"; } }; return new Policy().withId("sns2sqs").withStatements( new Statement(Statement.Effect.Allow) .withPrincipals(Principal.AllUsers) .withActions(sendMessageAction) .withResources(new Resource(queueArn)) .withConditions(new ArnCondition(ArnCondition.ArnComparisonType.ArnEquals, ConditionFactory.SOURCE_ARN_CONDITION_KEY, topicArn))); }