AWS code-library documentation change
Summary
Added PowerShell V5 examples for SetQueueAttributes API including policy configuration for SNS-SQS integration
Security assessment
The example demonstrates configuring resource policies with conditional access controls (ArnEquals condition), which documents security feature implementation
Diff
diff --git a/code-library/latest/ug/sqs_example_sqs_SetQueueAttributes_section.md b/code-library/latest/ug/sqs_example_sqs_SetQueueAttributes_section.md index 8459db10f..b68c233af 100644 --- a//code-library/latest/ug/sqs_example_sqs_SetQueueAttributes_section.md +++ b//code-library/latest/ug/sqs_example_sqs_SetQueueAttributes_section.md @@ -572,0 +573,52 @@ PowerShell +**Tools for PowerShell V5** + + +**Example 1: This example shows how to set a policy subscribing a queue to an SNS topic. When a message is published to the topic, a message is sent to the subscribed queue.** + + + # create the queue and topic to be associated + $qurl = New-SQSQueue -QueueName "myQueue" + $topicarn = New-SNSTopic -Name "myTopic" + + # get the queue ARN to inject into the policy; it will be returned + # in the output's QueueARN member but we need to put it into a variable + # so text expansion in the policy string takes effect + $qarn = (Get-SQSQueueAttribute -QueueUrl $qurl -AttributeName "QueueArn").QueueARN + + # construct the policy and inject arns + $policy = @" + { + "Version": "2008-10-17", + "Id": "$qarn/SQSPOLICY", + "Statement": [ + { + "Sid": "1", + "Effect": "Allow", + "Principal": "*", + "Action": "SQS:SendMessage", + "Resource": "$qarn", + "Condition": { + "ArnEquals": { + "aws:SourceArn": "$topicarn" + } + } + } + ] + } + "@ + + # set the policy + Set-SQSQueueAttribute -QueueUrl $qurl -Attribute @{ Policy=$policy } + + +**Example 2: This example sets the specified attributes for the specified queue.** + + + Set-SQSQueueAttribute -Attribute @{"DelaySeconds" = "10"; "MaximumMessageSize" = "131072"} -QueueUrl https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue + + + * For API details, see [SetQueueAttributes](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. + + + +