UNPKG

@pulumi/gcp

Version:

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

203 lines • 8.38 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! *** 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.Firewall = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Each network has its own firewall controlling access to and from the * instances. * * All traffic to instances, even from other instances, is blocked by the * firewall unless firewall rules are created to allow it. * * The default network has automatically created firewall rules that are * shown in default firewall rules. No manually created network has * automatically created firewall rules except for a default "allow" rule for * outgoing traffic and a default "deny" for incoming traffic. For all * networks except the default network, you must create any firewall rules * you need. * * To get more information about Firewall, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/v1/firewalls) * * How-to Guides * * [Official Documentation](https://cloud.google.com/vpc/docs/firewalls) * * ## Example Usage * * ### Firewall Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultNetwork = new gcp.compute.Network("default", {name: "test-network"}); * const _default = new gcp.compute.Firewall("default", { * name: "test-firewall", * network: defaultNetwork.name, * allows: [ * { * protocol: "icmp", * }, * { * protocol: "tcp", * ports: [ * "80", * "8080", * "1000-2000", * ], * }, * ], * sourceTags: ["web"], * }); * ``` * ### Firewall With Target Tags * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const rules = new gcp.compute.Firewall("rules", { * project: "my-project-name", * name: "my-firewall-rule", * network: "default", * description: "Creates firewall rule targeting tagged instances", * allows: [{ * protocol: "tcp", * ports: [ * "80", * "8080", * "1000-2000", * ], * }], * sourceTags: ["foo"], * targetTags: ["web"], * }); * ``` * * ## Import * * Firewall can be imported using any of these accepted formats: * * * `projects/{{project}}/global/firewalls/{{name}}` * * `{{project}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, Firewall can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/firewall:Firewall default projects/{{project}}/global/firewalls/{{name}} * $ pulumi import gcp:compute/firewall:Firewall default {{project}}/{{name}} * $ pulumi import gcp:compute/firewall:Firewall default {{name}} * ``` */ class Firewall extends pulumi.CustomResource { /** * Get an existing Firewall 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 Firewall(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:compute/firewall:Firewall'; /** * Returns true if the given object is an instance of Firewall. 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'] === Firewall.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["allows"] = state?.allows; resourceInputs["creationTimestamp"] = state?.creationTimestamp; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["denies"] = state?.denies; resourceInputs["description"] = state?.description; resourceInputs["destinationRanges"] = state?.destinationRanges; resourceInputs["direction"] = state?.direction; resourceInputs["disabled"] = state?.disabled; resourceInputs["enableLogging"] = state?.enableLogging; resourceInputs["logConfig"] = state?.logConfig; resourceInputs["name"] = state?.name; resourceInputs["network"] = state?.network; resourceInputs["params"] = state?.params; resourceInputs["priority"] = state?.priority; resourceInputs["project"] = state?.project; resourceInputs["selfLink"] = state?.selfLink; resourceInputs["sourceRanges"] = state?.sourceRanges; resourceInputs["sourceServiceAccounts"] = state?.sourceServiceAccounts; resourceInputs["sourceTags"] = state?.sourceTags; resourceInputs["targetServiceAccounts"] = state?.targetServiceAccounts; resourceInputs["targetTags"] = state?.targetTags; } else { const args = argsOrState; if (args?.network === undefined && !opts.urn) { throw new Error("Missing required property 'network'"); } resourceInputs["allows"] = args?.allows; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["denies"] = args?.denies; resourceInputs["description"] = args?.description; resourceInputs["destinationRanges"] = args?.destinationRanges; resourceInputs["direction"] = args?.direction; resourceInputs["disabled"] = args?.disabled; resourceInputs["enableLogging"] = args?.enableLogging; resourceInputs["logConfig"] = args?.logConfig; resourceInputs["name"] = args?.name; resourceInputs["network"] = args?.network; resourceInputs["params"] = args?.params; resourceInputs["priority"] = args?.priority; resourceInputs["project"] = args?.project; resourceInputs["sourceRanges"] = args?.sourceRanges; resourceInputs["sourceServiceAccounts"] = args?.sourceServiceAccounts; resourceInputs["sourceTags"] = args?.sourceTags; resourceInputs["targetServiceAccounts"] = args?.targetServiceAccounts; resourceInputs["targetTags"] = args?.targetTags; resourceInputs["creationTimestamp"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Firewall.__pulumiType, name, resourceInputs, opts); } } exports.Firewall = Firewall; //# sourceMappingURL=firewall.js.map