InstanceFromTemplate class
Manages a VM instance resource within GCE. For more information see the official documentation and API.
This resource is specifically to create a compute instance from a given
sourceInstanceTemplate. To create an instance without a template, use the
gcp.compute.Instance resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const tpl = new gcp.compute.InstanceTemplate("tpl", {
name: "template",
machineType: "e2-medium",
disks: [{
sourceImage: "debian-cloud/debian-11",
autoDelete: true,
diskSizeGb: 100,
boot: true,
}],
networkInterfaces: [{
network: "default",
}],
metadata: {
foo: "bar",
},
canIpForward: true,
});
const tplInstanceFromTemplate = new gcp.compute.InstanceFromTemplate("tpl", {
name: "instance-from-template",
zone: "us-central1-a",
sourceInstanceTemplate: tpl.selfLinkUnique,
canIpForward: false,
labels: {
my_key: "my_value",
},
});
import pulumi
import pulumi_gcp as gcp
tpl = gcp.compute.InstanceTemplate("tpl",
name="template",
machine_type="e2-medium",
disks=[{
"source_image": "debian-cloud/debian-11",
"auto_delete": True,
"disk_size_gb": 100,
"boot": True,
}],
network_interfaces=[{
"network": "default",
}],
metadata={
"foo": "bar",
},
can_ip_forward=True)
tpl_instance_from_template = gcp.compute.InstanceFromTemplate("tpl",
name="instance-from-template",
zone="us-central1-a",
source_instance_template=tpl.self_link_unique,
can_ip_forward=False,
labels={
"my_key": "my_value",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var tpl = new Gcp.Compute.InstanceTemplate("tpl", new()
{
Name = "template",
MachineType = "e2-medium",
Disks = new[]
{
new Gcp.Compute.Inputs.InstanceTemplateDiskArgs
{
SourceImage = "debian-cloud/debian-11",
AutoDelete = true,
DiskSizeGb = 100,
Boot = true,
},
},
NetworkInterfaces = new[]
{
new Gcp.Compute.Inputs.InstanceTemplateNetworkInterfaceArgs
{
Network = "default",
},
},
Metadata =
{
{ "foo", "bar" },
},
CanIpForward = true,
});
var tplInstanceFromTemplate = new Gcp.Compute.InstanceFromTemplate("tpl", new()
{
Name = "instance-from-template",
Zone = "us-central1-a",
SourceInstanceTemplate = tpl.SelfLinkUnique,
CanIpForward = false,
Labels =
{
{ "my_key", "my_value" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
tpl, err := compute.NewInstanceTemplate(ctx, "tpl", &compute.InstanceTemplateArgs{
Name: pulumi.String("template"),
MachineType: pulumi.String("e2-medium"),
Disks: compute.InstanceTemplateDiskArray{
&compute.InstanceTemplateDiskArgs{
SourceImage: pulumi.String("debian-cloud/debian-11"),
AutoDelete: pulumi.Bool(true),
DiskSizeGb: pulumi.Int(100),
Boot: pulumi.Bool(true),
},
},
NetworkInterfaces: compute.InstanceTemplateNetworkInterfaceArray{
&compute.InstanceTemplateNetworkInterfaceArgs{
Network: pulumi.String("default"),
},
},
Metadata: pulumi.StringMap{
"foo": pulumi.String("bar"),
},
CanIpForward: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = compute.NewInstanceFromTemplate(ctx, "tpl", &compute.InstanceFromTemplateArgs{
Name: pulumi.String("instance-from-template"),
Zone: pulumi.String("us-central1-a"),
SourceInstanceTemplate: tpl.SelfLinkUnique,
CanIpForward: pulumi.Bool(false),
Labels: pulumi.StringMap{
"my_key": pulumi.String("my_value"),
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_instancetemplate" "tpl" {
name = "template"
machine_type = "e2-medium"
disks {
source_image = "debian-cloud/debian-11"
auto_delete = true
disk_size_gb = 100
boot = true
}
network_interfaces {
network = "default"
}
metadata = {
"foo" = "bar"
}
can_ip_forward = true
}
resource "gcp_compute_instancefromtemplate" "tpl" {
name = "instance-from-template"
zone = "us-central1-a"
source_instance_template = gcp_compute_instancetemplate.tpl.self_link_unique
can_ip_forward = false
labels = {
"my_key" = "my_value"
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.InstanceTemplate;
import com.pulumi.gcp.compute.InstanceTemplateArgs;
import com.pulumi.gcp.compute.inputs.InstanceTemplateDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceTemplateNetworkInterfaceArgs;
import com.pulumi.gcp.compute.InstanceFromTemplate;
import com.pulumi.gcp.compute.InstanceFromTemplateArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var tpl = new InstanceTemplate("tpl", InstanceTemplateArgs.builder()
.name("template")
.machineType("e2-medium")
.disks(InstanceTemplateDiskArgs.builder()
.sourceImage("debian-cloud/debian-11")
.autoDelete(true)
.diskSizeGb(100)
.boot(true)
.build())
.networkInterfaces(InstanceTemplateNetworkInterfaceArgs.builder()
.network("default")
.build())
.metadata(Map.of("foo", "bar"))
.canIpForward(true)
.build());
var tplInstanceFromTemplate = new InstanceFromTemplate("tplInstanceFromTemplate", InstanceFromTemplateArgs.builder()
.name("instance-from-template")
.zone("us-central1-a")
.sourceInstanceTemplate(tpl.selfLinkUnique())
.canIpForward(false)
.labels(Map.of("my_key", "my_value"))
.build());
}
}
resources:
tpl:
type: gcp:compute:InstanceTemplate
properties:
name: template
machineType: e2-medium
disks:
- sourceImage: debian-cloud/debian-11
autoDelete: true
diskSizeGb: 100
boot: true
networkInterfaces:
- network: default
metadata:
foo: bar
canIpForward: true
tplInstanceFromTemplate:
type: gcp:compute:InstanceFromTemplate
name: tpl
properties:
name: instance-from-template
zone: us-central1-a
sourceInstanceTemplate: ${tpl.selfLinkUnique}
canIpForward: false
labels:
my_key: my_value
Import
This resource does not support import.
Constructors
- InstanceFromTemplate(String name, {InstanceFromTemplateArgs? args, CustomResourceOptions? options})
-
Creates a new InstanceFromTemplate.
nameThe Pulumi resource name.argsArguments used to configure this InstanceFromTemplate. The set of arguments for InstanceFromTemplate.optionsResource options controlling this resource's behavior. - InstanceFromTemplate.reference(String urn)
- Creates a typed reference to an existing InstanceFromTemplate resource.
Properties
-
advancedMachineFeatures
↔ Output<
InstanceFromTemplateAdvancedMachineFeatures> -
Controls for advanced machine-related behavior features.
latefinal
-
allowStoppingForUpdate
↔ Output<
bool> -
If true, allows Terraform 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.
latefinal
-
attachedDisks
↔ Output<
List< InstanceFromTemplateAttachedDisk> > -
List of disks attached to the instance
latefinal
-
bootDisk
↔ Output<
InstanceFromTemplateBootDisk> -
The boot disk for the instance.
latefinal
-
canIpForward
↔ Output<
bool> -
Whether sending and receiving of packets with non-matching source or destination IPs is allowed.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
confidentialInstanceConfig
↔ Output<
InstanceFromTemplateConfidentialInstanceConfig> -
The Confidential VM config being used by the instance. onHostMaintenance has to be set to TERMINATE or this will fail to create.
latefinal
-
cpuPlatform
↔ Output<
String> -
The CPU platform used by this instance.
latefinal
-
creationTimestamp
↔ Output<
String> -
Creation timestamp in RFC3339 text format.
latefinal
-
currentStatus
↔ Output<
String> -
Current status of the instance.
This could be one of the following values: PROVISIONING, STAGING, RUNNING, STOPPING, SUSPENDING, SUSPENDED, REPAIRING, and TERMINATED.
For more information about the status of the instance, see Instance life cycle.
latefinal
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE".
When a 'terraform destroy' or 'terraform apply' would delete the instance,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
deletionProtection
↔ Output<
bool> -
Whether deletion protection is enabled on this instance.
latefinal
-
description
↔ Output<
String> -
A brief description of the resource.
latefinal
-
desiredStatus
↔ Output<
String> -
Desired status of the instance. Either "RUNNING", "SUSPENDED" or "TERMINATED".
latefinal
-
effectiveLabels
↔ Output<
Map< String, String> > -
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
latefinal
-
enableDisplay
↔ Output<
bool> -
Whether the instance has virtual displays enabled.
latefinal
-
eraseWindowsVssSignature
↔ Output<
bool> -
Specifies whether the disks restored from source snapshots or source machine image should erase Windows specific VSS signature.
latefinal
-
guestAccelerators
↔ Output<
List< InstanceFromTemplateGuestAccelerator> > -
List of the type and count of accelerator cards attached to the instance.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
hostname
↔ Output<
String> -
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.
latefinal
-
id
↔ Output<
String> -
getter/setter pairinherited
-
instanceEncryptionKey
↔ Output<
InstanceFromTemplateInstanceEncryptionKey> -
Encryption key used to provide data encryption on the given instance.
latefinal
-
instanceId
↔ Output<
String> -
The server-assigned unique identifier of this instance.
latefinal
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
keyRevocationActionType
↔ Output<
String> -
Action to be taken when a customer's encryption key is revoked. Supports "STOP" and "NONE", with "NONE" being the default.
latefinal
-
labelFingerprint
↔ Output<
String> -
The unique fingerprint of the labels.
latefinal
-
labels
↔ Output<
Map< String, String> > -
A set of key/value label pairs assigned to the instance.
latefinal
-
machineType
↔ Output<
String> -
The machine type to create.
latefinal
-
metadata
↔ Output<
Map< String, String> > -
Metadata key/value pairs made available within the instance.
latefinal
-
metadataFingerprint
↔ Output<
String> -
The unique fingerprint of the metadata.
latefinal
-
metadataStartupScript
↔ Output<
String> -
Metadata startup scripts made available within the instance.
latefinal
-
minCpuPlatform
↔ Output<
String> -
The minimum CPU platform specified for the VM instance.
latefinal
-
name
↔ Output<
String> -
A unique name for the resource, required by GCE.
Changing this forces a new resource to be created.
latefinal
-
networkInterfaces
↔ Output<
List< InstanceFromTemplateNetworkInterface> > -
The networks attached to the instance.
latefinal
-
networkPerformanceConfig
↔ Output<
InstanceFromTemplateNetworkPerformanceConfig> -
Configures network performance settings for the instance. If not specified, the instance will be created with its default network performance configuration.
latefinal
-
params
↔ Output<
InstanceFromTemplateParams> -
Stores additional params passed with the request, but not persisted as part of resource payload.
latefinal
-
partnerMetadata
↔ Output<
Map< String, String> > -
Partner Metadata Map made available within the instance.
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs. If selfLink is provided, this value is ignored. If neither selfLink nor project are provided, the provider project is used.
latefinal
-
pulumiLabels
↔ Output<
Map< String, String> > -
The combination of labels configured directly on the resource and default labels configured on the provider.
latefinal
-
reservationAffinity
↔ Output<
InstanceFromTemplateReservationAffinity> -
Specifies the reservations that this instance can consume from.
latefinal
-
resourcePolicies
↔ Output<
String> -
A list of selfLinks of resource policies to attach to the instance. Currently a max of 1 resource policy is supported.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scheduling
↔ Output<
InstanceFromTemplateScheduling> -
The scheduling strategy being used by the instance.
latefinal
-
scratchDisks
↔ Output<
List< InstanceFromTemplateScratchDisk> > -
network_interface.alias_ip_rangenetwork_interface.alias_ipv6_rangeBetanetwork_interface.access_configlatefinal -
selfLink
↔ Output<
String> -
The URI of the created resource.
latefinal
-
serviceAccount
↔ Output<
InstanceFromTemplateServiceAccount> -
The service account to attach to the instance.
latefinal
-
shieldedInstanceConfig
↔ Output<
InstanceFromTemplateShieldedInstanceConfig> -
The shielded vm config being used by the instance.
latefinal
-
sourceInstanceTemplate
↔ Output<
String> -
Name or self link of an instance
template to create the instance based on. It is recommended to reference
instance templates through their unique id (
selfLinkUniqueattribute).latefinal -
The list of tags attached to the instance.
latefinal
-
The unique fingerprint of the tags.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
workloadIdentityConfig
↔ Output<
InstanceFromTemplateWorkloadIdentityConfig> -
Workload identity config.
latefinal
-
zone
↔ Output<
String> -
The zone that the machine should be created in. If not
set, the provider zone is used.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {InstanceFromTemplateState? state, CustomResourceOptions? options}) → InstanceFromTemplate -
Gets an existing InstanceFromTemplate resource's state with the given
nameandid.