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

Enable to specify ip_address in resource_compute_rooter_peer #9816

Closed
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
19 changes: 19 additions & 0 deletions google/resource_compute_router_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions website/docs/r/compute_router_peer.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down