github.com/i0n/terraform@v0.4.3-0.20150506151324-010a39a58ec1/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 network_interface { 31 network = "default" 32 access_config { 33 // Ephemeral IP 34 } 35 } 36 37 metadata { 38 foo = "bar" 39 } 40 41 service_account { 42 scopes = ["userinfo-email", "compute-ro", "storage-ro"] 43 } 44 } 45 ``` 46 47 ## Argument Reference 48 49 The following arguments are supported: 50 51 * `name` - (Required) A unique name for the resource, required by GCE. 52 Changing this forces a new resource to be created. 53 54 * `description` - (Optional) A brief description of this resource. 55 56 * `machine_type` - (Required) The machine type to create. 57 58 * `zone` - (Required) The zone that the machine should be created in. 59 60 * `disk` - (Required) Disks to attach to the instance. This can be specified 61 multiple times for multiple disks. Structure is documented below. 62 63 * `can_ip_forward` - (Optional) Whether to allow sending and receiving of 64 packets with non-matching source or destination IPs. 65 This defaults to false. 66 67 * `metadata` - (Optional) Metadata key/value pairs to make available from 68 within the instance. 69 70 * `network_interface` - (Required) Networks to attach to the instance. This can be 71 specified multiple times for multiple networks. Structure is documented 72 below. 73 74 * `network` - (DEPRECATED, Required) Networks to attach to the instance. This can be 75 specified multiple times for multiple networks. Structure is documented 76 below. 77 78 * `service_account` - (Optional) Service account to attach to the instance. 79 80 * `tags` - (Optional) Tags to attach to the instance. 81 82 The `disk` block supports: 83 84 * `disk` - (Required if image not set) The name of the disk (such as 85 those managed by `google_compute_disk`) to attach. 86 87 * `image` - (Required if disk not set) The image from which to initialize this 88 disk. Either the full URL, a contraction of the form "project/name", or just 89 a name (in which case the current project is used). 90 91 * `auto_delete` - (Optional) Whether or not the disk should be auto-deleted. 92 This defaults to true. 93 94 * `type` - (Optional) The GCE disk type. 95 96 * `size` - (Optional) The size of the image in gigabytes. If not specified, 97 it will inherit the size of its base image. 98 99 * `device_name` - (Optional) Name with which attached disk will be accessible 100 under `/dev/disk/by-id/` 101 102 The `network_interface` block supports: 103 104 * `network` - (Required) The name of the network to attach this interface to. 105 106 * `access_config` - (Optional) Access configurations, i.e. IPs via which this instance can be 107 accessed via the Internet. Omit to ensure that the instance is not accessible from the Internet 108 (this means that ssh provisioners will not work unless you are running Terraform can send traffic to 109 the instance's network (e.g. via tunnel or because it is running on another cloud instance on that 110 network). This block can be repeated multiple times. Structure documented below. 111 112 The `access_config` block supports: 113 114 * `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's network ip. If not 115 given, one will be generated. 116 117 (DEPRECATED) The `network` block supports: 118 119 * `source` - (Required) The name of the network to attach this interface to. 120 121 * `address` - (Optional) The IP address of a reserved IP address to assign 122 to this interface. 123 124 The `service_account` block supports: 125 126 * `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud 127 short names are supported. 128 129 ## Attributes Reference 130 131 The following attributes are exported: 132 133 * `name` - The name of the resource. 134 * `machine_type` - The type of machine. 135 * `zone` - The zone the machine lives in.