@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
246 lines • 9.06 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** 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, Object.assign(Object.assign({}, 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 ? state.adaptiveProtectionConfig : undefined;
resourceInputs["advancedOptionsConfig"] = state ? state.advancedOptionsConfig : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["fingerprint"] = state ? state.fingerprint : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["recaptchaOptionsConfig"] = state ? state.recaptchaOptionsConfig : undefined;
resourceInputs["rules"] = state ? state.rules : undefined;
resourceInputs["selfLink"] = state ? state.selfLink : undefined;
resourceInputs["type"] = state ? state.type : undefined;
}
else {
const args = argsOrState;
resourceInputs["adaptiveProtectionConfig"] = args ? args.adaptiveProtectionConfig : undefined;
resourceInputs["advancedOptionsConfig"] = args ? args.advancedOptionsConfig : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["recaptchaOptionsConfig"] = args ? args.recaptchaOptionsConfig : undefined;
resourceInputs["rules"] = args ? args.rules : undefined;
resourceInputs["type"] = args ? args.type : undefined;
resourceInputs["fingerprint"] = undefined /*out*/;
resourceInputs["selfLink"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(SecurityPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.SecurityPolicy = SecurityPolicy;
/** @internal */
SecurityPolicy.__pulumiType = 'gcp:compute/securityPolicy:SecurityPolicy';
//# sourceMappingURL=securityPolicy.js.map