github.com/hobbeswalsh/terraform@v0.3.7-0.20150619183303-ad17cf55a0fa/website/source/docs/providers/google/r/compute_instance.html.markdown (about) 1 --- 2 layout: "google" 3 page_title: "Google: google_compute_instance" 4 sidebar_current: "docs-google-resource-instance" 5 description: |- 6 Manages a VM instance resource within GCE. 7 --- 8 9 # google\_compute\_instance 10 11 Manages a VM instance resource within GCE. For more information see 12 [the official documentation](https://cloud.google.com/compute/docs/instances) 13 and 14 [API](https://cloud.google.com/compute/docs/reference/latest/instances). 15 16 17 ## Example Usage 18 19 ``` 20 resource "google_compute_instance" "default" { 21 name = "test" 22 machine_type = "n1-standard-1" 23 zone = "us-central1-a" 24 tags = ["foo", "bar"] 25 26 disk { 27 image = "debian-7-wheezy-v20140814" 28 } 29 30 // Local SSD disk 31 disk { 32 type = "local-ssd" 33 scratch = true 34 } 35 36 network_interface { 37 network = "default" 38 access_config { 39 // Ephemeral IP 40 } 41 } 42 43 metadata { 44 foo = "bar" 45 } 46 47 service_account { 48 scopes = ["userinfo-email", "compute-ro", "storage-ro"] 49 } 50 } 51 ``` 52 53 ## Argument Reference 54 55 The following arguments are supported: 56 57 * `name` - (Required) A unique name for the resource, required by GCE. 58 Changing this forces a new resource to be created. 59 60 * `description` - (Optional) A brief description of this resource. 61 62 * `machine_type` - (Required) The machine type to create. 63 64 * `zone` - (Required) The zone that the machine should be created in. 65 66 * `disk` - (Required) Disks to attach to the instance. This can be specified 67 multiple times for multiple disks. Structure is documented below. 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 * `metadata` - (Optional) Metadata key/value pairs to make available from 74 within the instance. 75 76 * `network_interface` - (Required) Networks to attach to the instance. This can be 77 specified multiple times for multiple networks. Structure is documented 78 below. 79 80 * `network` - (DEPRECATED, Required) Networks to attach to the instance. This can be 81 specified multiple times for multiple networks. Structure is documented 82 below. 83 84 * `service_account` - (Optional) Service account to attach to the instance. 85 86 * `tags` - (Optional) Tags to attach to the instance. 87 88 The `disk` block supports: (Note that either disk or image is required, unless 89 the type is "local-ssd", in which case scratch must be true). 90 91 * `disk` - The name of the existing disk (such as those managed by 92 `google_compute_disk`) to attach. 93 94 * `image` - The image from which to initialize this 95 disk. Either the full URL, a contraction of the form "project/name", or just 96 a name (in which case the current project is used). 97 98 * `auto_delete` - (Optional) Whether or not the disk should be auto-deleted. 99 This defaults to true. Leave true for local SSDs. 100 101 * `type` - (Optional) The GCE disk type, e.g. pd-standard, pd-ssd, or local-ssd. 102 103 * `scratch` - (Optional) Whether the disk is a scratch disk as opposed to a 104 persistent disk (required for local-ssd). 105 106 * `size` - (Optional) The size of the image in gigabytes. If not specified, it 107 will inherit the size of its base image. Do not specify for local SSDs as 108 their size is fixed. 109 110 * `device_name` - (Optional) Name with which attached disk will be accessible 111 under `/dev/disk/by-id/` 112 113 The `network_interface` block supports: 114 115 * `network` - (Required) The name of the network to attach this interface to. 116 117 * `access_config` - (Optional) Access configurations, i.e. IPs via which this instance can be 118 accessed via the Internet. Omit to ensure that the instance is not accessible from the Internet 119 (this means that ssh provisioners will not work unless you are running Terraform can send traffic to 120 the instance's network (e.g. via tunnel or because it is running on another cloud instance on that 121 network). This block can be repeated multiple times. Structure documented below. 122 123 The `access_config` block supports: 124 125 * `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's network ip. If not 126 given, one will be generated. 127 128 (DEPRECATED) The `network` block supports: 129 130 * `source` - (Required) The name of the network to attach this interface to. 131 132 * `address` - (Optional) The IP address of a reserved IP address to assign 133 to this interface. 134 135 The `service_account` block supports: 136 137 * `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud 138 short names are supported. 139 140 ## Attributes Reference 141 142 The following attributes are exported: 143 144 * `name` - The name of the resource. 145 * `machine_type` - The type of machine. 146 * `zone` - The zone the machine lives in.