Repository: GoogleCloudPlatform/terraform-validator
Pull request #1245 (2023-01-03 22:22:15)

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

Add google_compute_target_ssl_proxy for terraform validator
The converter is already generated, just adding a line into the converter list and add test cases

Referring to https://github.com/GoogleCloudPlatform/terraform-validator/issues/1214

<!--
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:

- [ ] 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-the-terraform-providers), and ran `make test` and `make lint` to ensure it passes unit and linter tests.
- [X] 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/main/mmv1/templates/terraform/examples) (for generated resources) or [third_party test](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/tests) (for handwritten resources or update tests).
- [ ] [Ran](https://github.com/hashicorp/terraform-provider-google/blob/main/.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/main/.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
compute: added `terraform validator` support to `google_compute_target_ssl_proxy`
```

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


Patch:
diff --git a/converters/google/resources/resource_converters.go b/converters/google/resources/resource_converters.go
index 3209bfed..2aefcc74 100644
--- a/converters/google/resources/resource_converters.go
+++ b/converters/google/resources/resource_converters.go
@@ -35,6 +35,7 @@ func ResourceConverters() map[string][]ResourceConverter {
 		"google_compute_snapshot":                                 {resourceConverterComputeSnapshot()},
 		"google_compute_subnetwork":                               {resourceConverterComputeSubnetwork()},
 		"google_compute_ssl_policy":                               {resourceConverterComputeSslPolicy()},
+		"google_compute_target_ssl_proxy":                         {resourceConverterComputeTargetSslProxy()},
 		"google_dns_managed_zone":                                 {resourceConverterDNSManagedZone()},
 		"google_dns_policy":                                       {resourceConverterDNSPolicy()},
 		"google_storage_bucket":                                   {resourceConverterStorageBucket()},


Test patch:
diff --git a/test/cli_test.go b/test/cli_test.go
index c2356aaa..781c5315 100644
--- a/test/cli_test.go
+++ b/test/cli_test.go
@@ -97,6 +97,7 @@ func TestCLI(t *testing.T) {
 		{name: "example_compute_snapshot"},
 		{name: "example_compute_ssl_policy"},
 		{name: "example_compute_subnetwork"},
+		{name: "example_compute_target_ssl_proxy"},
 		{name: "example_container_cluster"},
 		{name: "example_dns_managed_zone"},
 		{name: "example_dns_policy"},
diff --git a/test/read_test.go b/test/read_test.go
index 54cf6413..959a2fa8 100644
--- a/test/read_test.go
+++ b/test/read_test.go
@@ -59,6 +59,7 @@ func TestReadPlannedAssetsCoverage(t *testing.T) {
 		{name: "example_compute_snapshot"},
 		{name: "example_compute_ssl_policy"},
 		{name: "example_compute_subnetwork"},
+		{name: "example_compute_target_ssl_proxy"},
 		{name: "example_container_cluster"},
 		{name: "example_dns_managed_zone"},
 		{name: "example_dns_policy"},
diff --git a/testdata/templates/example_compute_target_ssl_proxy.json b/testdata/templates/example_compute_target_ssl_proxy.json
new file mode 100644
index 00000000..31ac8a7c
--- /dev/null
+++ b/testdata/templates/example_compute_target_ssl_proxy.json
@@ -0,0 +1,22 @@
+[
+  {
+    "name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/targetSslProxies/target-ssl-proxy",
+    "asset_type": "compute.googleapis.com/TargetSslProxy",
+    "ancestry_path": "{{.Ancestry}}/project/{{.Provider.project}}",
+    "resource": {
+      "version": "v1",
+      "discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest",
+      "discovery_name": "TargetSslProxy",
+      "parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}",
+      "data": {
+        "name": "target-ssl-proxy",
+        "proxyHeader": "NONE",
+        "service": "projects/{{.Provider.project}}/global/backendServices/backend_service_id",
+        "sslCertificates": [
+            "projects/{{.Provider.project}}/global/sslCertificates/ssl_certificate_id"
+        ],
+        "sslPolicy": "projects/{{.Provider.project}}/global/sslPolicies/ssl-policy-id"
+      }
+    }
+  }
+]
\ No newline at end of file
diff --git a/testdata/templates/example_compute_target_ssl_proxy.tf b/testdata/templates/example_compute_target_ssl_proxy.tf
new file mode 100644
index 00000000..42284afd
--- /dev/null
+++ b/testdata/templates/example_compute_target_ssl_proxy.tf
@@ -0,0 +1,35 @@
+/**
+ * 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_target_ssl_proxy" "target-ssl-proxy" {
+  name             = "target-ssl-proxy"
+  backend_service  = "backend_service_id"
+  ssl_certificates = ["ssl_certificate_id"]
+  ssl_policy       = "ssl-policy-id"
+}
diff --git a/testdata/templates/example_compute_target_ssl_proxy.tfplan.json b/testdata/templates/example_compute_target_ssl_proxy.tfplan.json
new file mode 100644
index 00000000..858ad184
--- /dev/null
+++ b/testdata/templates/example_compute_target_ssl_proxy.tfplan.json
@@ -0,0 +1,122 @@
+{
+  "format_version": "1.1",
+  "terraform_version": "1.3.6",
+  "planned_values": {
+      "root_module": {
+          "resources": [
+              {
+                  "address": "google_compute_target_ssl_proxy.target-ssl-proxy",
+                  "mode": "managed",
+                  "type": "google_compute_target_ssl_proxy",
+                  "name": "target-ssl-proxy",
+                  "provider_name": "registry.terraform.io/hashicorp/google",
+                  "schema_version": 0,
+                  "values": {
+                      "backend_service": "backend_service_id",
+                      "certificate_map": null,
+                      "description": null,
+                      "name": "target-ssl-proxy",
+                      "proxy_header": "NONE",
+                      "ssl_certificates": [
+                          "ssl_certificate_id"
+                      ],
+                      "ssl_policy": "ssl-policy-id",
+                      "timeouts": null
+                  },
+                  "sensitive_values": {
+                      "ssl_certificates": [
+                          false
+                      ]
+                  }
+              }
+          ]
+      }
+  },
+  "resource_changes": [
+      {
+          "address": "google_compute_target_ssl_proxy.target-ssl-proxy",
+          "mode": "managed",
+          "type": "google_compute_target_ssl_proxy",
+          "name": "target-ssl-proxy",
+          "provider_name": "registry.terraform.io/hashicorp/google",
+          "change": {
+              "actions": [
+                  "create"
+              ],
+              "before": null,
+              "after": {
+                  "backend_service": "backend_service_id",
+                  "certificate_map": null,
+                  "description": null,
+                  "name": "target-ssl-proxy",
+                  "proxy_header": "NONE",
+                  "ssl_certificates": [
+                      "ssl_certificate_id"
+                  ],
+                  "ssl_policy": "ssl-policy-id",
+                  "timeouts": null
+              },
+              "after_unknown": {
+                  "creation_timestamp": true,
+                  "id": true,
+                  "project": true,
+                  "proxy_id": true,
+                  "self_link": true,
+                  "ssl_certificates": [
+                      false
+                  ]
+              },
+              "before_sensitive": false,
+              "after_sensitive": {
+                  "ssl_certificates": [
+                      false
+                  ]
+              }
+          }
+      }
+  ],
+  "configuration": {
+      "provider_config": {
+          "google": {
+              "name": "google",
+              "full_name": "registry.terraform.io/hashicorp/google",
+              "expressions": {
+                  "project": {
+                      "constant_value": "cncac-demo-env"
+                  },
+                  "region": {
+                      "constant_value": "asia-southeast-1"
+                  }
+              }
+          }
+      },
+      "root_module": {
+          "resources": [
+              {
+                  "address": "google_compute_target_ssl_proxy.target-ssl-proxy",
+                  "mode": "managed",
+                  "type": "google_compute_target_ssl_proxy",
+                  "name": "target-ssl-proxy",
+                  "provider_config_key": "google",
+                  "expressions": {
+                      "backend_service": {
+                          "constant_value": "backend_service_id"
+                      },
+                      "name": {
+                          "constant_value": "target-ssl-proxy"
+                      },
+                      "ssl_certificates": {
+                          "constant_value": [
+                              "ssl_certificate_id"
+                          ]
+                      },
+                      "ssl_policy": {
+                          "constant_value": "ssl-policy-id"
+                      }
+                  },
+                  "schema_version": 0
+              }
+          ]
+      }
+  }
+}
\ No newline at end of file