Skip to content

Commit 504bc87

Browse files
committed
Merge pull request hashicorp#4265 from lwander/gcp-assigned-nat-ip
provider/google: provide assigned_nat_ip as well as nat_ip
2 parents 6b2fba6 + a1a5788 commit 504bc87

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

builtin/providers/google/resource_compute_instance.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,13 @@ func resourceComputeInstance() *schema.Resource {
137137
Schema: map[string]*schema.Schema{
138138
"nat_ip": &schema.Schema{
139139
Type: schema.TypeString,
140-
Computed: true,
141140
Optional: true,
142141
},
142+
143+
"assigned_nat_ip": &schema.Schema{
144+
Type: schema.TypeString,
145+
Computed: true,
146+
},
143147
},
144148
},
145149
},
@@ -637,9 +641,10 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
637641
var natIP string
638642
accessConfigs := make(
639643
[]map[string]interface{}, 0, len(iface.AccessConfigs))
640-
for _, config := range iface.AccessConfigs {
644+
for j, config := range iface.AccessConfigs {
641645
accessConfigs = append(accessConfigs, map[string]interface{}{
642-
"nat_ip": config.NatIP,
646+
"nat_ip": d.Get(fmt.Sprintf("network_interface.%d.access_config.%d.nat_ip", i, j)),
647+
"assigned_nat_ip": config.NatIP,
643648
})
644649

645650
if natIP == "" {

website/source/docs/providers/google/r/compute_instance.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ The `access_config` block supports:
133133
* `nat_ip` - (Optional) The IP address that will be 1:1 mapped to the instance's network ip. If not
134134
given, one will be generated.
135135

136+
* `assigned_nat_ip` - (Optional) The IP address that is assigned to the
137+
instance. If `nat_ip` is filled, it will appear here. If `nat_ip` is left
138+
blank, the ephemeral assigned IP will appear here.
139+
136140
(DEPRECATED) The `network` block supports:
137141

138142
* `source` - (Required) The name of the network to attach this interface to.

website/source/docs/providers/google/r/dns_record_set.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ resource "google_dns_record_set" "frontend" {
4040
name = "frontend.${google_dns_managed_zone.prod.dns_name}"
4141
type = "A"
4242
ttl = 300
43-
rrdatas = ["${google_compute_instance.frontend.network_interface.0.access_config.0.nat_ip}"]
43+
rrdatas = ["${google_compute_instance.frontend.network_interface.0.access_config.0.assigned_nat_ip}"]
4444
}
4545
```
4646

0 commit comments

Comments
 (0)