diff --git a/build/terraform b/build/terraform index f9ce6c371963..03d11221a2aa 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit f9ce6c3719639844f7e1ac5c5f53253778b98229 +Subproject commit 03d11221a2aaf0bc8d99b2062d9a6f9c48a8f197 diff --git a/build/terraform-beta b/build/terraform-beta index 43396b2d74c4..af7ffa08ba8d 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit 43396b2d74c442973bad33a651fa9962943646da +Subproject commit af7ffa08ba8db498249c776facf8ac2b22a2dc1d diff --git a/build/terraform-mapper b/build/terraform-mapper index 4d4d7adf23e1..9d39879a6acc 160000 --- a/build/terraform-mapper +++ b/build/terraform-mapper @@ -1 +1 @@ -Subproject commit 4d4d7adf23e1097d41a559a034067548f06fb2e2 +Subproject commit 9d39879a6acced8eddcec3a102b4b6a21182759d diff --git a/products/compute/ansible.yaml b/products/compute/ansible.yaml index 261f26b036d2..2b9d5532ddfe 100644 --- a/products/compute/ansible.yaml +++ b/products/compute/ansible.yaml @@ -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 @@ -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 diff --git a/products/compute/api.yaml b/products/compute/api.yaml index f2bac49902ea..4d32361e415d 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -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 @@ -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/' diff --git a/products/compute/inspec.yaml b/products/compute/inspec.yaml index 7d5d73be19c7..eebfd5f35066 100644 --- a/products/compute/inspec.yaml +++ b/products/compute/inspec.yaml @@ -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 diff --git a/products/compute/terraform.yaml b/products/compute/terraform.yaml index d59e55652d90..c020a5a37aa3 100644 --- a/products/compute/terraform.yaml +++ b/products/compute/terraform.yaml @@ -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" @@ -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: diff --git a/templates/terraform/decoders/compute_network_endpoint.go.erb b/templates/terraform/decoders/compute_network_endpoint.go.erb deleted file mode 100644 index cffb41973d5a..000000000000 --- a/templates/terraform/decoders/compute_network_endpoint.go.erb +++ /dev/null @@ -1,51 +0,0 @@ -<%# 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. --%> -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 diff --git a/templates/terraform/decoders/unwrap_resource.go.erb b/templates/terraform/decoders/unwrap_resource.go.erb new file mode 100644 index 000000000000..92bb21dccb35 --- /dev/null +++ b/templates/terraform/decoders/unwrap_resource.go.erb @@ -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 diff --git a/templates/terraform/examples/network_endpoint.tf.erb b/templates/terraform/examples/network_endpoint.tf.erb index 878fc00fccf2..b8d8f0af9b96 100644 --- a/templates/terraform/examples/network_endpoint.tf.erb +++ b/templates/terraform/examples/network_endpoint.tf.erb @@ -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}" @@ -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}" @@ -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" -} - - - diff --git a/templates/terraform/examples/network_endpoint_group.tf.erb b/templates/terraform/examples/network_endpoint_group.tf.erb index dd3937bc68fa..db3200ee6ccf 100644 --- a/templates/terraform/examples/network_endpoint_group.tf.erb +++ b/templates/terraform/examples/network_endpoint_group.tf.erb @@ -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}" @@ -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" -} diff --git a/third_party/terraform/tests/resource_compute_network_endpoint_test.go.erb b/third_party/terraform/tests/resource_compute_network_endpoint_test.go.erb index d7943abd8459..c20e7d0f1cb9 100644 --- a/third_party/terraform/tests/resource_compute_network_endpoint_test.go.erb +++ b/third_party/terraform/tests/resource_compute_network_endpoint_test.go.erb @@ -1,6 +1,5 @@ <% autogen_exception -%> package google -<% unless version == 'ga' -%> import ( "fmt" "testing" @@ -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 -%>