UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

136 lines 5.05 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.QueuePolicy = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Allows you to set a policy of an SQS Queue while referencing the ARN of the queue within the policy. * * !> AWS will hang indefinitely when creating or updating an `aws.sqs.Queue` with an associated policy if `Version = "2012-10-17"` is not explicitly set in the policy. See below for an example of how to avoid this issue. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const q = new aws.sqs.Queue("q", {name: "examplequeue"}); * const test = q.arn.apply(arn => aws.iam.getPolicyDocumentOutput({ * statements: [{ * sid: "First", * effect: "Allow", * principals: [{ * type: "*", * identifiers: ["*"], * }], * actions: ["sqs:SendMessage"], * resources: [arn], * conditions: [{ * test: "ArnEquals", * variable: "aws:SourceArn", * values: [example.arn], * }], * }], * })); * const testQueuePolicy = new aws.sqs.QueuePolicy("test", { * queueUrl: q.id, * policy: test.apply(test => test.json), * }); * ``` * * ### Timeout Problems Creating/Updating * * If `Version = "2012-10-17"` is not explicitly set in the policy, AWS may hang, causing the AWS provider to time out. To avoid this, make sure to include `Version` as shown in the example below. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.Bucket("example", {bucket: "brodobaggins"}); * const exampleQueue = new aws.sqs.Queue("example", {name: "be-giant"}); * const exampleQueuePolicy = new aws.sqs.QueuePolicy("example", { * queueUrl: exampleQueue.id, * policy: pulumi.jsonStringify({ * Version: "2012-10-17", * Statement: [{ * Sid: "Cejuwdam", * Effect: "Allow", * Principal: { * Service: "s3.amazonaws.com", * }, * Action: "SQS:SendMessage", * Resource: exampleQueue.arn, * Condition: { * ArnLike: { * "aws:SourceArn": example.arn, * }, * }, * }], * }), * }); * ``` * * ## Import * * Using `pulumi import`, import SQS Queue Policies using the queue URL. For example: * * ```sh * $ pulumi import aws:sqs/queuePolicy:QueuePolicy test https://queue.amazonaws.com/123456789012/myqueue * ``` */ class QueuePolicy extends pulumi.CustomResource { /** * Get an existing QueuePolicy resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new QueuePolicy(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of QueuePolicy. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === QueuePolicy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["policy"] = state?.policy; resourceInputs["queueUrl"] = state?.queueUrl; resourceInputs["region"] = state?.region; } else { const args = argsOrState; if (args?.policy === undefined && !opts.urn) { throw new Error("Missing required property 'policy'"); } if (args?.queueUrl === undefined && !opts.urn) { throw new Error("Missing required property 'queueUrl'"); } resourceInputs["policy"] = args?.policy; resourceInputs["queueUrl"] = args?.queueUrl; resourceInputs["region"] = args?.region; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(QueuePolicy.__pulumiType, name, resourceInputs, opts); } } exports.QueuePolicy = QueuePolicy; /** @internal */ QueuePolicy.__pulumiType = 'aws:sqs/queuePolicy:QueuePolicy'; //# sourceMappingURL=queuePolicy.js.map