"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.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, { ...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?.instanceGroupManager;
            resourceInputs["minimalAction"] = state?.minimalAction;
            resourceInputs["mostDisruptiveAllowedAction"] = state?.mostDisruptiveAllowedAction;
            resourceInputs["name"] = state?.name;
            resourceInputs["preservedState"] = state?.preservedState;
            resourceInputs["project"] = state?.project;
            resourceInputs["removeInstanceOnDestroy"] = state?.removeInstanceOnDestroy;
            resourceInputs["removeInstanceStateOnDestroy"] = state?.removeInstanceStateOnDestroy;
            resourceInputs["zone"] = state?.zone;
        }
        else {
            const args = argsOrState;
            if (args?.instanceGroupManager === undefined && !opts.urn) {
                throw new Error("Missing required property 'instanceGroupManager'");
            }
            resourceInputs["instanceGroupManager"] = args?.instanceGroupManager;
            resourceInputs["minimalAction"] = args?.minimalAction;
            resourceInputs["mostDisruptiveAllowedAction"] = args?.mostDisruptiveAllowedAction;
            resourceInputs["name"] = args?.name;
            resourceInputs["preservedState"] = args?.preservedState;
            resourceInputs["project"] = args?.project;
            resourceInputs["removeInstanceOnDestroy"] = args?.removeInstanceOnDestroy;
            resourceInputs["removeInstanceStateOnDestroy"] = args?.removeInstanceStateOnDestroy;
            resourceInputs["zone"] = args?.zone;
        }
        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