UNPKG

@pulumi/gcp

Version:

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

261 lines • 13.2 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.Instance = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages a VM instance resource within GCE. For more information see * [the official documentation](https://cloud.google.com/compute/docs/instances) * and * [API](https://cloud.google.com/compute/docs/reference/latest/instances). * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.serviceaccount.Account("default", { * accountId: "my-custom-sa", * displayName: "Custom SA for VM Instance", * }); * const defaultInstance = new gcp.compute.Instance("default", { * networkInterfaces: [{ * accessConfigs: [{}], * network: "default", * }], * name: "my-instance", * machineType: "n2-standard-2", * zone: "us-central1-a", * tags: [ * "foo", * "bar", * ], * bootDisk: { * initializeParams: { * image: "debian-cloud/debian-11", * labels: { * my_label: "value", * }, * }, * }, * scratchDisks: [{ * "interface": "NVME", * }], * metadata: { * foo: "bar", * }, * metadataStartupScript: "echo hi > /test.txt", * serviceAccount: { * email: _default.email, * scopes: ["cloud-platform"], * }, * }); * ``` * * ### Confidential Computing * * Example with [Confidential Mode](https://cloud.google.com/confidential-computing/confidential-vm/docs/confidential-vm-overview) activated. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.serviceaccount.Account("default", { * accountId: "my-custom-sa", * displayName: "Custom SA for VM Instance", * }); * const confidentialInstance = new gcp.compute.Instance("confidential_instance", { * networkInterfaces: [{ * accessConfigs: [{}], * network: "default", * }], * name: "my-confidential-instance", * zone: "us-central1-a", * machineType: "n2d-standard-2", * minCpuPlatform: "AMD Milan", * confidentialInstanceConfig: { * enableConfidentialCompute: true, * confidentialInstanceType: "SEV", * }, * bootDisk: { * initializeParams: { * image: "ubuntu-os-cloud/ubuntu-2004-lts", * labels: { * my_label: "value", * }, * }, * }, * scratchDisks: [{ * "interface": "NVME", * }], * serviceAccount: { * email: _default.email, * scopes: ["cloud-platform"], * }, * }); * ``` * * ## Import * * Instances can be imported using any of these accepted formats: * * * `projects/{{project}}/zones/{{zone}}/instances/{{name}}` * * * `{{project}}/{{zone}}/{{name}}` * * * `{{name}}` * * When using the `pulumi import` command, instances can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/instance:Instance default projects/{{project}}/zones/{{zone}}/instances/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/instance:Instance default {{project}}/{{zone}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/instance:Instance default {{name}} * ``` */ class Instance extends pulumi.CustomResource { /** * Get an existing Instance 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 Instance(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Instance. 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'] === Instance.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["advancedMachineFeatures"] = state ? state.advancedMachineFeatures : undefined; resourceInputs["allowStoppingForUpdate"] = state ? state.allowStoppingForUpdate : undefined; resourceInputs["attachedDisks"] = state ? state.attachedDisks : undefined; resourceInputs["bootDisk"] = state ? state.bootDisk : undefined; resourceInputs["canIpForward"] = state ? state.canIpForward : undefined; resourceInputs["confidentialInstanceConfig"] = state ? state.confidentialInstanceConfig : undefined; resourceInputs["cpuPlatform"] = state ? state.cpuPlatform : undefined; resourceInputs["creationTimestamp"] = state ? state.creationTimestamp : undefined; resourceInputs["currentStatus"] = state ? state.currentStatus : undefined; resourceInputs["deletionProtection"] = state ? state.deletionProtection : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["desiredStatus"] = state ? state.desiredStatus : undefined; resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined; resourceInputs["enableDisplay"] = state ? state.enableDisplay : undefined; resourceInputs["guestAccelerators"] = state ? state.guestAccelerators : undefined; resourceInputs["hostname"] = state ? state.hostname : undefined; resourceInputs["instanceEncryptionKey"] = state ? state.instanceEncryptionKey : undefined; resourceInputs["instanceId"] = state ? state.instanceId : undefined; resourceInputs["keyRevocationActionType"] = state ? state.keyRevocationActionType : undefined; resourceInputs["labelFingerprint"] = state ? state.labelFingerprint : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["machineType"] = state ? state.machineType : undefined; resourceInputs["metadata"] = state ? state.metadata : undefined; resourceInputs["metadataFingerprint"] = state ? state.metadataFingerprint : undefined; resourceInputs["metadataStartupScript"] = state ? state.metadataStartupScript : undefined; resourceInputs["minCpuPlatform"] = state ? state.minCpuPlatform : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["networkInterfaces"] = state ? state.networkInterfaces : undefined; resourceInputs["networkPerformanceConfig"] = state ? state.networkPerformanceConfig : undefined; resourceInputs["params"] = state ? state.params : undefined; resourceInputs["partnerMetadata"] = state ? state.partnerMetadata : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined; resourceInputs["reservationAffinity"] = state ? state.reservationAffinity : undefined; resourceInputs["resourcePolicies"] = state ? state.resourcePolicies : undefined; resourceInputs["scheduling"] = state ? state.scheduling : undefined; resourceInputs["scratchDisks"] = state ? state.scratchDisks : undefined; resourceInputs["selfLink"] = state ? state.selfLink : undefined; resourceInputs["serviceAccount"] = state ? state.serviceAccount : undefined; resourceInputs["shieldedInstanceConfig"] = state ? state.shieldedInstanceConfig : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsFingerprint"] = state ? state.tagsFingerprint : undefined; resourceInputs["zone"] = state ? state.zone : undefined; } else { const args = argsOrState; if ((!args || args.bootDisk === undefined) && !opts.urn) { throw new Error("Missing required property 'bootDisk'"); } if ((!args || args.machineType === undefined) && !opts.urn) { throw new Error("Missing required property 'machineType'"); } if ((!args || args.networkInterfaces === undefined) && !opts.urn) { throw new Error("Missing required property 'networkInterfaces'"); } resourceInputs["advancedMachineFeatures"] = args ? args.advancedMachineFeatures : undefined; resourceInputs["allowStoppingForUpdate"] = args ? args.allowStoppingForUpdate : undefined; resourceInputs["attachedDisks"] = args ? args.attachedDisks : undefined; resourceInputs["bootDisk"] = args ? args.bootDisk : undefined; resourceInputs["canIpForward"] = args ? args.canIpForward : undefined; resourceInputs["confidentialInstanceConfig"] = args ? args.confidentialInstanceConfig : undefined; resourceInputs["deletionProtection"] = args ? args.deletionProtection : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["desiredStatus"] = args ? args.desiredStatus : undefined; resourceInputs["enableDisplay"] = args ? args.enableDisplay : undefined; resourceInputs["guestAccelerators"] = args ? args.guestAccelerators : undefined; resourceInputs["hostname"] = args ? args.hostname : undefined; resourceInputs["instanceEncryptionKey"] = args ? args.instanceEncryptionKey : undefined; resourceInputs["keyRevocationActionType"] = args ? args.keyRevocationActionType : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["machineType"] = args ? args.machineType : undefined; resourceInputs["metadata"] = args ? args.metadata : undefined; resourceInputs["metadataStartupScript"] = args ? args.metadataStartupScript : undefined; resourceInputs["minCpuPlatform"] = args ? args.minCpuPlatform : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["networkInterfaces"] = args ? args.networkInterfaces : undefined; resourceInputs["networkPerformanceConfig"] = args ? args.networkPerformanceConfig : undefined; resourceInputs["params"] = args ? args.params : undefined; resourceInputs["partnerMetadata"] = args ? args.partnerMetadata : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["reservationAffinity"] = args ? args.reservationAffinity : undefined; resourceInputs["resourcePolicies"] = args ? args.resourcePolicies : undefined; resourceInputs["scheduling"] = args ? args.scheduling : undefined; resourceInputs["scratchDisks"] = args ? args.scratchDisks : undefined; resourceInputs["serviceAccount"] = args ? args.serviceAccount : undefined; resourceInputs["shieldedInstanceConfig"] = args ? args.shieldedInstanceConfig : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["zone"] = args ? args.zone : undefined; resourceInputs["cpuPlatform"] = undefined /*out*/; resourceInputs["creationTimestamp"] = undefined /*out*/; resourceInputs["currentStatus"] = undefined /*out*/; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["instanceId"] = undefined /*out*/; resourceInputs["labelFingerprint"] = undefined /*out*/; resourceInputs["metadataFingerprint"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; resourceInputs["tagsFingerprint"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Instance.__pulumiType, name, resourceInputs, opts); } } exports.Instance = Instance; /** @internal */ Instance.__pulumiType = 'gcp:compute/instance:Instance'; //# sourceMappingURL=instance.js.map