AWS Amazon SQS Queue Policy
This page shows how to write Terraform and CloudFormation for Amazon SQS Queue Policy and write them securely.
aws_sqs_queue_policy (Terraform)
The Queue Policy in Amazon SQS can be configured in Terraform with the resource name aws_sqs_queue_policy
. The following sections describe 3 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_sqs_queue_policy" "valid_sqs_policy_condition" {
queue_url = "SampleQueue"
policy = <<EOF
{
"Version": "2012-10-17",
resource "aws_sqs_queue_policy" "mo" {
queue_url = aws_sqs_queue.mo.id
policy = data.aws_iam_policy_document.mo.json
}
data "aws_iam_policy_document" "mo" {
resource "aws_sqs_queue_policy" "sqs_policy_allow_no_wildcard" {
queue_url = "https://queue.amazonaws.com/0123456789012/myqueue"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Parameters
Explanation in Terraform Registry
Allows you to set a policy of an SQS Queue while referencing ARN of the queue within the policy.
AWS::SQS::QueuePolicy (CloudFormation)
The QueuePolicy in SQS can be configured in CloudFormation with the resource name AWS::SQS::QueuePolicy
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- !Ref MwsReportSubDE
PolicyDocument:
Version: "2012-10-17"
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
-
Effect: Allow
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: allow-sns-messages
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: "allow-sns-messages"
Type: AWS::SQS::QueuePolicy
expectations:
rules:
delta_sqs_public_access: FAIL
- name: MyTest4
input:
"Type": "AWS::SQS::QueuePolicy",
"Properties": {
"Queues": [
{
"Ref": "INVCLOSECASHIER"
}
"Type" : "AWS::SQS::QueuePolicy",
"Properties" : {
"PolicyDocument" : {
"Id" : "MyQueuePolicy",
"Version" : "2012-10-17",
"Statement" : [ {
"Type" : "AWS::SQS::QueuePolicy",
"Properties" : {
"PolicyDocument" : {
"Id" : "MyQueuePolicy",
"Version" : "2012-10-17",
"Statement" : [ {
"Type" : "AWS::SQS::QueuePolicy",
"Properties" : {
"PolicyDocument" : {
"Id" : "MyQueuePolicy",
"Version" : "2012-10-17",
"Statement" : [ {
"Type": "AWS::SQS::QueuePolicy",
"Properties": {
"PolicyDocument": {
"Id": "MyQueuePolicy",
"Version": "2012-10-17",
"Statement": [
Parameters
-
PolicyDocument
required - Json -
Queues
required - List
Explanation in CloudFormation Registry
The
AWS::SQS::QueuePolicy
type applies a policy to Amazon SQS queues. For an example snippet, see Declaring an Amazon SQS policy in the AWS CloudFormation User Guide.
Frequently asked questions
What is AWS Amazon SQS Queue Policy?
AWS Amazon SQS Queue Policy is a resource for Amazon SQS of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon SQS Queue Policy?
For Terraform, the Cigna/confectionery, rock7/cloudloop-sqs-terraform-module and ffsclyh/config-lint source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the kaskadi/amz-reports-hooks, PhonyLou/hello_sqs_sns and WojciechMatuszewski/golang-upload-fanout source code examples are useful. See the CloudFormation Example section for further details.