Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ids to vpn_tunnel and vpn_gateway outputs #4373

Merged
merged 1 commit into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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