googleComputeInstanceFromTemplate
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 googleComputeInstance
resource.
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.*/
const googleComputeInstanceTemplateTpl =
new google.computeInstanceTemplate.ComputeInstanceTemplate(this, "tpl", {
can_ip_forward: true,
disk: [
{
auto_delete: true,
boot: true,
disk_size_gb: 100,
source_image: "debian-cloud/debian-11",
},
],
machine_type: "e2-medium",
metadata: [
{
foo: "bar",
},
],
name: "template",
network_interface: [
{
network: "default",
},
],
});
const googleComputeInstanceFromTemplateTpl =
new google.computeInstanceFromTemplate.ComputeInstanceFromTemplate(
this,
"tpl_1",
{
can_ip_forward: false,
labels: [
{
my_key: "my_value",
},
],
name: "instance-from-template",
source_instance_template: googleComputeInstanceTemplateTpl.id,
zone: "us-central1-a",
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeInstanceFromTemplateTpl.overrideLogicalId("tpl");
Argument Reference
The following arguments are supported:
-
name
- (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created. -
sourceInstanceTemplate
- (Required) Name or self link of an instance template to create the instance based on.
zone
- (Optional) The zone that the machine should be created in. If not set, the provider zone is used.
In addition to these, all arguments from googleComputeInstance
are supported as a way to override the properties in the template. All exported attributes from googleComputeInstance
are likewise exported here.
To support removal of Optional/Computed fields in Terraform 0.12 the following fields are marked Attributes as Blocks:
attachedDisk
guestAccelerator
serviceAccount
scratchDisk
networkInterfaceAliasIpRange
networkInterfaceAccessConfig
Attributes Reference
All exported attributes from googleComputeInstance
are exported here. See https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#attributes-reference for details.
Import
This resource does not support import.
Timeouts
This resource provides the following Timeouts configuration options: configuration options:
create
- Default is 6 minutes.update
- Default is 6 minutes.delete
- Default is 6 minutes.