QueuePolicy
Allows you to set a policy of an SQS Queue while referencing ARN of the queue within the policy.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var queue = new Aws.Sqs.Queue("queue", new Aws.Sqs.QueueArgs
{
});
var test = new Aws.Sqs.QueuePolicy("test", new Aws.Sqs.QueuePolicyArgs
{
Policy = queue.Arn.Apply(arn => @$"{{
""Version"": ""2012-10-17"",
""Id"": ""sqspolicy"",
""Statement"": [
{{
""Sid"": ""First"",
""Effect"": ""Allow"",
""Principal"": ""*"",
""Action"": ""sqs:SendMessage"",
""Resource"": ""{arn}"",
""Condition"": {{
""ArnEquals"": {{
""aws:SourceArn"": ""{aws_sns_topic.Example.Arn}""
}}
}}
}}
]
}}
"),
QueueUrl = queue.Id,
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/sqs"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
queue, err := sqs.NewQueue(ctx, "queue", nil)
if err != nil {
return err
}
_, err = sqs.NewQueuePolicy(ctx, "test", &sqs.QueuePolicyArgs{
Policy: queue.Arn.ApplyT(func(arn string) (string, error) {
return fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", "{\n", " \"Version\": \"2012-10-17\",\n", " \"Id\": \"sqspolicy\",\n", " \"Statement\": [\n", " {\n", " \"Sid\": \"First\",\n", " \"Effect\": \"Allow\",\n", " \"Principal\": \"*\",\n", " \"Action\": \"sqs:SendMessage\",\n", " \"Resource\": \"", arn, "\",\n", " \"Condition\": {\n", " \"ArnEquals\": {\n", " \"aws:SourceArn\": \"", aws_sns_topic.Example.Arn, "\"\n", " }\n", " }\n", " }\n", " ]\n", "}\n", "\n"), nil
}).(pulumi.StringOutput),
QueueUrl: queue.ID(),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
queue = aws.sqs.Queue("queue")
test = aws.sqs.QueuePolicy("test",
policy=queue.arn.apply(lambda arn: f"""{{
"Version": "2012-10-17",
"Id": "sqspolicy",
"Statement": [
{{
"Sid": "First",
"Effect": "Allow",
"Principal": "*",
"Action": "sqs:SendMessage",
"Resource": "{arn}",
"Condition": {{
"ArnEquals": {{
"aws:SourceArn": "{aws_sns_topic["example"]["arn"]}"
}}
}}
}}
]
}}
"""),
queue_url=queue.id)import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const queue = new aws.sqs.Queue("q", {});
const test = new aws.sqs.QueuePolicy("test", {
policy: pulumi.interpolate`{
"Version": "2012-10-17",
"Id": "sqspolicy",
"Statement": [
{
"Sid": "First",
"Effect": "Allow",
"Principal": "*",
"Action": "sqs:SendMessage",
"Resource": "${queue.arn}",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "${aws_sns_topic_example.arn}"
}
}
}
]
}
`,
queueUrl: queue.id,
});Create a QueuePolicy Resource
new QueuePolicy(name: string, args: QueuePolicyArgs, opts?: CustomResourceOptions);def QueuePolicy(resource_name, opts=None, policy=None, queue_url=None, __props__=None);func NewQueuePolicy(ctx *Context, name string, args QueuePolicyArgs, opts ...ResourceOption) (*QueuePolicy, error)public QueuePolicy(string name, QueuePolicyArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args QueuePolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args QueuePolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args QueuePolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
QueuePolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The QueuePolicy resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the QueuePolicy resource produces the following output properties:
Look up an Existing QueuePolicy Resource
Get an existing QueuePolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: QueuePolicyState, opts?: CustomResourceOptions): QueuePolicystatic get(resource_name, id, opts=None, policy=None, queue_url=None, __props__=None);func GetQueuePolicy(ctx *Context, name string, id IDInput, state *QueuePolicyState, opts ...ResourceOption) (*QueuePolicy, error)public static QueuePolicy Get(string name, Input<string> id, QueuePolicyState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.