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

Allow setting ip_address of bgp router peer #3565

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
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-beta/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-beta/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
2 changes: 1 addition & 1 deletion google-beta/resource_gke_hub_feature_membership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
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