Repository: GoogleCloudPlatform/terraform-validator
Pull request #405 (2021-11-24 18:32:46)

Add a resource mapping for google_compute_global_address
<!-- Put a description of what this PR is for here, along with any references to issues that this resolves or contributes to -->

Add a resource mapping for google_compute_global_address


<!--
Replace each [ ] with [X] to check it. Switch to the preview view to make it easier to click on links.
These steps will speed up the review process, and we appreciate you spending time on them before sending
your code to be reviewed.
-->
If this PR is for Terraform, I acknowledge that I have:

- [X] Searched through the [issue tracker](https://github.com/hashicorp/terraform-provider-google/issues) for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
- [ ] [Generated Terraform](https://github.com/GoogleCloudPlatform/magic-modules#generating-downstream-tools), and ran `make test` and `make lint` to ensure it passes unit and linter tests.
- [ ] Ensured that all new fields I added that can be set by a user appear in at least one [example](https://github.com/GoogleCloudPlatform/magic-modules/tree/master/templates/terraform/examples) (for generated resources) or [third_party test](https://github.com/GoogleCloudPlatform/magic-modules/tree/master/third_party/terraform/tests) (for handwritten resources or update tests).
- [X] [Ran](https://github.com/hashicorp/terraform-provider-google/blob/master/.github/CONTRIBUTING.md#tests) relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
- [X] Read the [Release Notes Guide](https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md) before writing my release note below.

<!-- AUTOCHANGELOG for Downstream PRs.

Please select one of the following "release-note:" headings:
    - release-note:enhancement
    - release-note:bug
    - release-note:note
    - release-note:new-resource
    - release-note:new-datasource
    - release-note:deprecation
    - release-note:breaking-change
    - release-note:none
    
Unless you choose release-note:none, please add a release note.

See .ci/RELEASE_NOTES_GUIDE.md for writing good release notes.

You can add more release note blocks if you want more than one CHANGELOG
entry for this PR.
-->
**Release Note Template for Downstream PRs (will be copied)**

```release-note:enhancement
Add a resource mapping for google_compute_global_address
```

Derived from https://github.com/GoogleCloudPlatform/magic-modules/pull/5475


Patch:
diff --git a/converters/google/resources/resource_converters.go b/converters/google/resources/resource_converters.go
index 3c0956a1..254dd725 100644
--- a/converters/google/resources/resource_converters.go
+++ b/converters/google/resources/resource_converters.go
@@ -26,6 +26,7 @@ func ResourceConverters() map[string][]ResourceConverter {
 		"google_compute_firewall":                          {resourceConverterComputeFirewall()},
 		"google_compute_disk":                              {resourceConverterComputeDisk()},
 		"google_compute_forwarding_rule":                   {resourceConverterComputeForwardingRule()},
+		"google_compute_global_address":                    {resourceConverterComputeGlobalAddress()},
 		"google_compute_global_forwarding_rule":            {resourceConverterComputeGlobalForwardingRule()},
 		"google_compute_instance":                          {resourceConverterComputeInstance()},
 		"google_compute_network":                           {resourceConverterComputeNetwork()},


Test patch:
diff --git a/test/cli_test.go b/test/cli_test.go
index 451d14e6..9f71a0e3 100644
--- a/test/cli_test.go
+++ b/test/cli_test.go
@@ -82,6 +82,7 @@ func TestCLI(t *testing.T) {
 		{name: "example_compute_disk"},
 		{name: "example_compute_disk_empty_image"},
 		{name: "example_compute_firewall"},
+		{name: "example_compute_global_address"},
 		{name: "example_compute_global_forwarding_rule"},
 		{name: "example_compute_network"},
 		{name: "example_compute_snapshot"},
diff --git a/test/read_test.go b/test/read_test.go
index 77bb9988..2eca939e 100644
--- a/test/read_test.go
+++ b/test/read_test.go
@@ -41,6 +41,7 @@ func TestReadPlannedAssetsCoverage(t *testing.T) {
 		{name: "example_compute_disk"},
 		{name: "example_compute_disk_empty_image"},
 		{name: "example_compute_firewall"},
+		{name: "example_compute_global_address"},
 		{name: "example_compute_global_forwarding_rule"},
 		{name: "example_compute_network"},
 		{name: "example_compute_snapshot"},
diff --git a/testdata/templates/example_compute_global_address.json b/testdata/templates/example_compute_global_address.json
new file mode 100644
index 00000000..5ce52dd7
--- /dev/null
+++ b/testdata/templates/example_compute_global_address.json
@@ -0,0 +1,17 @@
+[
+  {
+    "name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/addresses/global-appserver-ip",
+    "asset_type": "compute.googleapis.com/GlobalAddress",
+    "ancestry_path": "{{.Ancestry}}/project/{{.Provider.project}}",
+    "resource": {
+      "version": "v1",
+      "discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest",
+      "discovery_name": "GlobalAddress",
+      "parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}",
+      "data": {
+        "addressType": "EXTERNAL",
+        "name": "global-appserver-ip"
+      }
+    }
+  }
+]
diff --git a/testdata/templates/example_compute_global_address.tf b/testdata/templates/example_compute_global_address.tf
new file mode 100644
index 00000000..e3ea697b
--- /dev/null
+++ b/testdata/templates/example_compute_global_address.tf
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2021 Google LLC
+ *
+ * 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.
+ */
+
+terraform {
+  required_providers {
+    google = {
+      source = "hashicorp/google"
+      version = "~> {{.Provider.version}}"
+    }
+  }
+}
+
+provider "google" {
+  {{if .Provider.credentials }}credentials = "{{.Provider.credentials}}"{{end}}
+}
+
+resource "google_compute_global_address" "default" {
+  name = "global-appserver-ip"
+}
diff --git a/testdata/templates/example_compute_global_address.tfplan.json b/testdata/templates/example_compute_global_address.tfplan.json
new file mode 100644
index 00000000..d81a2a43
--- /dev/null
+++ b/testdata/templates/example_compute_global_address.tfplan.json
@@ -0,0 +1,92 @@
+{
+  "format_version": "0.2",
+  "terraform_version": "1.0.10",
+  "planned_values": {
+    "root_module": {
+      "resources": [
+        {
+          "address": "google_compute_global_address.default",
+          "mode": "managed",
+          "type": "google_compute_global_address",
+          "name": "default",
+          "provider_name": "registry.terraform.io/hashicorp/google",
+          "schema_version": 0,
+          "values": {
+            "address_type": null,
+            "description": null,
+            "ip_version": null,
+            "name": "global-appserver-ip",
+            "network": null,
+            "prefix_length": null,
+            "purpose": null,
+            "timeouts": null
+          },
+          "sensitive_values": {}
+        }
+      ]
+    }
+  },
+  "resource_changes": [
+    {
+      "address": "google_compute_global_address.default",
+      "mode": "managed",
+      "type": "google_compute_global_address",
+      "name": "default",
+      "provider_name": "registry.terraform.io/hashicorp/google",
+      "change": {
+        "actions": [
+          "create"
+        ],
+        "before": null,
+        "after": {
+          "address_type": null,
+          "description": null,
+          "ip_version": null,
+          "name": "global-appserver-ip",
+          "network": null,
+          "prefix_length": null,
+          "purpose": null,
+          "timeouts": null
+        },
+        "after_unknown": {
+          "address": true,
+          "creation_timestamp": true,
+          "id": true,
+          "project": true,
+          "self_link": true
+        },
+        "before_sensitive": false,
+        "after_sensitive": {}
+      }
+    }
+  ],
+  "configuration": {
+    "provider_config": {
+      "google": {
+        "name": "google",
+        "expressions": {
+          "project": {
+            "constant_value": "{{.Provider.project}}"
+          }
+        }
+      }
+    },
+    "root_module": {
+      "resources": [
+        {
+          "address": "google_compute_global_address.default",
+          "mode": "managed",
+          "type": "google_compute_global_address",
+          "name": "default",
+          "provider_config_key": "google",
+          "expressions": {
+            "name": {
+              "constant_value": "global-appserver-ip"
+            }
+          },
+          "schema_version": 0
+        }
+      ]
+    }
+  }
+}
diff --git a/testdata/templates/full_sql_database_instance.json b/testdata/templates/full_sql_database_instance.json
index c9b4f83d..2ddd7a7a 100644
--- a/testdata/templates/full_sql_database_instance.json
+++ b/testdata/templates/full_sql_database_instance.json
@@ -31,13 +31,12 @@
         },
         "settings": {
           "activationPolicy": "test-activation_policy",
-
           "availabilityType": "REGIONAL",
           "backupConfiguration": {
             "binaryLogEnabled": true,
             "enabled": true,
-            "startTime": "42:42",
-            "location": "us"
+            "location": "us",
+            "startTime": "42:42"
           },
           "dataDiskSizeGb": "42",
           "dataDiskType": "test-disk_type",
@@ -86,6 +85,23 @@
       }
     }
   },
+  {
+    "name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/addresses/private-ip-address",
+    "asset_type": "compute.googleapis.com/GlobalAddress",
+    "ancestry_path": "{{.Ancestry}}/project/{{.Provider.project}}",
+    "resource": {
+      "version": "v1",
+      "discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest",
+      "discovery_name": "GlobalAddress",
+      "parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}",
+      "data": {
+        "addressType": "INTERNAL",
+        "name": "private-ip-address",
+        "prefixLength": 16,
+        "purpose": "VPC_PEERING"
+      }
+    }
+  },
   {
     "name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/networks/private-network",
     "asset_type": "compute.googleapis.com/Network",