Skip to content

Commit

Permalink
Allow setting ip_address of bgp router peer (#5098) (#9913)
Browse files Browse the repository at this point in the history
* Allow setting ip_address of bgp router peer

* Mark O+C

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Aug 25, 2021
1 parent a97289f commit 4692b94
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .changelog/5098.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: allowed setting `ip_address` field of `google_compute_router_peer`
```
1 change: 1 addition & 0 deletions google/resource_compute_router_bgp_peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ resource "google_compute_router_peer" "foobar" {
name = "%s"
router = google_compute_router.foobar.name
region = google_compute_router.foobar.region
ip_address = "169.254.3.1"
peer_ip_address = "169.254.3.2"
peer_asn = 65515
advertised_route_priority = 100
Expand Down
29 changes: 23 additions & 6 deletions google/resource_compute_router_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ If set to true, the peer connection can be established with routing information.
The default is true.`,
Default: true,
},
"ip_address": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `IP address of the interface inside Google Cloud Platform.
Only IPv4 is supported.`,
},
"region": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -157,12 +164,6 @@ The default is true.`,
DiffSuppressFunc: compareSelfLinkOrResourceName,
Description: `Region where the router and BgpPeer reside.
If it is not provided, the provider region is used.`,
},
"ip_address": {
Type: schema.TypeString,
Computed: true,
Description: `IP address of the interface inside Google Cloud Platform.
Only IPv4 is supported.`,
},
"management_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -209,6 +210,12 @@ 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
Expand Down Expand Up @@ -409,6 +416,12 @@ 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(v)) && (ok || !reflect.DeepEqual(v, ipAddressProp)) {
obj["ipAddress"] = ipAddressProp
}
peerIpAddressProp, err := expandNestedComputeRouterBgpPeerPeerIpAddress(d.Get("peer_ip_address"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -683,6 +696,10 @@ func expandNestedComputeRouterBgpPeerInterface(v interface{}, d TerraformResourc
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
}
Expand Down
9 changes: 5 additions & 4 deletions website/docs/r/compute_router_peer.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ The following arguments are supported:
- - -


* `ip_address` -
(Optional)
IP address of the interface inside Google Cloud Platform.
Only IPv4 is supported.

* `advertised_route_priority` -
(Optional)
The priority of routes advertised to this BGP peer.
Expand Down Expand Up @@ -169,10 +174,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
Expand Down

0 comments on commit 4692b94

Please sign in to comment.