UNPKG

@pulumi/gcp

Version:

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

184 lines • 7.85 kB
"use strict"; // *** 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.Firewall = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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}} * ``` * * ```sh * $ pulumi import gcp:compute/firewall:Firewall default {{project}}/{{name}} * ``` * * ```sh * $ 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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 ? state.allows : undefined; resourceInputs["creationTimestamp"] = state ? state.creationTimestamp : undefined; resourceInputs["denies"] = state ? state.denies : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["destinationRanges"] = state ? state.destinationRanges : undefined; resourceInputs["direction"] = state ? state.direction : undefined; resourceInputs["disabled"] = state ? state.disabled : undefined; resourceInputs["enableLogging"] = state ? state.enableLogging : undefined; resourceInputs["logConfig"] = state ? state.logConfig : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["network"] = state ? state.network : undefined; resourceInputs["priority"] = state ? state.priority : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["selfLink"] = state ? state.selfLink : undefined; resourceInputs["sourceRanges"] = state ? state.sourceRanges : undefined; resourceInputs["sourceServiceAccounts"] = state ? state.sourceServiceAccounts : undefined; resourceInputs["sourceTags"] = state ? state.sourceTags : undefined; resourceInputs["targetServiceAccounts"] = state ? state.targetServiceAccounts : undefined; resourceInputs["targetTags"] = state ? state.targetTags : undefined; } else { const args = argsOrState; if ((!args || args.network === undefined) && !opts.urn) { throw new Error("Missing required property 'network'"); } resourceInputs["allows"] = args ? args.allows : undefined; resourceInputs["denies"] = args ? args.denies : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["destinationRanges"] = args ? args.destinationRanges : undefined; resourceInputs["direction"] = args ? args.direction : undefined; resourceInputs["disabled"] = args ? args.disabled : undefined; resourceInputs["enableLogging"] = args ? args.enableLogging : undefined; resourceInputs["logConfig"] = args ? args.logConfig : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["network"] = args ? args.network : undefined; resourceInputs["priority"] = args ? args.priority : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["sourceRanges"] = args ? args.sourceRanges : undefined; resourceInputs["sourceServiceAccounts"] = args ? args.sourceServiceAccounts : undefined; resourceInputs["sourceTags"] = args ? args.sourceTags : undefined; resourceInputs["targetServiceAccounts"] = args ? args.targetServiceAccounts : undefined; resourceInputs["targetTags"] = args ? args.targetTags : undefined; resourceInputs["creationTimestamp"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Firewall.__pulumiType, name, resourceInputs, opts); } } exports.Firewall = Firewall; /** @internal */ Firewall.__pulumiType = 'gcp:compute/firewall:Firewall'; //# sourceMappingURL=firewall.js.map