Skip to content

Commit

Permalink
Enable network endpoint groups and endpoints in GA (#836)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and emilymye committed Jun 14, 2019
1 parent 43396b2 commit af7ffa0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 79 deletions.
33 changes: 1 addition & 32 deletions google-beta/resource_compute_network_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,41 +397,10 @@ func flattenNestedComputeNetworkEndpoint(d *schema.ResourceData, meta interface{
}

func resourceComputeNetworkEndpointDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
transformed := map[string]interface{}{}

v, ok := res["networkEndpoint"]
if !ok || v == nil {
return res, nil
}

networkEndpt := v.(map[string]interface{})
for k, v := range networkEndpt {
transformed[k] = v
}

v, ok = res["healths"]
if !ok || res == nil {
return transformed, nil
}

healths := v.(map[string]interface{})
if v, ok := healths["forwardingRule"]; ok {
frobj := v.(map[string]interface{})
if frv, ok := frobj["forwardingRule"]; ok {
transformed["healthForwardingRule"] = frv
}
}
if v, ok := healths["backendService"]; ok {
frobj := v.(map[string]interface{})
if frv, ok := frobj["backendService"]; ok {
transformed["healthBackendService"] = frv
}
}
if v, ok := healths["healthCheck"]; ok {
frobj := v.(map[string]interface{})
if frv, ok := frobj["healthCheck"]; ok {
transformed["healthCheck"] = frv
}
}
return transformed, nil
return v.(map[string]interface{}), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ func TestAccComputeNetworkEndpointGroup_networkEndpointGroupExample(t *testing.T

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProvidersOiCS,
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeNetworkEndpointGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeNetworkEndpointGroup_networkEndpointGroupExample(context),
},
{
ResourceName: "google_compute_network_endpoint_group.neg",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeNetworkEndpointGroup_networkEndpointGroupExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_network_endpoint_group" "neg" {
provider = "google-beta"
name = "my-lb-neg-%{random_suffix}"
network = "${google_compute_network.default.self_link}"
subnetwork = "${google_compute_subnetwork.default.self_link}"
Expand All @@ -56,25 +59,16 @@ resource "google_compute_network_endpoint_group" "neg" {
}
resource "google_compute_network" "default" {
provider = "google-beta"
name = "neg-network-%{random_suffix}"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "default" {
provider = "google-beta"
name = "neg-subnetwork-%{random_suffix}"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = "${google_compute_network.default.self_link}"
}
provider "google-beta" {
region = "us-central1"
zone = "us-central1-a"
}
`, context)
}

Expand Down
23 changes: 4 additions & 19 deletions website/docs/r/compute_network_endpoint.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ collection of these endpoints for GCP resources within a
single subnet. **NOTE**: Network endpoints cannot be created outside of a
network endpoint group.

~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/provider_versions.html) for more details on beta resources.

To get more information about NetworkEndpoint, see:

Expand All @@ -42,8 +40,6 @@ To get more information about NetworkEndpoint, see:

```hcl
resource "google_compute_network_endpoint" "default-endpoint {
provider = "google-beta"
network_endpoint_group = "${google_compute_network_endpoint_group.neg.name}"
instance = "${google_compute_instance.endpoint-instance.name}"
Expand Down Expand Up @@ -73,8 +69,6 @@ resource "google_compute_instance" "endpoint-instance" {
}
resource "google_compute_network_endpoint_group" "group" {
provider = "google-beta"
name = "my-lb-neg"
network = "${google_compute_network.default.self_link}"
subnetwork = "${google_compute_subnetwork.default.self_link}"
Expand All @@ -83,25 +77,16 @@ resource "google_compute_network_endpoint_group" "group" {
}
resource "google_compute_network" "default" {
provider = "google-beta"
name = "neg-network"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "default" {
provider = "google-beta"
name = "neg-subnetwork"
ip_cidr_range = "10.0.0.1/16"
region = "us-central1"
network = "${google_compute_network.default.self_link}"
}
provider "google-beta" {
region = "us-central1"
zone = "us-central1-a"
}
```

## Argument Reference
Expand Down Expand Up @@ -155,10 +140,10 @@ This resource provides the following
NetworkEndpoint can be imported using any of these accepted formats:

```
$ terraform import -provider=google-beta google_compute_network_endpoint.default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/{{name}}
$ terraform import -provider=google-beta google_compute_network_endpoint.default {{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
$ terraform import -provider=google-beta google_compute_network_endpoint.default {{project}}/{{zone}}/{{network_endpoint_group}}/{{name}}
$ terraform import -provider=google-beta google_compute_network_endpoint.default {{network_endpoint_group}}/{{name}}
$ terraform import google_compute_network_endpoint.default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/{{name}}
$ terraform import google_compute_network_endpoint.default {{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
$ terraform import google_compute_network_endpoint.default {{project}}/{{zone}}/{{network_endpoint_group}}/{{name}}
$ terraform import google_compute_network_endpoint.default {{network_endpoint_group}}/{{name}}
```

-> If you're importing a resource with beta features, make sure to include `-provider=google-beta`
Expand Down
19 changes: 3 additions & 16 deletions website/docs/r/compute_network_endpoint_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ backend with internal load balancers. Because NEG backends allow you to
specify IP addresses and ports, you can distribute traffic in a granular
fashion among applications or containers running within VM instances.

~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/provider_versions.html) for more details on beta resources.

To get more information about NetworkEndpointGroup, see:

Expand All @@ -53,8 +51,6 @@ To get more information about NetworkEndpointGroup, see:

```hcl
resource "google_compute_network_endpoint_group" "neg" {
provider = "google-beta"
name = "my-lb-neg"
network = "${google_compute_network.default.self_link}"
subnetwork = "${google_compute_subnetwork.default.self_link}"
Expand All @@ -63,25 +59,16 @@ resource "google_compute_network_endpoint_group" "neg" {
}
resource "google_compute_network" "default" {
provider = "google-beta"
name = "neg-network"
auto_create_subnetworks = false
}
resource "google_compute_subnetwork" "default" {
provider = "google-beta"
name = "neg-subnetwork"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = "${google_compute_network.default.self_link}"
}
provider "google-beta" {
region = "us-central1"
zone = "us-central1-a"
}
```

## Argument Reference
Expand Down Expand Up @@ -157,9 +144,9 @@ This resource provides the following
NetworkEndpointGroup can be imported using any of these accepted formats:

```
$ terraform import -provider=google-beta google_compute_network_endpoint_group.default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}
$ terraform import -provider=google-beta google_compute_network_endpoint_group.default {{project}}/{{zone}}/{{name}}
$ terraform import -provider=google-beta google_compute_network_endpoint_group.default {{name}}
$ terraform import google_compute_network_endpoint_group.default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}
$ terraform import google_compute_network_endpoint_group.default {{project}}/{{zone}}/{{name}}
$ terraform import google_compute_network_endpoint_group.default {{name}}
```

-> If you're importing a resource with beta features, make sure to include `-provider=google-beta`
Expand Down

0 comments on commit af7ffa0

Please sign in to comment.