"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! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueuePolicy = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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 = aws.iam.getPolicyDocumentOutput({
 *     statements: [{
 *         sid: "First",
 *         effect: "Allow",
 *         principals: [{
 *             type: "*",
 *             identifiers: ["*"],
 *         }],
 *         actions: ["sqs:SendMessage"],
 *         resources: [q.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 });
    }
    /** @internal */
    static __pulumiType = 'aws:sqs/queuePolicy:QueuePolicy';
    /**
     * 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;
//# sourceMappingURL=queuePolicy.js.map