github.com/andresvia/terraform@v0.6.15-0.20160412045437-d51c75946785/website/source/docs/providers/google/r/compute_instance_template.html.markdown (about) 1 --- 2 layout: "google" 3 page_title: "Google: google_compute_instance_template" 4 sidebar_current: "docs-google-compute-instance-template" 5 description: |- 6 Manages a VM instance template resource within GCE. 7 --- 8 9 10 # google\_compute\_instance\_template 11 12 Manages a VM instance template resource within GCE. For more information see 13 [the official documentation](https://cloud.google.com/compute/docs/instance-templates) 14 and 15 [API](https://cloud.google.com/compute/docs/reference/latest/instanceTemplates). 16 17 18 ## Example Usage 19 20 ```js 21 resource "google_compute_instance_template" "foobar" { 22 name = "terraform-test" 23 description = "template description" 24 25 tags = ["foo", "bar"] 26 27 instance_description = "description assigned to instances" 28 machine_type = "n1-standard-1" 29 can_ip_forward = false 30 automatic_restart = true 31 on_host_maintenance = "MIGRATE" 32 33 // Create a new boot disk from an image 34 disk { 35 source_image = "debian-7-wheezy-v20160301" 36 auto_delete = true 37 boot = true 38 } 39 40 // Use an existing disk resource 41 disk { 42 source = "foo_existing_disk" 43 auto_delete = false 44 boot = false 45 } 46 47 network_interface { 48 network = "default" 49 } 50 51 metadata { 52 foo = "bar" 53 } 54 55 service_account { 56 scopes = ["userinfo-email", "compute-ro", "storage-ro"] 57 } 58 } 59 ``` 60 61 ## Argument Reference 62 63 Note that changing any field for this resource forces a new resource to be created. 64 65 The following arguments are supported: 66 67 * `disk` - (Required) Disks to attach to instances created from this template. 68 This can be specified multiple times for multiple disks. Structure is 69 documented below. 70 71 * `machine_type` - (Required) The machine type to create. 72 73 * `name` - (Required) A unique name for the resource, required by GCE. 74 75 - - - 76 77 * `can_ip_forward` - (Optional) Whether to allow sending and receiving of 78 packets with non-matching source or destination IPs. This defaults to false. 79 80 * `description` - (Optional) A brief description of this resource. 81 82 * `instance_description` - (Optional) A brief description to use for instances 83 created from this template. 84 85 * `metadata` - (Optional) Metadata key/value pairs to make available from 86 within instances created from this template. 87 88 * `network_interface` - (Required) Networks to attach to instances created from 89 this template. This can be specified multiple times for multiple networks. 90 Structure is documented below. 91 92 * `project` - (Optional) The project in which the resource belongs. If it 93 is not provided, the provider project is used. 94 95 * `region` - (Optional) An instance template is a global resource that is not 96 bound to a zone or a region. However, you can still specify some regional 97 resources in an instance template, which restricts the template to the 98 region where that resource resides. For example, a custom `subnetwork` 99 resource is tied to a specific region. Defaults to the region of the 100 Provider if no value is given. 101 102 * `scheduling` - (Optional) The scheduling strategy to use. More details about 103 this configuration option are detailed below. 104 105 * `service_account` - (Optional) Service account to attach to the instance. 106 107 * `tags` - (Optional) Tags to attach to the instance. 108 109 The `disk` block supports: 110 111 * `auto_delete` - (Optional) Whether or not the disk should be auto-deleted. 112 This defaults to true. 113 114 * `boot` - (Optional) Indicates that this is a boot disk. 115 116 * `device_name` - (Optional) A unique device name that is reflected into the 117 /dev/ tree of a Linux operating system running within the instance. If not 118 specified, the server chooses a default device name to apply to this disk. 119 120 * `disk_name` - (Optional) Name of the disk. When not provided, this defaults 121 to the name of the instance. 122 123 * `source_image` - (Required if source not set) The name of the image to base 124 this disk off of. 125 126 * `interface` - (Optional) Specifies the disk interface to use for attaching 127 this disk. 128 129 * `mode` - (Optional) The mode in which to attach this disk, either READ_WRITE 130 or READ_ONLY. If you are attaching or creating a boot disk, this must 131 read-write mode. 132 133 * `source` - (Required if source_image not set) The name of the disk (such as 134 those managed by `google_compute_disk`) to attach. 135 136 * `disk_type` - (Optional) The GCE disk type. Can be either `"pd-ssd"`, 137 `"local-ssd"`, or `"pd-standard"`. 138 139 * `disk_size_gb` - (Optional) The size of the image in gigabytes. If not 140 specified, it will inherit the size of its base image. 141 142 * `type` - (Optional) The type of GCE disk, can be either `"SCRATCH"` or 143 `"PERSISTENT"`. 144 145 The `network_interface` block supports: 146 147 * `network` - (Optional) The name of the network to attach this interface to. 148 Use `network` attribute for Legacy or Auto subnetted networks and 149 `subnetwork` for custom subnetted networks. 150 151 * `subnetwork` - (Optional) the name of the subnetwork to attach this interface 152 to. The subnetwork must exist in the same `region` this instance will be 153 created in. Either `network` or `subnetwork` must be provided. 154 155 * `access_config` - (Optional) Access configurations, i.e. IPs via which this 156 instance can be accessed via the Internet. Omit to ensure that the instance 157 is not accessible from the Internet (this means that ssh provisioners will 158 not work unless you are running Terraform can send traffic to the instance's 159 network (e.g. via tunnel or because it is running on another cloud instance 160 on that network). This block can be repeated multiple times. Structure documented below. 161 162 The `access_config` block supports: 163 164 * `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's 165 network ip. If not given, one will be generated. 166 167 The `service_account` block supports: 168 169 * `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud 170 short names are supported. 171 172 The `scheduling` block supports: 173 174 * `automatic_restart` - (Optional) Specifies whether the instance should be 175 automatically restarted if it is terminated by Compute Engine (not 176 terminated by a user). This defaults to true. 177 178 * `on_host_maintenance` - (Optional) Defines the maintenance behavior for this 179 instance. 180 181 * `preemptible` - (Optional) Allows instance to be preempted. Read more on this 182 [here](https://cloud.google.com/compute/docs/instances/preemptible). 183 184 ## Attributes Reference 185 186 In addition to the arguments listed above, the following computed attributes are 187 exported: 188 189 * `metadata_fingerprint` - The unique fingerprint of the metadata. 190 191 * `self_link` - The URI of the created resource. 192 193 * `tags_fingerprint` - The unique fingerprint of the tags.