Skip to content

Commit

Permalink
add ids to vpn_tunnel and vpn_gateway outputs
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
megan07 authored and modular-magician committed Aug 29, 2019
1 parent b162bd0 commit d5d2bb1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions google/resource_compute_vpn_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"log"
"reflect"
"strconv"
"time"

"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -67,6 +68,10 @@ func resourceComputeVpnGateway() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"gateway_id": {
Type: schema.TypeInt,
Computed: true,
},
"project": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -183,6 +188,9 @@ func resourceComputeVpnGatewayRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("name", flattenComputeVpnGatewayName(res["name"], d)); err != nil {
return fmt.Errorf("Error reading VpnGateway: %s", err)
}
if err := d.Set("gateway_id", flattenComputeVpnGatewayGateway_id(res["id"], d)); err != nil {
return fmt.Errorf("Error reading VpnGateway: %s", err)
}
if err := d.Set("network", flattenComputeVpnGatewayNetwork(res["network"], d)); err != nil {
return fmt.Errorf("Error reading VpnGateway: %s", err)
}
Expand Down Expand Up @@ -268,6 +276,16 @@ func flattenComputeVpnGatewayName(v interface{}, d *schema.ResourceData) interfa
return v
}

func flattenComputeVpnGatewayGateway_id(v interface{}, d *schema.ResourceData) interface{} {
// Handles the string fixed64 format
if strVal, ok := v.(string); ok {
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
return intVal
} // let terraform core handle it if we can't convert the string to an int.
}
return v
}

func flattenComputeVpnGatewayNetwork(v interface{}, d *schema.ResourceData) interface{} {
if v == nil {
return v
Expand Down
11 changes: 11 additions & 0 deletions google/resource_compute_vpn_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ func resourceComputeVpnTunnel() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"tunnel_id": {
Type: schema.TypeString,
Computed: true,
},
"project": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -373,6 +377,9 @@ func resourceComputeVpnTunnelRead(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error reading VpnTunnel: %s", err)
}

if err := d.Set("tunnel_id", flattenComputeVpnTunnelTunnel_id(res["id"], d)); err != nil {
return fmt.Errorf("Error reading VpnTunnel: %s", err)
}
if err := d.Set("creation_timestamp", flattenComputeVpnTunnelCreationTimestamp(res["creationTimestamp"], d)); err != nil {
return fmt.Errorf("Error reading VpnTunnel: %s", err)
}
Expand Down Expand Up @@ -476,6 +483,10 @@ func resourceComputeVpnTunnelImport(d *schema.ResourceData, meta interface{}) ([
return []*schema.ResourceData{d}, nil
}

func flattenComputeVpnTunnelTunnel_id(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenComputeVpnTunnelCreationTimestamp(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/compute_vpn_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ In addition to the arguments listed above, the following computed attributes are

* `creation_timestamp` -
Creation timestamp in RFC3339 text format.

* `gateway_id` -
The unique identifier for the resource.
* `self_link` - The URI of the created resource.


Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/compute_vpn_tunnel.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ The following arguments are supported:
In addition to the arguments listed above, the following computed attributes are exported:


* `tunnel_id` -
The unique identifier for the resource. This identifier is defined by the server.

* `creation_timestamp` -
Creation timestamp in RFC3339 text format.

Expand Down

0 comments on commit d5d2bb1

Please sign in to comment.