@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
180 lines • 7.41 kB
JavaScript
;
// *** 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.PerInstanceConfig = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* A config defined for a single managed instance that belongs to an instance group manager. It preserves the instance name
* across instance group manager operations and can define stateful disks or metadata that are unique to the instance.
*
* To get more information about PerInstanceConfig, see:
*
* * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroupManagers)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/compute/docs/instance-groups/stateful-migs#per-instance_configs)
*
* ## Example Usage
*
* ### Stateful Igm
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const myImage = gcp.compute.getImage({
* family: "debian-11",
* project: "debian-cloud",
* });
* const igm_basic = new gcp.compute.InstanceTemplate("igm-basic", {
* name: "my-template",
* machineType: "e2-medium",
* canIpForward: false,
* tags: [
* "foo",
* "bar",
* ],
* disks: [{
* sourceImage: myImage.then(myImage => myImage.selfLink),
* autoDelete: true,
* boot: true,
* }],
* networkInterfaces: [{
* network: "default",
* }],
* serviceAccount: {
* scopes: [
* "userinfo-email",
* "compute-ro",
* "storage-ro",
* ],
* },
* });
* const igm_no_tp = new gcp.compute.InstanceGroupManager("igm-no-tp", {
* description: "Test instance group manager",
* name: "my-igm",
* versions: [{
* name: "prod",
* instanceTemplate: igm_basic.selfLink,
* }],
* baseInstanceName: "igm-no-tp",
* zone: "us-central1-c",
* targetSize: 2,
* });
* const _default = new gcp.compute.Disk("default", {
* name: "my-disk-name",
* type: "pd-ssd",
* zone: igm.zone,
* image: "debian-11-bullseye-v20220719",
* physicalBlockSizeBytes: 4096,
* });
* const withDisk = new gcp.compute.PerInstanceConfig("with_disk", {
* zone: igm.zone,
* instanceGroupManager: igm.name,
* name: "instance-1",
* preservedState: {
* metadata: {
* foo: "bar",
* instance_template: igm_basic.selfLink,
* },
* disks: [{
* deviceName: "my-stateful-disk",
* source: _default.id,
* mode: "READ_ONLY",
* }],
* },
* });
* ```
*
* ## Import
*
* PerInstanceConfig can be imported using any of these accepted formats:
*
* * `projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{instance_group_manager}}/{{name}}`
*
* * `{{project}}/{{zone}}/{{instance_group_manager}}/{{name}}`
*
* * `{{zone}}/{{instance_group_manager}}/{{name}}`
*
* * `{{instance_group_manager}}/{{name}}`
*
* When using the `pulumi import` command, PerInstanceConfig can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/perInstanceConfig:PerInstanceConfig default projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{instance_group_manager}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/perInstanceConfig:PerInstanceConfig default {{project}}/{{zone}}/{{instance_group_manager}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/perInstanceConfig:PerInstanceConfig default {{zone}}/{{instance_group_manager}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/perInstanceConfig:PerInstanceConfig default {{instance_group_manager}}/{{name}}
* ```
*/
class PerInstanceConfig extends pulumi.CustomResource {
/**
* Get an existing PerInstanceConfig 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 PerInstanceConfig(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of PerInstanceConfig. 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'] === PerInstanceConfig.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["instanceGroupManager"] = state ? state.instanceGroupManager : undefined;
resourceInputs["minimalAction"] = state ? state.minimalAction : undefined;
resourceInputs["mostDisruptiveAllowedAction"] = state ? state.mostDisruptiveAllowedAction : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["preservedState"] = state ? state.preservedState : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["removeInstanceOnDestroy"] = state ? state.removeInstanceOnDestroy : undefined;
resourceInputs["removeInstanceStateOnDestroy"] = state ? state.removeInstanceStateOnDestroy : undefined;
resourceInputs["zone"] = state ? state.zone : undefined;
}
else {
const args = argsOrState;
if ((!args || args.instanceGroupManager === undefined) && !opts.urn) {
throw new Error("Missing required property 'instanceGroupManager'");
}
resourceInputs["instanceGroupManager"] = args ? args.instanceGroupManager : undefined;
resourceInputs["minimalAction"] = args ? args.minimalAction : undefined;
resourceInputs["mostDisruptiveAllowedAction"] = args ? args.mostDisruptiveAllowedAction : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["preservedState"] = args ? args.preservedState : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["removeInstanceOnDestroy"] = args ? args.removeInstanceOnDestroy : undefined;
resourceInputs["removeInstanceStateOnDestroy"] = args ? args.removeInstanceStateOnDestroy : undefined;
resourceInputs["zone"] = args ? args.zone : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(PerInstanceConfig.__pulumiType, name, resourceInputs, opts);
}
}
exports.PerInstanceConfig = PerInstanceConfig;
/** @internal */
PerInstanceConfig.__pulumiType = 'gcp:compute/perInstanceConfig:PerInstanceConfig';
//# sourceMappingURL=perInstanceConfig.js.map