2014-08-26 21:50:29 +00:00
---
2018-06-12 00:31:33 +00:00
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
2014-08-26 21:50:29 +00:00
layout: "google"
page_title: "Google: google_compute_address"
2015-10-23 14:10:41 +00:00
sidebar_current: "docs-google-compute-address"
2014-10-22 03:21:56 +00:00
description: |-
2018-06-12 00:31:33 +00:00
Represents an Address resource.
2014-08-26 21:50:29 +00:00
---
# google\_compute\_address
2018-06-12 00:31:33 +00:00
Represents an Address resource.
2014-11-20 17:40:17 +00:00
2018-06-12 00:31:33 +00:00
Each virtual machine instance has an ephemeral internal IP address and,
optionally, an external IP address. To communicate between instances on
the same network, you can use an instance's internal IP address. To
communicate with the Internet and instances outside of the same network,
you must specify the instance's external IP address.
Internal IP addresses are ephemeral and only belong to an instance for
the lifetime of the instance; if the instance is deleted and recreated,
the instance is assigned a new internal IP address, either by Compute
Engine or by you. External IP addresses can be either ephemeral or
static.
2018-10-04 02:45:53 +00:00
2018-06-12 00:31:33 +00:00
To get more information about Address, see:
* [API documentation ](https://cloud.google.com/compute/docs/reference/beta/addresses )
* How-to Guides
* [Reserving a Static External IP Address ](https://cloud.google.com/compute/docs/instances-and-network )
* [Reserving a Static Internal IP Address ](https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address )
2014-08-26 21:50:29 +00:00
2018-11-09 00:30:51 +00:00
< div class = "oics-button" style = "float: right; margin: 0 0 -15px" >
< a href = "https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=address_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target = "_blank" >
< img alt = "Open in Cloud Shell" src = "//gstatic.com/cloudssh/images/open-btn.svg" style = "max-height: 44px; margin: 32px auto; max-width: 100%;" >
< / a >
< / div >
## Example Usage - Address Basic
2014-08-26 21:50:29 +00:00
2017-04-17 10:17:54 +00:00
```hcl
2018-09-17 19:31:57 +00:00
resource "google_compute_address" "ip_address" {
2018-06-12 00:31:33 +00:00
name = "my-address"
2014-08-26 21:50:29 +00:00
}
```
2018-11-09 00:30:51 +00:00
< div class = "oics-button" style = "float: right; margin: 0 0 -15px" >
< a href = "https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=address_with_subnetwork&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target = "_blank" >
< img alt = "Open in Cloud Shell" src = "//gstatic.com/cloudssh/images/open-btn.svg" style = "max-height: 44px; margin: 32px auto; max-width: 100%;" >
< / a >
< / div >
## Example Usage - Address With Subnetwork
2018-06-12 00:31:33 +00:00
```hcl
resource "google_compute_network" "default" {
name = "my-network"
}
2014-08-26 21:50:29 +00:00
2018-06-12 00:31:33 +00:00
resource "google_compute_subnetwork" "default" {
name = "my-subnet"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = "${google_compute_network.default.self_link}"
}
2014-08-26 21:50:29 +00:00
2018-06-12 00:31:33 +00:00
resource "google_compute_address" "internal_with_subnet_and_address" {
name = "my-internal-address"
subnetwork = "${google_compute_subnetwork.default.self_link}"
address_type = "INTERNAL"
address = "10.0.42.42"
region = "us-central1"
}
```
2018-11-09 00:30:51 +00:00
< div class = "oics-button" style = "float: right; margin: 0 0 -15px" >
< a href = "https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=instance_with_ip&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target = "_blank" >
< img alt = "Open in Cloud Shell" src = "//gstatic.com/cloudssh/images/open-btn.svg" style = "max-height: 44px; margin: 32px auto; max-width: 100%;" >
< / a >
< / div >
## Example Usage - Instance With Ip
2018-10-05 20:05:58 +00:00
```hcl
resource "google_compute_address" "static" {
name = "ipv4-address"
}
data "google_compute_image" "debian_image" {
family = "debian-9"
project = "debian-cloud"
}
resource "google_compute_instance" "instance_with_ip" {
name = "vm-instance"
machine_type = "f1-micro"
zone = "us-central1-a"
boot_disk {
initialize_params{
image = "${data.google_compute_image.debian_image.self_link}"
}
}
network_interface {
network = "default"
access_config {
nat_ip = "${google_compute_address.static.address}"
}
}
}
```
2016-04-10 21:34:15 +00:00
2018-06-12 00:31:33 +00:00
## Argument Reference
2016-04-10 21:34:15 +00:00
2018-06-12 00:31:33 +00:00
The following arguments are supported:
2016-04-10 21:34:15 +00:00
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `name` -
(Required)
Name of the resource. The name must be 1-63 characters long, and
comply with RFC1035. Specifically, the name must be 1-63 characters
long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
which means the first character must be a lowercase letter, and all
following characters must be a dash, lowercase letter, or digit,
except the last character, which cannot be a dash.
2014-08-26 21:50:29 +00:00
2018-08-20 23:46:13 +00:00
2018-06-12 00:31:33 +00:00
- - -
2017-11-07 21:38:26 +00:00
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `address` -
(Optional)
The static external IP address represented by this resource. Only
IPv4 is supported. An address may only be specified for INTERNAL
address types. The IP address must be inside the specified subnetwork,
if any.
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `address_type` -
(Optional)
The type of address to reserve, either INTERNAL or EXTERNAL.
If unspecified, defaults to EXTERNAL.
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `description` -
(Optional)
An optional description of this resource.
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `network_tier` -
(Optional)
The networking tier used for configuring this address. This field can
take the following values: PREMIUM or STANDARD. If this field is not
2018-10-04 16:51:57 +00:00
specified, it is assumed to be PREMIUM.
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `subnetwork` -
(Optional)
The URL of the subnetwork in which to reserve the address. If an IP
address is specified, it must be within the subnetwork's IP range.
This field can only be used with INTERNAL type with
GCE_ENDPOINT/DNS_RESOLVER purposes.
2018-07-10 22:42:50 +00:00
2018-07-25 20:25:16 +00:00
* `labels` -
(Optional)
2018-10-04 02:45:53 +00:00
Labels to apply to this address. A list of key->value pairs. This property is in beta, and should be used with the terraform-provider-google-beta provider.
2018-10-09 15:26:38 +00:00
See [Provider Versions ](https://terraform.io/docs/providers/google/provider_versions.html ) for more details on beta fields.
2018-07-25 20:25:16 +00:00
2018-06-12 00:31:33 +00:00
* `region` -
(Optional)
The Region in which the created address should reside.
If it is not provided, the provider region is used.
2018-08-16 05:59:44 +00:00
* `project` - (Optional) The ID of the project in which the resource belongs.
2018-06-12 00:31:33 +00:00
If it is not provided, the provider project is used.
2017-11-07 21:38:26 +00:00
2018-06-05 20:42:22 +00:00
2014-08-26 21:50:29 +00:00
## Attributes Reference
2018-06-12 00:31:33 +00:00
In addition to the arguments listed above, the following computed attributes are exported:
2014-08-26 21:50:29 +00:00
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `creation_timestamp` -
Creation timestamp in RFC3339 text format.
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
* `users` -
The URLs of the resources that are using this address.
2018-07-25 20:25:16 +00:00
* `label_fingerprint` -
The fingerprint used for optimistic locking of this resource. Used
2018-10-04 02:45:53 +00:00
internally during updates. This property is in beta, and should be used with the terraform-provider-google-beta provider.
2018-10-09 15:26:38 +00:00
See [Provider Versions ](https://terraform.io/docs/providers/google/provider_versions.html ) for more details on beta fields.
2014-11-20 17:40:17 +00:00
* `self_link` - The URI of the created resource.
2017-06-14 00:46:50 +00:00
2018-08-16 05:59:44 +00:00
* `address` - The IP of the created resource.
2018-07-10 22:42:50 +00:00
2018-06-12 00:31:33 +00:00
## Timeouts
2017-09-07 17:38:26 +00:00
2018-06-12 00:31:33 +00:00
This resource provides the following
[Timeouts ](/docs/configuration/resources.html#timeouts ) configuration options:
2017-09-07 17:38:26 +00:00
2018-06-12 00:31:33 +00:00
- `create` - Default is 4 minutes.
2018-07-25 20:25:16 +00:00
- `update` - Default is 4 minutes.
2018-06-12 00:31:33 +00:00
- `delete` - Default is 4 minutes.
2017-09-07 17:38:26 +00:00
2018-06-12 00:31:33 +00:00
## Import
2017-09-07 17:38:26 +00:00
2018-06-12 00:31:33 +00:00
Address can be imported using any of these accepted formats:
2017-09-07 17:38:26 +00:00
```
2018-06-12 00:31:33 +00:00
$ terraform import google_compute_address.default projects/{{project}}/regions/{{region}}/addresses/{{name}}
$ terraform import google_compute_address.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_address.default {{name}}
2018-03-12 20:59:47 +00:00
```