github.com/hobbeswalsh/terraform@v0.3.7-0.20150619183303-ad17cf55a0fa/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-resource-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  * `automatic_restart` - (Optional) Specifies whether the instance should be
    90  	automatically restarted if it is terminated by Compute Engine (not
    91  	terminated by a user).
    92  	This defaults to true.
    93  
    94  * `on_host_maintenance` - (Optional) Defines the maintenance behavior for this
    95  	instance.
    96  
    97  * `service_account` - (Optional) Service account to attach to the instance.
    98  
    99  * `tags` - (Optional) Tags to attach to the instance.
   100  
   101  
   102  
   103  The `disk` block supports:
   104  
   105  * `auto_delete` - (Optional) Whether or not the disk should be auto-deleted.
   106  	This defaults to true.
   107  
   108  * `boot` - (Optional) Indicates that this is a boot disk.
   109  
   110  * `device_name` - (Optional) A unique device name that is reflected into
   111  	the /dev/  tree of a Linux operating system running within the instance.
   112  	If not specified, the server chooses a default device name to apply to
   113  	this disk.
   114  
   115  * `disk_name` - (Optional) Name of the disk. When not provided, this defaults
   116  	to the name of the instance.
   117  
   118  * `source_image` - (Required if source not set) The name of the image to base
   119  	this disk off of.
   120  
   121  * `interface` - (Optional) Specifies the disk interface to use for attaching
   122  	this disk.
   123  
   124  * `mode` - (Optional) The mode in which to attach this disk, either READ_WRITE
   125  	or READ_ONLY. If you are attaching or creating a boot disk, this must
   126  	read-write mode.
   127  
   128  * `source` - (Required if source_image not set) The name of the disk (such as
   129  	those managed by `google_compute_disk`) to attach.
   130  
   131  * `type` - (Optional) The GCE disk type.
   132  
   133  The `network_interface` block supports:
   134  
   135  * `network` - (Required) The name of the network to attach this interface to.
   136  
   137  * `access_config` - (Optional) Access configurations, i.e. IPs via which this instance can be
   138    accessed via the Internet.  Omit to ensure that the instance is not accessible from the Internet
   139  (this means that ssh provisioners will not work unless you are running Terraform can send traffic to
   140  the instance's network (e.g. via tunnel or because it is running on another cloud instance on that
   141  network).  This block can be repeated multiple times.  Structure documented below.
   142  
   143  The `access_config` block supports:
   144  
   145  * `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's network ip.  If not
   146    given, one will be generated.
   147  
   148  The `service_account` block supports:
   149  
   150  * `scopes` - (Required) A list of service scopes. Both OAuth2 URLs and gcloud
   151  	short names are supported.
   152  
   153  ## Attributes Reference
   154  
   155  The following attributes are exported:
   156  
   157  * `self_link` - The URL of the created resource.