UNPKG

@pulumi/gcp

Version:

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

139 lines 6.24 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.InstanceGroupMembership = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Represents the Instance membership to the Instance Group. * * > **NOTE** You can use this resource instead of the `instances` field in the * `gcp.compute.InstanceGroup`, however it's not recommended to use it alongside this field. * It might cause inconsistencies, as they can end up competing over control. * * > **NOTE** This resource has been added to avoid a situation, where after * Instance is recreated, it's removed from Instance Group and it's needed to * perform `apply` twice. To avoid situations like this, please use this resource * with the lifecycle `replaceTriggeredBy` method, with the passed Instance's ID. * * To get more information about InstanceGroupMembership, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroups) * * How-to Guides * * [Add instances](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroups/addInstances) * * [List instances](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroups/listInstances) * * [Remove instances](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroups/removeInstances) * * ## Example Usage * * ### Instance Group Membership * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const default_network = new gcp.compute.Network("default-network", {name: "network"}); * const default_instance = new gcp.compute.Instance("default-instance", { * name: "instance", * machineType: "e2-medium", * bootDisk: { * initializeParams: { * image: "debian-cloud/debian-11", * }, * }, * networkInterfaces: [{ * network: default_network.name, * }], * }); * const default_instance_group = new gcp.compute.InstanceGroup("default-instance-group", {name: "instance-group"}); * const default_ig_membership = new gcp.compute.InstanceGroupMembership("default-ig-membership", { * instance: default_instance.selfLink, * instanceGroup: default_instance_group.name, * }); * ``` * * ## Import * * InstanceGroupMembership can be imported using any of these accepted formats: * * * `projects/{{project}}/zones/{{zone}}/instanceGroups/{{instance_group}}/{{instance}}` * * * `{{project}}/{{zone}}/{{instance_group}}/{{instance}}` * * * `{{zone}}/{{instance_group}}/{{instance}}` * * * `{{instance_group}}/{{instance}}` * * When using the `pulumi import` command, InstanceGroupMembership can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default projects/{{project}}/zones/{{zone}}/instanceGroups/{{instance_group}}/{{instance}} * ``` * * ```sh * $ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default {{project}}/{{zone}}/{{instance_group}}/{{instance}} * ``` * * ```sh * $ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default {{zone}}/{{instance_group}}/{{instance}} * ``` * * ```sh * $ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default {{instance_group}}/{{instance}} * ``` */ class InstanceGroupMembership extends pulumi.CustomResource { /** * Get an existing InstanceGroupMembership 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 InstanceGroupMembership(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of InstanceGroupMembership. 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'] === InstanceGroupMembership.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["instance"] = state ? state.instance : undefined; resourceInputs["instanceGroup"] = state ? state.instanceGroup : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["zone"] = state ? state.zone : undefined; } else { const args = argsOrState; if ((!args || args.instance === undefined) && !opts.urn) { throw new Error("Missing required property 'instance'"); } if ((!args || args.instanceGroup === undefined) && !opts.urn) { throw new Error("Missing required property 'instanceGroup'"); } resourceInputs["instance"] = args ? args.instance : undefined; resourceInputs["instanceGroup"] = args ? args.instanceGroup : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["zone"] = args ? args.zone : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(InstanceGroupMembership.__pulumiType, name, resourceInputs, opts); } } exports.InstanceGroupMembership = InstanceGroupMembership; /** @internal */ InstanceGroupMembership.__pulumiType = 'gcp:compute/instanceGroupMembership:InstanceGroupMembership'; //# sourceMappingURL=instanceGroupMembership.js.map