UNPKG

@pulumi/gcp

Version:

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

245 lines • 8.89 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.TargetInstance = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Represents a TargetInstance resource which defines an endpoint instance * that terminates traffic of certain protocols. In particular, they are used * in Protocol Forwarding, where forwarding rules can send packets to a * non-NAT'ed target instance. Each target instance contains a single * virtual machine instance that receives and handles traffic from the * corresponding forwarding rules. * * To get more information about TargetInstance, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/v1/targetInstances) * * How-to Guides * * [Using Protocol Forwarding](https://cloud.google.com/compute/docs/protocol-forwarding) * * ## Example Usage * * ### Target Instance Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const vmimage = gcp.compute.getImage({ * family: "debian-11", * project: "debian-cloud", * }); * const target_vm = new gcp.compute.Instance("target-vm", { * name: "target-vm", * machineType: "e2-medium", * zone: "us-central1-a", * bootDisk: { * initializeParams: { * image: vmimage.then(vmimage => vmimage.selfLink), * }, * }, * networkInterfaces: [{ * network: "default", * }], * }); * const _default = new gcp.compute.TargetInstance("default", { * name: "target", * instance: target_vm.id, * }); * ``` * ### Target Instance Custom Network * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const target_vm = gcp.compute.getNetwork({ * name: "default", * }); * const vmimage = gcp.compute.getImage({ * family: "debian-12", * project: "debian-cloud", * }); * const target_vmInstance = new gcp.compute.Instance("target-vm", { * name: "custom-network-target-vm", * machineType: "e2-medium", * zone: "us-central1-a", * bootDisk: { * initializeParams: { * image: vmimage.then(vmimage => vmimage.selfLink), * }, * }, * networkInterfaces: [{ * network: "default", * }], * }); * const customNetwork = new gcp.compute.TargetInstance("custom_network", { * name: "custom-network", * instance: target_vmInstance.id, * network: target_vm.then(target_vm => target_vm.selfLink), * }); * ``` * ### Target Instance With Security Policy * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.Network("default", { * name: "custom-default-network", * autoCreateSubnetworks: false, * routingMode: "REGIONAL", * }); * const defaultSubnetwork = new gcp.compute.Subnetwork("default", { * name: "custom-default-subnet", * ipCidrRange: "10.1.2.0/24", * network: _default.id, * privateIpv6GoogleAccess: "DISABLE_GOOGLE_ACCESS", * purpose: "PRIVATE", * region: "southamerica-west1", * stackType: "IPV4_ONLY", * }); * const vmimage = gcp.compute.getImage({ * family: "debian-11", * project: "debian-cloud", * }); * const target_vm = new gcp.compute.Instance("target-vm", { * networkInterfaces: [{ * accessConfigs: [{}], * network: _default.selfLink, * subnetwork: defaultSubnetwork.selfLink, * }], * name: "target-vm", * machineType: "e2-medium", * zone: "southamerica-west1-a", * bootDisk: { * initializeParams: { * image: vmimage.then(vmimage => vmimage.selfLink), * }, * }, * }); * const policyddosprotection = new gcp.compute.RegionSecurityPolicy("policyddosprotection", { * region: "southamerica-west1", * name: "tf-test-policyddos_21197", * description: "ddos protection security policy to set target instance", * type: "CLOUD_ARMOR_NETWORK", * ddosProtectionConfig: { * ddosProtection: "ADVANCED_PREVIEW", * }, * }); * const edgeSecService = new gcp.compute.NetworkEdgeSecurityService("edge_sec_service", { * region: "southamerica-west1", * name: "tf-test-edgesec_52865", * securityPolicy: policyddosprotection.selfLink, * }); * const regionsecuritypolicy = new gcp.compute.RegionSecurityPolicy("regionsecuritypolicy", { * name: "region-secpolicy", * region: "southamerica-west1", * description: "basic security policy for target instance", * type: "CLOUD_ARMOR_NETWORK", * }, { * dependsOn: [edgeSecService], * }); * const defaultTargetInstance = new gcp.compute.TargetInstance("default", { * name: "target-instance", * zone: "southamerica-west1-a", * instance: target_vm.id, * securityPolicy: regionsecuritypolicy.selfLink, * }); * ``` * * ## Import * * TargetInstance can be imported using any of these accepted formats: * * * `projects/{{project}}/zones/{{zone}}/targetInstances/{{name}}` * * * `{{project}}/{{zone}}/{{name}}` * * * `{{zone}}/{{name}}` * * * `{{name}}` * * When using the `pulumi import` command, TargetInstance can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/targetInstance:TargetInstance default projects/{{project}}/zones/{{zone}}/targetInstances/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/targetInstance:TargetInstance default {{project}}/{{zone}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/targetInstance:TargetInstance default {{zone}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/targetInstance:TargetInstance default {{name}} * ``` */ class TargetInstance extends pulumi.CustomResource { /** * Get an existing TargetInstance 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 TargetInstance(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of TargetInstance. 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'] === TargetInstance.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["creationTimestamp"] = state?.creationTimestamp; resourceInputs["description"] = state?.description; resourceInputs["instance"] = state?.instance; resourceInputs["name"] = state?.name; resourceInputs["natPolicy"] = state?.natPolicy; resourceInputs["network"] = state?.network; resourceInputs["project"] = state?.project; resourceInputs["securityPolicy"] = state?.securityPolicy; resourceInputs["selfLink"] = state?.selfLink; resourceInputs["zone"] = state?.zone; } else { const args = argsOrState; if (args?.instance === undefined && !opts.urn) { throw new Error("Missing required property 'instance'"); } resourceInputs["description"] = args?.description; resourceInputs["instance"] = args?.instance; resourceInputs["name"] = args?.name; resourceInputs["natPolicy"] = args?.natPolicy; resourceInputs["network"] = args?.network; resourceInputs["project"] = args?.project; resourceInputs["securityPolicy"] = args?.securityPolicy; resourceInputs["zone"] = args?.zone; resourceInputs["creationTimestamp"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(TargetInstance.__pulumiType, name, resourceInputs, opts); } } exports.TargetInstance = TargetInstance; /** @internal */ TargetInstance.__pulumiType = 'gcp:compute/targetInstance:TargetInstance'; //# sourceMappingURL=targetInstance.js.map