User guide
AmazonSQS sqs = new AmazonSQSClient(myAwsCredentials);
sqs.setQueueAttributes(new SetQueueAttributesRequest(myQueueUrl, queueAttrib
utes));
Amazon SNS Example
Some services offer additional conditions that can be used in policies. Amazon SNS provides conditions
for allowing or denying subscriptions to SNS topics based on the protocol (e.g., email, HTTP, HTTPS,
SQS) and endpoint (e.g., email address, URL, SQS ARN) of the request to subscribe to a topic.
/*
* This SNS condition allows you to restrict subscriptions to an Amazon SNS
topic
* based on the requested endpoint (email address, SQS queue ARN, etc.) used
when
* someone tries to subscribe to your SNS topic.
*/
Condition endpointCondition =
SNSConditionFactory.newEndpointCondition("*@mycompany.com");
Policy policy = new Policy().withStatements(
new Statement(Effect.Allow)
.withPrincipals(Principal.AllUsers)
.withActions(SNSActions.Subscribe)
.withConditions(endpointCondition));
AmazonSNS sns = new AmazonSNSClient(myAwsCredentials);
sns.setTopicAttributes(
new SetTopicAttributesRequest(myTopicArn, "Policy", policy.toJson()));
Version v1.0.0
22
AWS SDK for Java Developer Guide
Access Control Policies