UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

217 lines • 8 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.SecurityPolicyRule = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * A rule for the SecurityPolicy. * * To get more information about SecurityPolicyRule, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/securityPolicies/addRule) * * How-to Guides * * [Creating global security policy rules](https://cloud.google.com/armor/docs/configure-security-policies) * * ## Example Usage * * ### Security Policy Rule Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.SecurityPolicy("default", { * name: "policyruletest", * description: "basic global security policy", * type: "CLOUD_ARMOR", * }); * const policyRule = new gcp.compute.SecurityPolicyRule("policy_rule", { * securityPolicy: _default.name, * description: "new rule", * priority: 100, * match: { * versionedExpr: "SRC_IPS_V1", * config: { * srcIpRanges: ["10.10.0.0/16"], * }, * }, * action: "allow", * preview: true, * }); * ``` * ### Security Policy Rule Default Rule * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.SecurityPolicy("default", { * name: "policyruletest", * description: "basic global security policy", * type: "CLOUD_ARMOR", * }); * const defaultRule = new gcp.compute.SecurityPolicyRule("default_rule", { * securityPolicy: _default.name, * description: "default rule", * action: "deny", * priority: 2147483647, * match: { * versionedExpr: "SRC_IPS_V1", * config: { * srcIpRanges: ["*"], * }, * }, * }); * const policyRule = new gcp.compute.SecurityPolicyRule("policy_rule", { * securityPolicy: _default.name, * description: "new rule", * priority: 100, * match: { * versionedExpr: "SRC_IPS_V1", * config: { * srcIpRanges: ["10.10.0.0/16"], * }, * }, * action: "allow", * preview: true, * }); * ``` * ### Security Policy Rule Multiple Rules * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.SecurityPolicy("default", { * name: "policywithmultiplerules", * description: "basic global security policy", * type: "CLOUD_ARMOR", * }); * const policyRuleOne = new gcp.compute.SecurityPolicyRule("policy_rule_one", { * securityPolicy: _default.name, * description: "new rule one", * priority: 100, * match: { * versionedExpr: "SRC_IPS_V1", * config: { * srcIpRanges: ["10.10.0.0/16"], * }, * }, * action: "allow", * preview: true, * }); * const policyRuleTwo = new gcp.compute.SecurityPolicyRule("policy_rule_two", { * securityPolicy: _default.name, * description: "new rule two", * priority: 101, * match: { * versionedExpr: "SRC_IPS_V1", * config: { * srcIpRanges: [ * "192.168.0.0/16", * "10.0.0.0/8", * ], * }, * }, * action: "allow", * preview: true, * }); * ``` * * ## Import * * SecurityPolicyRule can be imported using any of these accepted formats: * * * `projects/{{project}}/global/securityPolicies/{{security_policy}}/priority/{{priority}}` * * * `{{project}}/{{security_policy}}/{{priority}}` * * * `{{security_policy}}/{{priority}}` * * When using the `pulumi import` command, SecurityPolicyRule can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/securityPolicyRule:SecurityPolicyRule default projects/{{project}}/global/securityPolicies/{{security_policy}}/priority/{{priority}} * ``` * * ```sh * $ pulumi import gcp:compute/securityPolicyRule:SecurityPolicyRule default {{project}}/{{security_policy}}/{{priority}} * ``` * * ```sh * $ pulumi import gcp:compute/securityPolicyRule:SecurityPolicyRule default {{security_policy}}/{{priority}} * ``` */ class SecurityPolicyRule extends pulumi.CustomResource { /** * Get an existing SecurityPolicyRule 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 SecurityPolicyRule(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of SecurityPolicyRule. 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'] === SecurityPolicyRule.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["action"] = state?.action; resourceInputs["description"] = state?.description; resourceInputs["headerAction"] = state?.headerAction; resourceInputs["match"] = state?.match; resourceInputs["preconfiguredWafConfig"] = state?.preconfiguredWafConfig; resourceInputs["preview"] = state?.preview; resourceInputs["priority"] = state?.priority; resourceInputs["project"] = state?.project; resourceInputs["rateLimitOptions"] = state?.rateLimitOptions; resourceInputs["redirectOptions"] = state?.redirectOptions; resourceInputs["securityPolicy"] = state?.securityPolicy; } else { const args = argsOrState; if (args?.action === undefined && !opts.urn) { throw new Error("Missing required property 'action'"); } if (args?.priority === undefined && !opts.urn) { throw new Error("Missing required property 'priority'"); } if (args?.securityPolicy === undefined && !opts.urn) { throw new Error("Missing required property 'securityPolicy'"); } resourceInputs["action"] = args?.action; resourceInputs["description"] = args?.description; resourceInputs["headerAction"] = args?.headerAction; resourceInputs["match"] = args?.match; resourceInputs["preconfiguredWafConfig"] = args?.preconfiguredWafConfig; resourceInputs["preview"] = args?.preview; resourceInputs["priority"] = args?.priority; resourceInputs["project"] = args?.project; resourceInputs["rateLimitOptions"] = args?.rateLimitOptions; resourceInputs["redirectOptions"] = args?.redirectOptions; resourceInputs["securityPolicy"] = args?.securityPolicy; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(SecurityPolicyRule.__pulumiType, name, resourceInputs, opts); } } exports.SecurityPolicyRule = SecurityPolicyRule; /** @internal */ SecurityPolicyRule.__pulumiType = 'gcp:compute/securityPolicyRule:SecurityPolicyRule'; //# sourceMappingURL=securityPolicyRule.js.map