Skip to content

Commit

Permalink
Enable network endpoint groups and endpoints in GA (#1905)
Browse files Browse the repository at this point in the history
Merged PR #1905.
  • Loading branch information
emilymye authored and modular-magician committed Jun 14, 2019
1 parent 515ffcc commit 772d0da
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 93 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
2 changes: 1 addition & 1 deletion build/terraform-mapper
8 changes: 8 additions & 0 deletions products/compute/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ datasources: !ruby/object:Overrides::ResourceOverrides
exclude: true
MachineType: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NetworkEndpoint: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NetworkEndpointGroup: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NodeGroup: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NodeTemplate: !ruby/object:Overrides::Ansible::ResourceOverride
Expand Down Expand Up @@ -252,6 +256,10 @@ overrides: !ruby/object:Overrides::ResourceOverrides
exclude: true
MachineType: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NetworkEndpoint: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NetworkEndpointGroup: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NodeGroup: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
NodeTemplate: !ruby/object:Overrides::Ansible::ResourceOverride
Expand Down
2 changes: 0 additions & 2 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4898,7 +4898,6 @@ objects:
single subnet. **NOTE**: Network endpoints cannot be created outside of a
network endpoint group.
input: true
min_version: beta
create_verb: :POST
create_url: projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/attachNetworkEndpoints
delete_verb: :POST
Expand Down Expand Up @@ -4978,7 +4977,6 @@ objects:
kind: 'compute#networkEndpointGroup'
base_url: 'projects/{{project}}/zones/{{zone}}/networkEndpointGroups'
input: true
min_version: beta
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation': 'https://cloud.google.com/load-balancing/docs/negs/'
Expand Down
4 changes: 4 additions & 0 deletions products/compute/inspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ overrides: !ruby/object:Overrides::ResourceOverrides
exclude: true
Network: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
NetworkEndpoint: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
NetworkEndpointGroup: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
NodeGroup: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
NodeTemplate: !ruby/object:Overrides::Inspec::ResourceOverride
Expand Down
14 changes: 8 additions & 6 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -774,15 +774,17 @@ overrides: !ruby/object:Overrides::ResourceOverrides
NetworkEndpoint: !ruby/object:Overrides::Terraform::ResourceOverride
id_format: "{{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}"
mutex: networkEndpoint/{{project}}/{{zone}}/{{network_endpoint_group}}
# Fine-grained resources don't actually exist as standalone GCP resource
# in Cloud Asset Inventory
exclude_validator: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "network_endpoint"
primary_resource_id: "default-endpoint"
# Autogenerated tests currently don't work well with
# fine-grained resources where we need to check destroy
# during a test step where the parent resource still exists,
# rather than during CheckDestroy (when the parent resource has
# then also been destroyed)
# Fine-grained resource need diffferent autogenerated tests, as
# we need to check destroy during a test step where the parent resource
# still exists, rather than during CheckDestroy (when read returns
# nothing because the parent resource has then also been destroyed)
skip_test: true
vars:
neg_name: "my-lb-neg"
Expand All @@ -802,7 +804,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
ignore_read: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
pre_delete: templates/terraform/pre_delete/compute_network_endpoint.go.erb
decoder: templates/terraform/decoders/compute_network_endpoint.go.erb
decoder: templates/terraform/decoders/unwrap_resource.go.erb
encoder: templates/terraform/encoders/compute_network_endpoint.go.erb
NetworkEndpointGroup: !ruby/object:Overrides::Terraform::ResourceOverride
examples:
Expand Down
51 changes: 0 additions & 51 deletions templates/terraform/decoders/compute_network_endpoint.go.erb

This file was deleted.

20 changes: 20 additions & 0 deletions templates/terraform/decoders/unwrap_resource.go.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%# The license inside this block applies to this file.
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-%>
v, ok := res["<%= object.name.camelize(:lower) %>"]
if !ok || v == nil {
return res, nil
}

return v.(map[string]interface{}), nil
16 changes: 0 additions & 16 deletions templates/terraform/examples/network_endpoint.tf.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
resource "google_compute_network_endpoint" "<%= ctx[:primary_resource_id] %> {
provider = "google-beta"

network_endpoint_group = "${google_compute_network_endpoint_group.neg.name}"

instance = "${google_compute_instance.endpoint-instance.name}"
Expand Down Expand Up @@ -30,8 +28,6 @@ resource "google_compute_instance" "endpoint-instance" {
}

resource "google_compute_network_endpoint_group" "group" {
provider = "google-beta"

name = "<%= ctx[:vars]['neg_name'] %>"
network = "${google_compute_network.default.self_link}"
subnetwork = "${google_compute_subnetwork.default.self_link}"
Expand All @@ -40,25 +36,13 @@ resource "google_compute_network_endpoint_group" "group" {
}

resource "google_compute_network" "default" {
provider = "google-beta"

name = "<%= ctx[:vars]['network_name'] %>"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "default" {
provider = "google-beta"

name = "<%= ctx[:vars]['subnetwork_name'] %>"
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"
}



11 changes: 0 additions & 11 deletions templates/terraform/examples/network_endpoint_group.tf.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
resource "google_compute_network_endpoint_group" "<%= ctx[:primary_resource_id] %>" {
provider = "google-beta"

name = "<%= ctx[:vars]['neg_name'] %>"
network = "${google_compute_network.default.self_link}"
subnetwork = "${google_compute_subnetwork.default.self_link}"
Expand All @@ -9,22 +7,13 @@ resource "google_compute_network_endpoint_group" "<%= ctx[:primary_resource_id]
}

resource "google_compute_network" "default" {
provider = "google-beta"

name = "<%= ctx[:vars]['network_name'] %>"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "default" {
provider = "google-beta"

name = "<%= ctx[:vars]['subnetwork_name'] %>"
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"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<% autogen_exception -%>
package google
<% unless version == 'ga' -%>
import (
"fmt"
"testing"
Expand Down Expand Up @@ -248,6 +247,3 @@ func testAccComputeNetworkEndpointsListEndpointPorts(negId string) (map[string]s
}
return ports, nil
}
<% else -%>
// Magic Modules doesn't let us remove files - blank out beta-only common-compile files for now.
<% end -%>

0 comments on commit 772d0da

Please sign in to comment.