Skip to content

Commit 4292451

Browse files
authored
add ids to vpn_tunnel and vpn_gateway outputs
2 parents b162bd0 + d5d2bb1 commit 4292451

4 files changed

+35
-0
lines changed

google/resource_compute_vpn_gateway.go

+18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"fmt"
1919
"log"
2020
"reflect"
21+
"strconv"
2122
"time"
2223

2324
"github.com/hashicorp/terraform/helper/schema"
@@ -67,6 +68,10 @@ func resourceComputeVpnGateway() *schema.Resource {
6768
Type: schema.TypeString,
6869
Computed: true,
6970
},
71+
"gateway_id": {
72+
Type: schema.TypeInt,
73+
Computed: true,
74+
},
7075
"project": {
7176
Type: schema.TypeString,
7277
Optional: true,
@@ -183,6 +188,9 @@ func resourceComputeVpnGatewayRead(d *schema.ResourceData, meta interface{}) err
183188
if err := d.Set("name", flattenComputeVpnGatewayName(res["name"], d)); err != nil {
184189
return fmt.Errorf("Error reading VpnGateway: %s", err)
185190
}
191+
if err := d.Set("gateway_id", flattenComputeVpnGatewayGateway_id(res["id"], d)); err != nil {
192+
return fmt.Errorf("Error reading VpnGateway: %s", err)
193+
}
186194
if err := d.Set("network", flattenComputeVpnGatewayNetwork(res["network"], d)); err != nil {
187195
return fmt.Errorf("Error reading VpnGateway: %s", err)
188196
}
@@ -268,6 +276,16 @@ func flattenComputeVpnGatewayName(v interface{}, d *schema.ResourceData) interfa
268276
return v
269277
}
270278

279+
func flattenComputeVpnGatewayGateway_id(v interface{}, d *schema.ResourceData) interface{} {
280+
// Handles the string fixed64 format
281+
if strVal, ok := v.(string); ok {
282+
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
283+
return intVal
284+
} // let terraform core handle it if we can't convert the string to an int.
285+
}
286+
return v
287+
}
288+
271289
func flattenComputeVpnGatewayNetwork(v interface{}, d *schema.ResourceData) interface{} {
272290
if v == nil {
273291
return v

google/resource_compute_vpn_tunnel.go

+11
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ func resourceComputeVpnTunnel() *schema.Resource {
225225
Type: schema.TypeString,
226226
Computed: true,
227227
},
228+
"tunnel_id": {
229+
Type: schema.TypeString,
230+
Computed: true,
231+
},
228232
"project": {
229233
Type: schema.TypeString,
230234
Optional: true,
@@ -373,6 +377,9 @@ func resourceComputeVpnTunnelRead(d *schema.ResourceData, meta interface{}) erro
373377
return fmt.Errorf("Error reading VpnTunnel: %s", err)
374378
}
375379

380+
if err := d.Set("tunnel_id", flattenComputeVpnTunnelTunnel_id(res["id"], d)); err != nil {
381+
return fmt.Errorf("Error reading VpnTunnel: %s", err)
382+
}
376383
if err := d.Set("creation_timestamp", flattenComputeVpnTunnelCreationTimestamp(res["creationTimestamp"], d)); err != nil {
377384
return fmt.Errorf("Error reading VpnTunnel: %s", err)
378385
}
@@ -476,6 +483,10 @@ func resourceComputeVpnTunnelImport(d *schema.ResourceData, meta interface{}) ([
476483
return []*schema.ResourceData{d}, nil
477484
}
478485

486+
func flattenComputeVpnTunnelTunnel_id(v interface{}, d *schema.ResourceData) interface{} {
487+
return v
488+
}
489+
479490
func flattenComputeVpnTunnelCreationTimestamp(v interface{}, d *schema.ResourceData) interface{} {
480491
return v
481492
}

website/docs/r/compute_vpn_gateway.html.markdown

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ In addition to the arguments listed above, the following computed attributes are
140140

141141
* `creation_timestamp` -
142142
Creation timestamp in RFC3339 text format.
143+
144+
* `gateway_id` -
145+
The unique identifier for the resource.
143146
* `self_link` - The URI of the created resource.
144147

145148

website/docs/r/compute_vpn_tunnel.html.markdown

+3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ The following arguments are supported:
263263
In addition to the arguments listed above, the following computed attributes are exported:
264264

265265

266+
* `tunnel_id` -
267+
The unique identifier for the resource. This identifier is defined by the server.
268+
266269
* `creation_timestamp` -
267270
Creation timestamp in RFC3339 text format.
268271

0 commit comments

Comments
 (0)