"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.SecurityPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A Security Policy defines an IP blacklist or whitelist that protects load balanced Google Cloud services by denying or permitting traffic from specified IP ranges. For more information
 * see the [official documentation](https://cloud.google.com/armor/docs/configure-security-policies)
 * and the [API](https://cloud.google.com/compute/docs/reference/rest/beta/securityPolicies).
 *
 * Security Policy is used by google_compute_backend_service.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const policy = new gcp.compute.SecurityPolicy("policy", {
 *     name: "my-policy",
 *     rules: [
 *         {
 *             action: "deny(403)",
 *             priority: 1000,
 *             match: {
 *                 versionedExpr: "SRC_IPS_V1",
 *                 config: {
 *                     srcIpRanges: ["9.9.9.0/24"],
 *                 },
 *             },
 *             description: "Deny access to IPs in 9.9.9.0/24",
 *         },
 *         {
 *             action: "allow",
 *             priority: 2147483647,
 *             match: {
 *                 versionedExpr: "SRC_IPS_V1",
 *                 config: {
 *                     srcIpRanges: ["*"],
 *                 },
 *             },
 *             description: "default rule",
 *         },
 *     ],
 * });
 * ```
 *
 * ### With ReCAPTCHA Configuration Options
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const primary = new gcp.recaptcha.EnterpriseKey("primary", {
 *     displayName: "display-name",
 *     labels: {
 *         "label-one": "value-one",
 *     },
 *     project: "my-project-name",
 *     webSettings: {
 *         integrationType: "INVISIBLE",
 *         allowAllDomains: true,
 *         allowedDomains: ["localhost"],
 *     },
 * });
 * const policy = new gcp.compute.SecurityPolicy("policy", {
 *     name: "my-policy",
 *     description: "basic security policy",
 *     type: "CLOUD_ARMOR",
 *     recaptchaOptionsConfig: {
 *         redirectSiteKey: primary.name,
 *     },
 * });
 * ```
 *
 * ### With Header Actions
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const policy = new gcp.compute.SecurityPolicy("policy", {
 *     name: "my-policy",
 *     rules: [
 *         {
 *             action: "allow",
 *             priority: 2147483647,
 *             match: {
 *                 versionedExpr: "SRC_IPS_V1",
 *                 config: {
 *                     srcIpRanges: ["*"],
 *                 },
 *             },
 *             description: "default rule",
 *         },
 *         {
 *             action: "allow",
 *             priority: 1000,
 *             match: {
 *                 expr: {
 *                     expression: "request.path.matches(\"/login.html\") && token.recaptcha_session.score < 0.2",
 *                 },
 *             },
 *             headerAction: {
 *                 requestHeadersToAdds: [
 *                     {
 *                         headerName: "reCAPTCHA-Warning",
 *                         headerValue: "high",
 *                     },
 *                     {
 *                         headerName: "X-Resource",
 *                         headerValue: "test",
 *                     },
 *                 ],
 *             },
 *         },
 *     ],
 * });
 * ```
 *
 * ### With EnforceOnKey Value As Empty String
 * A scenario example that won't cause any conflict between `enforceOnKey` and `enforceOnKeyConfigs`, because `enforceOnKey` was specified as an empty string:
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const policy = new gcp.compute.SecurityPolicy("policy", {
 *     name: "%s",
 *     description: "throttle rule with enforce_on_key_configs",
 *     rules: [{
 *         action: "throttle",
 *         priority: 2147483647,
 *         match: {
 *             versionedExpr: "SRC_IPS_V1",
 *             config: {
 *                 srcIpRanges: ["*"],
 *             },
 *         },
 *         description: "default rule",
 *         rateLimitOptions: {
 *             conformAction: "allow",
 *             exceedAction: "redirect",
 *             enforceOnKey: "",
 *             enforceOnKeyConfigs: [{
 *                 enforceOnKeyType: "IP",
 *             }],
 *             exceedRedirectOptions: {
 *                 type: "EXTERNAL_302",
 *                 target: "<https://www.example.com>",
 *             },
 *             rateLimitThreshold: {
 *                 count: 10,
 *                 intervalSec: 60,
 *             },
 *         },
 *     }],
 * });
 * ```
 *
 * ## Import
 *
 * Security policies can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/global/securityPolicies/{{name}}`
 *
 * * `{{project}}/{{name}}`
 *
 * * `{{name}}`
 *
 * When using the `pulumi import` command, security policies can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:compute/securityPolicy:SecurityPolicy default projects/{{project}}/global/securityPolicies/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/securityPolicy:SecurityPolicy default {{project}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/securityPolicy:SecurityPolicy default {{name}}
 * ```
 */
class SecurityPolicy extends pulumi.CustomResource {
    /**
     * Get an existing SecurityPolicy 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 SecurityPolicy(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of SecurityPolicy.  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'] === SecurityPolicy.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["adaptiveProtectionConfig"] = state?.adaptiveProtectionConfig;
            resourceInputs["advancedOptionsConfig"] = state?.advancedOptionsConfig;
            resourceInputs["description"] = state?.description;
            resourceInputs["effectiveLabels"] = state?.effectiveLabels;
            resourceInputs["fingerprint"] = state?.fingerprint;
            resourceInputs["labelFingerprint"] = state?.labelFingerprint;
            resourceInputs["labels"] = state?.labels;
            resourceInputs["name"] = state?.name;
            resourceInputs["project"] = state?.project;
            resourceInputs["pulumiLabels"] = state?.pulumiLabels;
            resourceInputs["recaptchaOptionsConfig"] = state?.recaptchaOptionsConfig;
            resourceInputs["rules"] = state?.rules;
            resourceInputs["selfLink"] = state?.selfLink;
            resourceInputs["type"] = state?.type;
        }
        else {
            const args = argsOrState;
            resourceInputs["adaptiveProtectionConfig"] = args?.adaptiveProtectionConfig;
            resourceInputs["advancedOptionsConfig"] = args?.advancedOptionsConfig;
            resourceInputs["description"] = args?.description;
            resourceInputs["labels"] = args?.labels;
            resourceInputs["name"] = args?.name;
            resourceInputs["project"] = args?.project;
            resourceInputs["recaptchaOptionsConfig"] = args?.recaptchaOptionsConfig;
            resourceInputs["rules"] = args?.rules;
            resourceInputs["type"] = args?.type;
            resourceInputs["effectiveLabels"] = undefined /*out*/;
            resourceInputs["fingerprint"] = undefined /*out*/;
            resourceInputs["labelFingerprint"] = undefined /*out*/;
            resourceInputs["pulumiLabels"] = undefined /*out*/;
            resourceInputs["selfLink"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(SecurityPolicy.__pulumiType, name, resourceInputs, opts);
    }
}
exports.SecurityPolicy = SecurityPolicy;
/** @internal */
SecurityPolicy.__pulumiType = 'gcp:compute/securityPolicy:SecurityPolicy';
//# sourceMappingURL=securityPolicy.js.map