From 0ff6d6f1cc19f70a6cd980ebe8fabf2bcae35d41 Mon Sep 17 00:00:00 2001 From: Iris Chen <10179943+iyabchen@users.noreply.github.com> Date: Wed, 1 Dec 2021 11:50:10 -0500 Subject: [PATCH] Add support for google_redis_instance (#5496) --- .../validator/resource_converters.go.erb | 1 + .../tests/data/example_redis_instance.json | 44 ++++ .../tests/data/example_redis_instance.tf | 52 +++++ .../data/example_redis_instance.tfplan.json | 220 ++++++++++++++++++ 4 files changed, 317 insertions(+) create mode 100644 mmv1/third_party/validator/tests/data/example_redis_instance.json create mode 100644 mmv1/third_party/validator/tests/data/example_redis_instance.tf create mode 100644 mmv1/third_party/validator/tests/data/example_redis_instance.tfplan.json diff --git a/mmv1/templates/validator/resource_converters.go.erb b/mmv1/templates/validator/resource_converters.go.erb index ec45725151e5..58d5e954b5a2 100644 --- a/mmv1/templates/validator/resource_converters.go.erb +++ b/mmv1/templates/validator/resource_converters.go.erb @@ -54,6 +54,7 @@ func ResourceConverters() map[string][]ResourceConverter { "google_bigquery_dataset_iam_binding": {resourceConverterBigqueryDatasetIamBinding()}, "google_bigquery_dataset_iam_member": {resourceConverterBigqueryDatasetIamMember()}, "google_bigquery_table": {resourceConverterBigQueryTable()}, + "google_redis_instance": {resourceConverterRedisInstance()}, "google_spanner_database": {resourceConverterSpannerDatabase()}, "google_spanner_database_iam_policy": {resourceConverterSpannerDatabaseIamPolicy()}, "google_spanner_database_iam_binding": {resourceConverterSpannerDatabaseIamBinding()}, diff --git a/mmv1/third_party/validator/tests/data/example_redis_instance.json b/mmv1/third_party/validator/tests/data/example_redis_instance.json new file mode 100644 index 000000000000..c767a295902f --- /dev/null +++ b/mmv1/third_party/validator/tests/data/example_redis_instance.json @@ -0,0 +1,44 @@ +[ + { + "name": "//compute.googleapis.com/projects/{{.Provider.project}}/global/networks/redis-test-network", + "asset_type": "compute.googleapis.com/Network", + "ancestry_path": "{{.Ancestry}}/project/{{.Provider.project}}", + "resource": { + "version": "v1", + "discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest", + "discovery_name": "Network", + "parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}", + "data": { + "autoCreateSubnetworks": true, + "name": "redis-test-network" + } + } + }, + { + "name": "//redis.googleapis.com/projects/{{.Provider.project}}/locations/us-central1/instances/ha-memory-cache", + "asset_type": "redis.googleapis.com/Instance", + "ancestry_path": "{{.Ancestry}}/project/{{.Provider.project}}", + "resource": { + "version": "v1", + "discovery_document_uri": "https://www.googleapis.com/discovery/v1/apis/redis/v1/rest", + "discovery_name": "Instance", + "parent": "//cloudresourcemanager.googleapis.com/projects/{{.Provider.project}}", + "data": { + "alternativeLocationId": "us-central1-f", + "connectMode": "DIRECT_PEERING", + "displayName": "Terraform Test Instance", + "labels": { + "my_key": "my_val", + "other_key": "other_val" + }, + "locationId": "us-central1-a", + "memorySizeGb": 1, + "name": "projects/{{.Provider.project}}/locations/us-central1/instances/ha-memory-cache", + "redisVersion": "REDIS_4_0", + "reservedIpRange": "192.168.0.0/29", + "tier": "STANDARD_HA", + "transitEncryptionMode": "DISABLED" + } + } + } +] diff --git a/mmv1/third_party/validator/tests/data/example_redis_instance.tf b/mmv1/third_party/validator/tests/data/example_redis_instance.tf new file mode 100644 index 000000000000..4ac28c6ddcb3 --- /dev/null +++ b/mmv1/third_party/validator/tests/data/example_redis_instance.tf @@ -0,0 +1,52 @@ +/** + * 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_network" "redis-network" { + name = "redis-test-network" +} + +resource "google_redis_instance" "cache" { + name = "ha-memory-cache" + tier = "STANDARD_HA" + memory_size_gb = 1 + + region = "us-central1" + location_id = "us-central1-a" + alternative_location_id = "us-central1-f" + + authorized_network = google_compute_network.redis-network.id + + redis_version = "REDIS_4_0" + display_name = "Terraform Test Instance" + reserved_ip_range = "192.168.0.0/29" + + labels = { + my_key = "my_val" + other_key = "other_val" + } +} diff --git a/mmv1/third_party/validator/tests/data/example_redis_instance.tfplan.json b/mmv1/third_party/validator/tests/data/example_redis_instance.tfplan.json new file mode 100644 index 000000000000..f2d6e1303e03 --- /dev/null +++ b/mmv1/third_party/validator/tests/data/example_redis_instance.tfplan.json @@ -0,0 +1,220 @@ +{ + "format_version": "0.2", + "terraform_version": "1.0.10", + "planned_values": { + "root_module": { + "resources": [ + { + "address": "google_compute_network.redis-network", + "mode": "managed", + "type": "google_compute_network", + "name": "redis-network", + "provider_name": "registry.terraform.io/hashicorp/google", + "schema_version": 0, + "values": { + "auto_create_subnetworks": true, + "delete_default_routes_on_create": false, + "description": null, + "name": "redis-test-network", + "timeouts": null + }, + "sensitive_values": {} + }, + { + "address": "google_redis_instance.cache", + "mode": "managed", + "type": "google_redis_instance", + "name": "cache", + "provider_name": "registry.terraform.io/hashicorp/google", + "schema_version": 0, + "values": { + "alternative_location_id": "us-central1-f", + "auth_enabled": false, + "connect_mode": "DIRECT_PEERING", + "display_name": "Terraform Test Instance", + "labels": { + "my_key": "my_val", + "other_key": "other_val" + }, + "location_id": "us-central1-a", + "memory_size_gb": 1, + "name": "ha-memory-cache", + "redis_configs": null, + "redis_version": "REDIS_4_0", + "region": "us-central1", + "reserved_ip_range": "192.168.0.0/29", + "tier": "STANDARD_HA", + "timeouts": null, + "transit_encryption_mode": "DISABLED" + }, + "sensitive_values": { + "labels": {}, + "server_ca_certs": [] + } + } + ] + } + }, + "resource_changes": [ + { + "address": "google_compute_network.redis-network", + "mode": "managed", + "type": "google_compute_network", + "name": "redis-network", + "provider_name": "registry.terraform.io/hashicorp/google", + "change": { + "actions": [ + "create" + ], + "before": null, + "after": { + "auto_create_subnetworks": true, + "delete_default_routes_on_create": false, + "description": null, + "name": "redis-test-network", + "timeouts": null + }, + "after_unknown": { + "gateway_ipv4": true, + "id": true, + "mtu": true, + "project": true, + "routing_mode": true, + "self_link": true + }, + "before_sensitive": false, + "after_sensitive": {} + } + }, + { + "address": "google_redis_instance.cache", + "mode": "managed", + "type": "google_redis_instance", + "name": "cache", + "provider_name": "registry.terraform.io/hashicorp/google", + "change": { + "actions": [ + "create" + ], + "before": null, + "after": { + "alternative_location_id": "us-central1-f", + "auth_enabled": false, + "connect_mode": "DIRECT_PEERING", + "display_name": "Terraform Test Instance", + "labels": { + "my_key": "my_val", + "other_key": "other_val" + }, + "location_id": "us-central1-a", + "memory_size_gb": 1, + "name": "ha-memory-cache", + "redis_configs": null, + "redis_version": "REDIS_4_0", + "region": "us-central1", + "reserved_ip_range": "192.168.0.0/29", + "tier": "STANDARD_HA", + "timeouts": null, + "transit_encryption_mode": "DISABLED" + }, + "after_unknown": { + "auth_string": true, + "authorized_network": true, + "create_time": true, + "current_location_id": true, + "host": true, + "id": true, + "labels": {}, + "persistence_iam_identity": true, + "port": true, + "project": true, + "server_ca_certs": true + }, + "before_sensitive": false, + "after_sensitive": { + "auth_string": true, + "labels": {}, + "server_ca_certs": [] + } + } + } + ], + "configuration": { + "provider_config": { + "google": { + "name": "google", + "expressions": { + "project": { + "constant_value": "{{.Provider.project}}" + } + } + } + }, + "root_module": { + "resources": [ + { + "address": "google_compute_network.redis-network", + "mode": "managed", + "type": "google_compute_network", + "name": "redis-network", + "provider_config_key": "google", + "expressions": { + "name": { + "constant_value": "redis-test-network" + } + }, + "schema_version": 0 + }, + { + "address": "google_redis_instance.cache", + "mode": "managed", + "type": "google_redis_instance", + "name": "cache", + "provider_config_key": "google", + "expressions": { + "alternative_location_id": { + "constant_value": "us-central1-f" + }, + "authorized_network": { + "references": [ + "google_compute_network.redis-network.id", + "google_compute_network.redis-network" + ] + }, + "display_name": { + "constant_value": "Terraform Test Instance" + }, + "labels": { + "constant_value": { + "my_key": "my_val", + "other_key": "other_val" + } + }, + "location_id": { + "constant_value": "us-central1-a" + }, + "memory_size_gb": { + "constant_value": 1 + }, + "name": { + "constant_value": "ha-memory-cache" + }, + "redis_version": { + "constant_value": "REDIS_4_0" + }, + "region": { + "constant_value": "us-central1" + }, + "reserved_ip_range": { + "constant_value": "192.168.0.0/29" + }, + "tier": { + "constant_value": "STANDARD_HA" + } + }, + "schema_version": 0 + } + ] + } + } +}