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