github.com/arvindram03/terraform@v0.3.7-0.20150212015210-408f838db36d/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  The `network_interface` block supports:
    97  
    98  * `network` - (Required) The name of the network to attach this interface to.
    99  
   100  * `access_config` - (Optional) Access configurations, i.e. IPs via which this instance can be
   101    accessed via the Internet.  Omit to ensure that the instance is not accessible from the Internet
   102  (this means that ssh provisioners will not work unless you are running Terraform can send traffic to
   103  the instance's network (e.g. via tunnel or because it is running on another cloud instance on that
   104  network).  This block can be repeated multiple times.  Structure documented below.
   105  
   106  The `access_config` block supports:
   107  
   108  * `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's network ip.  If not
   109    given, one will be generated.
   110  
   111  (DEPRECATED) The `network` block supports:
   112  
   113  * `source` - (Required) The name of the network to attach this interface to.
   114  
   115  * `address` - (Optional) The IP address of a reserved IP address to assign
   116       to this interface.
   117  
   118  The `service_account` block supports:
   119  
   120  * `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud
   121      short names are supported.
   122  
   123  ## Attributes Reference
   124  
   125  The following attributes are exported:
   126  
   127  * `name` - The name of the resource.
   128  * `machine_type` - The type of machine.
   129  * `zone` - The zone the machine lives in.