Skip to content

Commit

Permalink
network endpoint support long form ids for network endpoint groups (#…
Browse files Browse the repository at this point in the history
…3224) (#5838)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Mar 5, 2020
1 parent 105df44 commit 2ee6c9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/3224.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: Added support for full-name/id `network_endpoint_group` value in `google_network_endpoint`
```
5 changes: 4 additions & 1 deletion google/resource_compute_network_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ range).`,
Type: schema.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
DiffSuppressFunc: compareResourceNames,
Description: `The network endpoint group this endpoint is part of.`,
},
"port": {
Expand Down Expand Up @@ -332,6 +332,9 @@ func expandComputeNetworkEndpointIpAddress(v interface{}, d TerraformResourceDat
}

func resourceComputeNetworkEndpointEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
// Network Endpoint Group is a URL parameter only, so replace self-link/path with resource name only.
d.Set("network_endpoint_group", GetResourceNameFromSelfLink(d.Get("network_endpoint_group").(string)))

wrappedReq := map[string]interface{}{
"networkEndpoints": []interface{}{obj},
}
Expand Down
6 changes: 3 additions & 3 deletions google/resource_compute_network_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func testAccComputeNetworkEndpoint_networkEndpointsBasic(context map[string]inte
return Nprintf(`
resource "google_compute_network_endpoint" "default" {
zone = "us-central1-a"
network_endpoint_group = google_compute_network_endpoint_group.neg.name
network_endpoint_group = google_compute_network_endpoint_group.neg.id
instance = google_compute_instance.default.name
ip_address = google_compute_instance.default.network_interface[0].network_ip
Expand All @@ -107,7 +107,7 @@ func testAccComputeNetworkEndpoint_networkEndpointsAdditional(context map[string
return Nprintf(`
resource "google_compute_network_endpoint" "default" {
zone = "us-central1-a"
network_endpoint_group = google_compute_network_endpoint_group.neg.name
network_endpoint_group = google_compute_network_endpoint_group.neg.id
instance = google_compute_instance.default.name
ip_address = google_compute_instance.default.network_interface[0].network_ip
Expand All @@ -116,7 +116,7 @@ resource "google_compute_network_endpoint" "default" {
resource "google_compute_network_endpoint" "add1" {
zone = "us-central1-a"
network_endpoint_group = google_compute_network_endpoint_group.neg.name
network_endpoint_group = google_compute_network_endpoint_group.neg.id
instance = google_compute_instance.default.name
ip_address = google_compute_instance.default.network_interface[0].network_ip
Expand Down

0 comments on commit 2ee6c9c

Please sign in to comment.