Skip to content

Commit

Permalink
extract vpn tunnel region/project from vpn gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
danawillow authored and modular-magician committed Dec 12, 2018
1 parent 00cc6cc commit 1fc23a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions google-beta/resource_compute_vpn_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ func resourceComputeVpnTunnelCreate(d *schema.ResourceData, meta interface{}) er
obj["region"] = regionProp
}

obj, err = resourceComputeVpnTunnelEncoder(d, meta, obj)
if err != nil {
return err
}

url, err := replaceVars(d, config, "https://www.googleapis.com/compute/beta/projects/{{project}}/regions/{{region}}/vpnTunnels")
if err != nil {
return err
Expand Down Expand Up @@ -694,3 +699,18 @@ func expandComputeVpnTunnelRegion(v interface{}, d *schema.ResourceData, config
}
return f.RelativeLink(), nil
}

func resourceComputeVpnTunnelEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
config := meta.(*Config)
f, err := parseRegionalFieldValue("targetVpnGateways", d.Get("target_vpn_gateway").(string), "project", "region", "zone", d, config, true)
if err != nil {
return nil, err
}
if _, ok := d.GetOk("project"); !ok {
d.Set("project", f.Project)
}
if _, ok := d.GetOk("region"); !ok {
d.Set("region", f.Region)
}
return obj, nil
}
2 changes: 1 addition & 1 deletion website/docs/r/compute_vpn_tunnel.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ The following arguments are supported:

* `region` -
(Optional)
The region where the tunnel is located.
The region where the tunnel is located. If unset, is set to the region of `target_vpn_gateway`.
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down

0 comments on commit 1fc23a0

Please sign in to comment.