diff --git a/google/resource_compute_router_peer.go b/google/resource_compute_router_peer.go index 0cfb8d2ffd3..1dedb193576 100644 --- a/google/resource_compute_router_peer.go +++ b/google/resource_compute_router_peer.go @@ -161,6 +161,7 @@ If it is not provided, the provider region is used.`, "ip_address": { Type: schema.TypeString, Computed: true, + Optional: true, Description: `IP address of the interface inside Google Cloud Platform. Only IPv4 is supported.`, }, @@ -209,6 +210,13 @@ func resourceComputeRouterBgpPeerCreate(d *schema.ResourceData, meta interface{} } else if v, ok := d.GetOkExists("interface"); !isEmptyValue(reflect.ValueOf(interfaceNameProp)) && (ok || !reflect.DeepEqual(v, interfaceNameProp)) { obj["interfaceName"] = interfaceNameProp } + ipAddressProp, err := expandNestedComputeRouterBgpPeerIpAddress(d.Get("ip_address"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("ip_address"); !isEmptyValue(reflect.ValueOf(ipAddressProp)) && (ok || !reflect.DeepEqual(v, ipAddressProp)) { + obj["ipAddress"] = ipAddressProp + } + peerIpAddressProp, err := expandNestedComputeRouterBgpPeerPeerIpAddress(d.Get("peer_ip_address"), d, config) if err != nil { return err @@ -409,6 +417,14 @@ func resourceComputeRouterBgpPeerUpdate(d *schema.ResourceData, meta interface{} billingProject = project obj := make(map[string]interface{}) + + ipAddressProp, err := expandNestedComputeRouterBgpPeerIpAddress(d.Get("ip_address"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("ip_address"); !isEmptyValue(reflect.ValueOf(ipAddressProp)) && (ok || !reflect.DeepEqual(v, ipAddressProp)) { + obj["ipAddress"] = ipAddressProp + } + peerIpAddressProp, err := expandNestedComputeRouterBgpPeerPeerIpAddress(d.Get("peer_ip_address"), d, config) if err != nil { return err @@ -682,6 +698,9 @@ func expandNestedComputeRouterBgpPeerName(v interface{}, d TerraformResourceData func expandNestedComputeRouterBgpPeerInterface(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } +func expandNestedComputeRouterBgpPeerIpAddress(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} func expandNestedComputeRouterBgpPeerPeerIpAddress(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil diff --git a/website/docs/r/compute_router_peer.html.markdown b/website/docs/r/compute_router_peer.html.markdown index 84ffa1101ca..152b657ef1e 100644 --- a/website/docs/r/compute_router_peer.html.markdown +++ b/website/docs/r/compute_router_peer.html.markdown @@ -65,6 +65,22 @@ resource "google_compute_router_peer" "peer" { } ``` +## Example Usage - Router Peer specify IP address explicitly + + +```hcl +resource "google_compute_router_peer" "peer" { + name = "my-router-peer" + router = "my-router" + region = "us-central1" + ip_address = "169.254.1.1" + peer_ip_address = "169.254.1.2" + peer_asn = 65513 + advertised_route_priority = 100 + interface = "interface-1" +} +``` + ## Argument Reference The following arguments are supported: @@ -83,6 +99,10 @@ The following arguments are supported: (Required) Name of the interface the BGP peer is associated with. +* `ip_address` - + IP address of the interface inside Google Cloud Platform. + Only IPv4 is supported. + * `peer_ip_address` - (Required) IP address of the BGP interface outside Google Cloud Platform. @@ -169,10 +189,6 @@ In addition to the arguments listed above, the following computed attributes are * `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/routers/{{router}}/{{name}}` -* `ip_address` - - IP address of the interface inside Google Cloud Platform. - Only IPv4 is supported. - * `management_type` - The resource that configures and manages this BGP peer. * `MANAGED_BY_USER` is the default value and can be managed by