googleComputeInstanceTemplate
Get information about a VM instance template resource within GCE. For more information see the official documentation and API.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.dataGoogleComputeInstanceTemplate.DataGoogleComputeInstanceTemplate(
this,
"generic",
{
name: "generic-tpl-20200107",
}
);
new google.dataGoogleComputeInstanceTemplate.DataGoogleComputeInstanceTemplate(
this,
"generic-regex",
{
filter: "name != generic-tpl-20200107",
most_recent: true,
}
);
Argument Reference
The following arguments are supported:
-
name
- (Optional) The name of the instance template. One ofname
orfilter
must be provided. -
filter
- (Optional) A filter to retrieve the instance templates. See gcloud topic filters for reference. If multiple instance templates match, either adjust the filter or specifymostRecent
. One ofname
orfilter
must be provided. -
mostRecent
- (Optional) Iffilter
is provided, ensures the most recent template is returned when multiple instance templates match. One ofname
orfilter
must be provided.
project
- (Optional) The ID of the project in which the resource belongs. Ifproject
is not provided, the provider project is used.
Attributes Reference
-
disk
- Disks to attach to instances created from this template. This can be specified multiple times for multiple disks. Structure is documented below. -
machineType
- The machine type to create.To create a machine with a [custom type][custom-vm-types] (such as extended memory), format the value like
customVcpusMemInMb
likecustom620480
for 6 vCPU and 20GB of RAM. -
name
- The name of the instance template. If you leave this blank, Terraform will auto-generate a unique name. -
namePrefix
- Creates a unique name beginning with the specified prefix. Conflicts withname
. -
canIpForward
- Whether to allow sending and receiving of packets with non-matching source or destination IPs. This defaults to false. -
description
- A brief description of this resource. -
instanceDescription
- A brief description to use for instances created from this template. -
labels
- A set of key/value label pairs to assign to instances created from this template, -
metadata
- Metadata key/value pairs to make available from within instances created from this template. -
metadataStartupScript
- An alternative to using the startup-script metadata key, mostly to match the compute_instance resource. This replaces the startup-script metadata key on the created instance and thus the two mechanisms are not allowed to be used simultaneously. -
networkInterface
- Networks to attach to instances created from this template. This can be specified multiple times for multiple networks. Structure is documented below. -
networkPerformanceConfig
- The network performance configuration setting for the instance, if set. Structure is documented below. -
project
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -
region
- An instance template is a global resource that is not bound to a zone or a region. However, you can still specify some regional resources in an instance template, which restricts the template to the region where that resource resides. For example, a customsubnetwork
resource is tied to a specific region. Defaults to the region of the Provider if no value is given. -
scheduling
- The scheduling strategy to use. More details about this configuration option are detailed below. -
serviceAccount
- Service account to attach to the instance. Structure is documented below. -
tags
- Tags to attach to the instance. -
guestAccelerator
- List of the type and count of accelerator cards attached to the instance. Structure documented below. -
minCpuPlatform
- Specifies a minimum CPU platform. Applicable values are the friendly names of CPU platforms, such asintelHaswell
orintelSkylake
. See the complete list here. -
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:shieldedInstanceConfig
can only be used with boot images with shielded vm support. See the complete list here. -
enableDisplay
- Enable Virtual Displays on this instance. Note:allowStoppingForUpdate
must be set to true in order to update this field. -
confidentialInstanceConfig
- Enable Confidential Mode on this VM. Structure is documented below
-
autoDelete
- Whether or not the disk should be auto-deleted. This defaults to true. -
boot
- Indicates that this is a boot disk. -
deviceName
- A unique device name that is reflected into the /dev/ tree of a Linux operating system running within the instance. If not specified, the server chooses a default device name to apply to this disk. -
diskName
- Name of the disk. When not provided, this defaults to the name of the instance. -
sourceImage
- The image from which to initialize this disk. This can be one of: the image'sselfLink
,projects/{project}/global/images/{image}
,projects/{project}/global/images/family/{family}
,global/images/{image}
,global/images/family/{family}
,family/{family}
,{project}/{family}
,{project}/{image}
,{family}
, or{image}
. \~> Note: Eithersource
orsourceImage
is required in a disk block unless the disk type islocalSsd
. Check the API docs for details. -
interface
- Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. Persistent disks must always use SCSI and the request will fail if you attempt to attach a persistent disk in any other format than SCSI. Local SSDs can use either NVME or SCSI. -
mode
- The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If you are attaching or creating a boot disk, this must read-write mode. -
source
- The name (not self_link) of the disk (such as those managed bygoogleComputeDisk
) to attach. \~> Note: Eithersource
orsourceImage
is required in a disk block unless the disk type islocalSsd
. Check the API docs for details. -
diskType
- The GCE disk type. Such as"pdSsd"
,"localSsd"
,"pdBalanced"
or"pdStandard"
. -
diskSizeGb
- The size of the image in gigabytes. If not specified, it will inherit the size of its base image. For SCRATCH disks, the size must be exactly 375GB. -
labels
- (Optional) A set of ket/value label pairs to assign to disk created from this template -
type
- The type of GCE disk, can be either"scratch"
or"persistent"
. -
diskEncryptionKey
- Encrypts or decrypts a disk using a customer-supplied encryption key.If you are creating a new disk, this field encrypts the new disk using an encryption key that you provide. If you are attaching an existing disk that is already encrypted, this field decrypts the disk using the customer-supplied encryption key.
If you encrypt a disk using a customer-supplied key, you must provide the same key again when you attempt to use this resource at a later time. For example, you must provide the key when you create a snapshot or an image from the disk or when you attach the disk to a virtual machine instance.
If you do not provide an encryption key, then the disk will be encrypted using an automatically generated key and you do not need to provide a key to use the disk later.
Instance templates do not store customer-supplied encryption keys, so you cannot use your own keys to encrypt disks in a managed instance group.
-
resourcePolicies
(Optional) -- A list of short names of resource policies to attach to this disk for automatic snapshot creations. Currently a max of 1 resource policy is supported.
The diskEncryptionKey
block supports:
kmsKeySelfLink
- The self link of the encryption key that is stored in Google Cloud KMS
The networkInterface
block supports:
-
network
- The name or self_link of the network to attach this interface to. Usenetwork
attribute for Legacy or Auto subnetted networks andsubnetwork
for custom subnetted networks. -
subnetwork
- the name of the subnetwork to attach this interface to. The subnetwork must exist in the sameregion
this instance will be created in. Eithernetwork
orsubnetwork
must be provided. -
subnetworkProject
- The ID of the project in which the subnetwork belongs. If it is not provided, the provider project is used. -
networkIp
- The private IP address to assign to the instance. If empty, the address will be automatically assigned. -
accessConfig
- Access configurations, i.e. IPs via which this instance can be accessed via the Internet. Omit to ensure that the instance is not accessible from the Internet (this means that ssh provisioners will not work unless you are running Terraform can send traffic to the instance's network (e.g. via tunnel or because it is running on another cloud instance on that network). This block can be repeated multiple times. Structure documented below. -
aliasIpRange
- An array of alias IP ranges for this network interface. Can only be specified for network interfaces on subnet-mode networks. Structure documented below.
The accessConfig
block supports:
-
natIp
- The IP address that will be 1:1 mapped to the instance's network ip. If not given, one will be generated. -
networkTier
- The [networking tier][network-tier] used for configuring this instance template. This field can take the following values: PREMIUM or STANDARD. If this field is not specified, it is assumed to be PREMIUM.
The aliasIpRange
block supports:
-
ipCidrRange
- The IP CIDR range represented by this alias IP range. This IP CIDR range must belong to the specified subnetwork and cannot contain IP addresses reserved by system or used by other network interfaces. At the time of writing only a netmask (e.g. /24) may be supplied, with a CIDR format resulting in an API error. -
subnetworkRangeName
- The subnetwork secondary range name specifying the secondary range from which to allocate the IP CIDR range for this alias IP range. If left unspecified, the primary range of the subnetwork will be used.
The serviceAccount
block supports:
-
email
- The service account e-mail address. If not given, the default Google Compute Engine service account is used. -
scopes
- A list of service scopes. Both OAuth2 URLs and gcloud short names are supported. To allow full access to all Cloud APIs, use thecloudPlatform
scope. See a complete list of scopes here.The service accounts documentation explains that access scopes are the legacy method of specifying permissions for your instance. If you are following best practices and using IAM roles to grant permissions to service accounts, then you can define this field as an empty list.
The scheduling
block supports:
-
automaticRestart
- Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). This defaults to true. -
onHostMaintenance
- Defines the maintenance behavior for this instance. -
preemptible
- Allows instance to be preempted. This defaults to false. Read more on this here. -
nodeAffinities
- Specifies node affinities or anti-affinities to determine which sole-tenant nodes your instances and managed instance groups will use as host systems. Read more on sole-tenant node creation here. Structure documented below. -
provisioningModel
- Describe the type of preemptible VM. -
instanceTerminationAction
- Describe the type of termination action forspot
VM. Can bestop
ordelete
. Read more on here
The guestAccelerator
block supports:
-
type
- The accelerator type resource to expose to this instance. E.g.nvidiaTeslaK80
. -
count
- The number of the guest accelerator cards exposed to this instance.
The nodeAffinities
block supports:
-
key
- The key for the node affinity label. -
operator
- The operator. Can bein
for node-affinities ornotIn
for anti-affinities. -
value
- The values for the node affinity label.
The shieldedInstanceConfig
block supports:
-
enableSecureBoot
-- Verify the digital signature of all boot components, and halt the boot process if signature verification fails. Defaults to false. -
enableVtpm
-- Use a virtualized trusted platform module, which is a specialized computer chip you can use to encrypt objects like keys and certificates. Defaults to true. -
enableIntegrityMonitoring
-- Compare the most recent boot measurements to the integrity policy baseline and return a pair of pass/fail results depending on whether they match or not. Defaults to true.
The confidentialInstanceConfig
block supports:
enableConfidentialCompute
Defines whether the instance should have confidential compute enabled.onHostMaintenance
has to be set to TERMINATE or this will fail to create the VM.
The networkPerformanceConfig
block supports:
totalEgressBandwidthTier
- The egress bandwidth tier for the instance.
-
id
- an identifier for the resource with formatprojects/{{project}}/global/instanceTemplates/{{name}}
-
metadataFingerprint
- The unique fingerprint of the metadata. -
selfLink
- The URI of the created resource. -
tagsFingerprint
- The unique fingerprint of the tags.