Skip to content

Resource: awsSqsQueuePolicy

Allows you to set a policy of an SQS Queue while referencing ARN of the queue within the policy.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsSqsQueueQ = new aws.sqsQueue.SqsQueue(this, "q", {
  name: "examplequeue",
});
const dataAwsIamPolicyDocumentTest =
  new aws.dataAwsIamPolicyDocument.DataAwsIamPolicyDocument(this, "test", {
    statement: [
      {
        actions: ["sqs:SendMessage"],
        condition: [
          {
            test: "ArnEquals",
            values: ["${aws_sns_topic.example.arn}"],
            variable: "aws:SourceArn",
          },
        ],
        effect: "Allow",
        principals: [
          {
            identifiers: ["*"],
            type: "*",
          },
        ],
        resources: [awsSqsQueueQ.arn],
        sid: "First",
      },
    ],
  });
const awsSqsQueuePolicyTest = new aws.sqsQueuePolicy.SqsQueuePolicy(
  this,
  "test_2",
  {
    policy: dataAwsIamPolicyDocumentTest.json,
    queueUrl: awsSqsQueueQ.id,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsSqsQueuePolicyTest.overrideLogicalId("test");

Argument Reference

The following arguments are supported:

  • queueUrl - (Required) The URL of the SQS Queue to which to attach the policy
  • policy - (Required) The JSON policy for the SQS queue. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide.

Attributes Reference

No additional attributes are exported.

Import

SQS Queue Policies can be imported using the queue URL, e.g.,

$ terraform import aws_sqs_queue_policy.test https://queue.amazonaws.com/0123456789012/myqueue