@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
300 lines • 11.2 kB
JavaScript
;
// *** 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.SecurityPolicy = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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,
* },
* },
* }],
* });
* ```
*
* ### With Advanced Options Config
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const policy = new gcp.compute.SecurityPolicy("policy", {
* name: "my-policy",
* advancedOptionsConfig: {
* jsonParsing: "STANDARD",
* jsonCustomConfig: {
* contentTypes: [
* "application/json",
* "application/vnd.api+json",
* "application/vnd.collection+json",
* "application/vnd.hyper+json",
* ],
* },
* logLevel: "VERBOSE",
* userIpRequestHeaders: [
* "True-Client-IP",
* "x-custom-ip",
* ],
* },
* });
* ```
*
* ## 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}}
* $ pulumi import gcp:compute/securityPolicy:SecurityPolicy default {{project}}/{{name}}
* $ 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 });
}
/** @internal */
static __pulumiType = 'gcp:compute/securityPolicy:SecurityPolicy';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
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["deletionPolicy"] = args?.deletionPolicy;
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;
//# sourceMappingURL=securityPolicy.js.map