Skip to content

Commit

Permalink
Add support for google_redis_instance (#5496)
Browse files Browse the repository at this point in the history
  • Loading branch information
iyabchen authored Dec 1, 2021
1 parent c1648ad commit 0ff6d6f
Show file tree
Hide file tree
Showing 4 changed files with 317 additions and 0 deletions.
1 change: 1 addition & 0 deletions mmv1/templates/validator/resource_converters.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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()},
Expand Down
44 changes: 44 additions & 0 deletions mmv1/third_party/validator/tests/data/example_redis_instance.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
]
52 changes: 52 additions & 0 deletions mmv1/third_party/validator/tests/data/example_redis_instance.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}
}

0 comments on commit 0ff6d6f

Please sign in to comment.