Class Instance
Manages a VM instance resource within GCE. For more information see the official documentation and API.
Example Usage
using Pulumi;
using Gcp = Pulumi.Gcp;
class MyStack : Stack
{
public MyStack()
{
var @default = new Gcp.Compute.Instance("default", new Gcp.Compute.InstanceArgs
{
BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
{
InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
{
Image = "debian-cloud/debian-9",
},
},
MachineType = "n1-standard-1",
Metadata =
{
{ "foo", "bar" },
},
MetadataStartupScript = "echo hi > /test.txt",
NetworkInterfaces =
{
new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
{
AccessConfig =
{
,
},
Network = "default",
},
},
ScratchDisks =
{
new Gcp.Compute.Inputs.InstanceScratchDiskArgs
{
Interface = "SCSI",
},
},
ServiceAccount = new Gcp.Compute.Inputs.InstanceServiceAccountArgs
{
Scopes =
{
"userinfo-email",
"compute-ro",
"storage-ro",
},
},
Tags =
{
"foo",
"bar",
},
Zone = "us-central1-a",
});
}
}
Inherited Members
Namespace: Pulumi.Gcp.Compute
Assembly: Pulumi.Gcp.dll
Syntax
public class Instance : CustomResource
Constructors
View SourceInstance(String, InstanceArgs, CustomResourceOptions)
Create a Instance resource with the given unique name, arguments, and options.
Declaration
public Instance(string name, InstanceArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| InstanceArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceAllowStoppingForUpdate
If true, allows this prvider to stop the instance to update its properties. If you try to update a property that requires stopping the instance without setting this field, the update will fail.
Declaration
public Output<bool?> AllowStoppingForUpdate { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
AttachedDisks
Additional disks to attach to the instance. Can be repeated multiple times for multiple disks. Structure is documented below.
Declaration
public Output<ImmutableArray<InstanceAttachedDisk>> AttachedDisks { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<InstanceAttachedDisk>> |
BootDisk
The boot disk for the instance. Structure is documented below.
Declaration
public Output<InstanceBootDisk> BootDisk { get; }
Property Value
| Type | Description |
|---|---|
| Output<InstanceBootDisk> |
CanIpForward
Whether to allow sending and receiving of packets with non-matching source or destination IPs. This defaults to false.
Declaration
public Output<bool?> CanIpForward { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
CpuPlatform
The CPU platform used by this instance.
Declaration
public Output<string> CpuPlatform { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
CurrentStatus
Declaration
public Output<string> CurrentStatus { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
DeletionProtection
Enable deletion protection on this instance. Defaults to false.
Note: you must disable deletion protection before removing the resource (e.g., via pulumi destroy), or the instance cannot be deleted and the provider run will not complete successfully.
Declaration
public Output<bool?> DeletionProtection { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Description
A brief description of this resource.
Declaration
public Output<string> Description { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
DesiredStatus
Desired status of the instance. Either
"RUNNING" or "TERMINATED".
Declaration
public Output<string> DesiredStatus { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
EnableDisplay
Enable Virtual Displays on this instance.
Note: allow_stopping_for_update must be set to true or your instance must have a desired_status of TERMINATED in order to update this field.
Declaration
public Output<bool?> EnableDisplay { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
GuestAccelerators
List of the type and count of accelerator cards attached to the instance. Structure documented below.
Note: GPU accelerators can only be used with on_host_maintenance option set to TERMINATE.
Declaration
public Output<ImmutableArray<InstanceGuestAccelerator>> GuestAccelerators { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<InstanceGuestAccelerator>> |
Hostname
A custom hostname for the instance. Must be a fully qualified DNS name and RFC-1035-valid.
Valid format is a series of labels 1-63 characters long matching the regular expression a-z, concatenated with periods.
The entire hostname must not exceed 253 characters. Changing this forces a new resource to be created.
Declaration
public Output<string> Hostname { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
InstanceId
The server-assigned unique identifier of this instance.
Declaration
public Output<string> InstanceId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
LabelFingerprint
The unique fingerprint of the labels.
Declaration
public Output<string> LabelFingerprint { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Labels
A map of key/value label pairs to assign to the instance.
Declaration
public Output<ImmutableDictionary<string, string>> Labels { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.String>> |
MachineType
The machine type to create.
Declaration
public Output<string> MachineType { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Metadata
Metadata key/value pairs to make available from within the instance. Ssh keys attached in the Cloud Console will be removed. Add them to your config in order to keep them attached to your instance.
Declaration
public Output<ImmutableDictionary<string, string>> Metadata { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableDictionary<System.String, System.String>> |
MetadataFingerprint
The unique fingerprint of the metadata.
Declaration
public Output<string> MetadataFingerprint { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
MetadataStartupScript
An alternative to using the
startup-script metadata key, except this one forces the instance to be
recreated (thus re-running the script) if it is changed. This replaces the
startup-script metadata key on the created instance and thus the two
mechanisms are not allowed to be used simultaneously. Users are free to use
either mechanism - the only distinction is that this separate attribute
willl cause a recreate on modification. On import, metadata_startup_script
will be set, but metadata.startup-script will not - if you choose to use the
other mechanism, you will see a diff immediately after import, which will cause a
destroy/recreate operation. You may want to modify your state file manually
using pulumi stack commands, depending on your use case.
Declaration
public Output<string> MetadataStartupScript { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
MinCpuPlatform
Specifies a minimum CPU platform for the VM instance. Applicable values are the friendly names of CPU platforms, such as
Intel Haswell or Intel Skylake. See the complete list here.
Note: allow_stopping_for_update must be set to true or your instance must have a desired_status of TERMINATED in order to update this field.
Declaration
public Output<string> MinCpuPlatform { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Name
A unique name for the resource, required by GCE. Changing this forces a new resource to be created.
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
NetworkInterfaces
Networks to attach to the instance. This can be specified multiple times. Structure is documented below.
Declaration
public Output<ImmutableArray<InstanceNetworkInterface>> NetworkInterfaces { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<InstanceNetworkInterface>> |
Project
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Declaration
public Output<string> Project { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
ResourcePolicies
-- A list of short names or self_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported.
Declaration
public Output<string> ResourcePolicies { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Scheduling
The scheduling strategy to use. More details about this configuration option are detailed below.
Declaration
public Output<InstanceScheduling> Scheduling { get; }
Property Value
| Type | Description |
|---|---|
| Output<InstanceScheduling> |
ScratchDisks
Scratch disks to attach to the instance. This can be specified multiple times for multiple scratch disks. Structure is documented below.
Declaration
public Output<ImmutableArray<InstanceScratchDisk>> ScratchDisks { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<InstanceScratchDisk>> |
SelfLink
The URI of the created resource.
Declaration
public Output<string> SelfLink { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
ServiceAccount
Service account to attach to the instance.
Structure is documented below.
Note: allow_stopping_for_update must be set to true or your instance must have a desired_status of TERMINATED in order to update this field.
Declaration
public Output<InstanceServiceAccount> ServiceAccount { get; }
Property Value
| Type | Description |
|---|---|
| Output<InstanceServiceAccount> |
ShieldedInstanceConfig
Enable Shielded VM on this instance. Shielded VM provides verifiable integrity to prevent against malware and rootkits. Defaults to disabled. Structure is documented below.
Note: shielded_instance_config can only be used with boot images with shielded vm support. See the complete list here.
Declaration
public Output<InstanceShieldedInstanceConfig> ShieldedInstanceConfig { get; }
Property Value
| Type | Description |
|---|---|
| Output<InstanceShieldedInstanceConfig> |
Tags
A list of tags to attach to the instance.
Declaration
public Output<ImmutableArray<string>> Tags { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
TagsFingerprint
The unique fingerprint of the tags.
Declaration
public Output<string> TagsFingerprint { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Zone
The zone that the machine should be created in.
Declaration
public Output<string> Zone { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, InstanceState, CustomResourceOptions)
Get an existing Instance resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static Instance Get(string name, Input<string> id, InstanceState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| InstanceState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| Instance |