From 2772c89208dcd1c9c48bfc5f54a017d56f7a9559 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Fri, 4 Aug 2023 22:25:06 +0000 Subject: [PATCH 01/18] Redis cluster terraform support --- mmv1/products/redis/Cluster.yaml | 163 ++++++++++++++++++ .../examples/redis_cluster_nonha.tf.erb | 17 ++ .../tests/resource_redis_cluster_test.go | 108 ++++++++++++ 3 files changed, 288 insertions(+) create mode 100644 mmv1/products/redis/Cluster.yaml create mode 100644 mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb create mode 100644 mmv1/third_party/terraform/tests/resource_redis_cluster_test.go diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml new file mode 100644 index 000000000000..fb55844bd57a --- /dev/null +++ b/mmv1/products/redis/Cluster.yaml @@ -0,0 +1,163 @@ +# Copyright 2023 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. + +--- !ruby/object:Api::Resource +name: 'Cluster' +description: | + A Google Cloud Redis Cluster instance. +references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Official Documentation': 'https://cloud.google.com/memorystore/docs/cluster/' + api: 'https://cloud.google.com/memorystore/docs/cluster/reference/rest/v1alpha1/projects.locations.clusters' +timeouts: !ruby/object:Api::Timeouts + insert_minutes: 60 + update_minutes: 120 + delete_minutes: 30 +min_version: beta +base_url: 'projects/{{project}}/locations/{{region}}/clusters' +self_link: 'projects/{{project}}/locations/{{region}}/clusters/{{name}}' + +create_url: 'projects/{{project}}/locations/{{region}}/clusters?clusterId={{name}}' +update_verb: :PATCH +update_mask: true + +autogen_async: true + +parameters: + - !ruby/object:Api::Type::String + name: name + description: | + Unique name of the resource in this scope including project and location using the form: + projects/{projectId}/locations/{locationId}/clusters/{clusterId} + required: true + immutable: true + url_param_only: true + - !ruby/object:Api::Type::String + name: 'region' + required: false + immutable: true + url_param_only: true + description: | + The name of the region of the Redis cluster. + ignore_read: true + default_from_api: true +examples: + - !ruby/object:Provider::Terraform::Examples + name: "redis_cluster_nonha" + min_version: beta + primary_resource_id: "cluster-nonha" + vars: + cluster_name: "nonha-cluster" + network_name: "redis-test-network" +properties: + - !ruby/object:Api::Type::String + name: displayName + description: | + Optional. An arbitrary and optional user-provided name for the cluster. + required: false + - !ruby/object:Api::Type::Time + name: createTime + description: | + The timestamp associated with the cluster creation request. A timestamp in + RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional + digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z". + output: true + - !ruby/object:Api::Type::Enum + name: state + description: | + The current state of this cluster. Can be CREATING, READY, UPDATING, DELETING and SUSPENDED + values: + - :CREATING + - :READY + - :UPDATING + - :DELETING + - :SUSPENDED + immutable: true + output: true + - !ruby/object:Api::Type::String + name: uid + description: | + System assigned, unique identifier for the cluster. + output: true + - !ruby/object:Api::Type::Enum + name: transitEncryptionMode + description: | + Optional. The in-transit encryption for the Redis cluster. + If not provided, encryption is disabled for the cluster. + values: + - :TRANSIT_ENCRYPTION_MODE_UNSPECIFIED + - :TRANSIT_ENCRYPTION_MODE_DISABLED + - :TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION + default_value: :TRANSIT_ENCRYPTION_MODE_DISABLED + immutable: true + required: false + - !ruby/object:Api::Type::Array + name: 'pscConfigs' + description: | + Required. Each PscConfig configures the consumer network where two + network addresses will be designated to the cluster for client access. + Currently, only one PscConfig is supported. + required: true + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: 'network' + description: | + Required. The consumer network where the network address of + the discovery endpoint will be reserved, in the form of + projects/{network_host_project_id}/global/networks/{network_id}. + required: true + - !ruby/object:Api::Type::Array + name: 'discoveryEndpoints' + description: | + Output only. Endpoints created on each given network, + for Redis clients to connect to the cluster. + Currently only one endpoint is supported. + output: true + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: 'address' + description: | + Output only. Network address of the exposed Redis endpoint used by clients to connect to the service. + - !ruby/object:Api::Type::Integer + name: 'port' + description: | + Output only. The port number of the exposed Redis endpoint. + - !ruby/object:Api::Type::NestedObject + name: 'pscConfig' + description: | + Output only. Customer configuration for where the endpoint + is created and accessed from. + properties: + - !ruby/object:Api::Type::String + name: 'network' + description: | + The consumer network where the network address of the discovery + endpoint will be reserved, in the form of + projects/{network_host_project_id}/global/networks/{network_id}. + - !ruby/object:Api::Type::Integer + name: replicaCount + description: | + Optional. The number of replica nodes per shard. + required: false + - !ruby/object:Api::Type::Integer + name: sizeGb + description: | + Output only. Redis memory size in GB for the entire cluster. + output: true + - !ruby/object:Api::Type::Integer + name: shardCount + description: | + Required. Number of shards for the Redis cluster. + required: true diff --git a/mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb new file mode 100644 index 000000000000..6234d70d0dcf --- /dev/null +++ b/mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb @@ -0,0 +1,17 @@ +resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { + provider = google-beta + name = "<%= ctx[:vars]['cluster_name'] %>" + shard_count = 3 + psc_configs = [ + { + network = data.google_compute_network.redis-network.id + } + ] +} + +data "google_compute_network" "redis-network" { + name = "projects/${data.google_project.project.project_id}/global/networks/default" +} + +data "google_project" "project" { +} diff --git a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go new file mode 100644 index 000000000000..58832554cfc1 --- /dev/null +++ b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go @@ -0,0 +1,108 @@ +package google + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-provider-google/google/acctest" +) + +// Validate that replica count is updated for the cluster +func TestAccRedisCluster_updateReplicaCount(t *testing.T) { + t.Parallel() + + name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), + Steps: []resource.TestStep{ + { + // create cluster with replica count 1 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 3, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // update replica count to 2 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 2 /* shardCount = */, 3, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // clean up the resource + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 2 /* shardCount = */, 3, false), + }, + }, + }) +} + +// Validate that shard count is updated for the cluster +func TestAccRedisCluster_updateShardCount(t *testing.T) { + t.Parallel() + + name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), + Steps: []resource.TestStep{ + { + // create cluster with shard count 3 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 3, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // update shard count to 5 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 5, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // clean up the resource + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 5, false), + }, + }, + }) +} + +func createOrUpdateRedisCluster(name string, replicaCount int, shardCount int, preventDestroy bool) string { + lifecycleBlock := "" + if preventDestroy { + lifecycleBlock = ` + lifecycle { + prevent_destroy = true + }` + } + return fmt.Sprintf(` +resource "google_redis_cluster" "test" { + name = "%s" + replica_count = %d + shard_count = %d + region = "us-central1" + psc_configs { + network = "projects/${data.google_project.project.number}/global/networks/default" + } + %s +} + +data "google_project" "project" { +} +`, name, replicaCount, shardCount, lifecycleBlock) +} From b76230687f69ff7c20122f612b52327734477d9a Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Mon, 7 Aug 2023 22:11:34 +0000 Subject: [PATCH 02/18] updating cluster resource --- mmv1/products/redis/Cluster.yaml | 12 +++--------- .../examples/redis_cluster_nonha.tf.erb | 17 ----------------- .../tests/resource_redis_cluster_test.go | 3 ++- 3 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml index fb55844bd57a..727f8c297a61 100644 --- a/mmv1/products/redis/Cluster.yaml +++ b/mmv1/products/redis/Cluster.yaml @@ -53,18 +53,12 @@ parameters: default_from_api: true examples: - !ruby/object:Provider::Terraform::Examples - name: "redis_cluster_nonha" + name: "redis_cluster_ha" min_version: beta - primary_resource_id: "cluster-nonha" + primary_resource_id: "cluster-ha" vars: - cluster_name: "nonha-cluster" - network_name: "redis-test-network" + cluster_name: "ha-cluster" properties: - - !ruby/object:Api::Type::String - name: displayName - description: | - Optional. An arbitrary and optional user-provided name for the cluster. - required: false - !ruby/object:Api::Type::Time name: createTime description: | diff --git a/mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb deleted file mode 100644 index 6234d70d0dcf..000000000000 --- a/mmv1/templates/terraform/examples/redis_cluster_nonha.tf.erb +++ /dev/null @@ -1,17 +0,0 @@ -resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { - provider = google-beta - name = "<%= ctx[:vars]['cluster_name'] %>" - shard_count = 3 - psc_configs = [ - { - network = data.google_compute_network.redis-network.id - } - ] -} - -data "google_compute_network" "redis-network" { - name = "projects/${data.google_project.project.project_id}/global/networks/default" -} - -data "google_project" "project" { -} diff --git a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go index 58832554cfc1..f73596f472a2 100644 --- a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go +++ b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go @@ -92,7 +92,8 @@ func createOrUpdateRedisCluster(name string, replicaCount int, shardCount int, p } return fmt.Sprintf(` resource "google_redis_cluster" "test" { - name = "%s" + name = "%s" + region = "us-central1" replica_count = %d shard_count = %d region = "us-central1" From 24882a10d5e7f2c3e9f20eb015264ba2c7452aa9 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Mon, 7 Aug 2023 22:14:42 +0000 Subject: [PATCH 03/18] updating cluster resource --- .../terraform/examples/redis_cluster_ha.tf.erb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb diff --git a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb new file mode 100644 index 000000000000..356b516868d7 --- /dev/null +++ b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb @@ -0,0 +1,18 @@ +resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { + provider = google-beta + name = "<%= ctx[:vars]['cluster_name'] %>" + shard_count = 3 + psc_configs = { + network = data.google_compute_network.redis-network.id + } + region = "us-central1" + replica_count = 1 + transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED" +} + +data "google_compute_network" "redis-network" { + name = "projects/${data.google_project.project.project_id}/global/networks/default" +} + +data "google_project" "project" { +} \ No newline at end of file From 66912eb07ac485b7c73c4b38ef4365c3cec3ed5a Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Tue, 8 Aug 2023 00:14:29 +0000 Subject: [PATCH 04/18] updating cluster resource --- mmv1/products/redis/Cluster.yaml | 12 ++++++------ .../terraform/examples/redis_cluster_ha.tf.erb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml index 727f8c297a61..dfd0d6612c7b 100644 --- a/mmv1/products/redis/Cluster.yaml +++ b/mmv1/products/redis/Cluster.yaml @@ -50,14 +50,14 @@ parameters: description: | The name of the region of the Redis cluster. ignore_read: true - default_from_api: true + default_from_api: true examples: - !ruby/object:Provider::Terraform::Examples - name: "redis_cluster_ha" - min_version: beta - primary_resource_id: "cluster-ha" - vars: - cluster_name: "ha-cluster" + name: "redis_cluster_ha" + min_version: beta + primary_resource_id: "cluster-ha" + vars: + cluster_name: "ha-cluster" properties: - !ruby/object:Api::Type::Time name: createTime diff --git a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb index 356b516868d7..e90d6fc37f67 100644 --- a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb +++ b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb @@ -2,7 +2,7 @@ resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { provider = google-beta name = "<%= ctx[:vars]['cluster_name'] %>" shard_count = 3 - psc_configs = { + psc_configs { network = data.google_compute_network.redis-network.id } region = "us-central1" From 10d790cedbd75a5a84dcc654c02bb57a69b0abf7 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Tue, 8 Aug 2023 00:21:51 +0000 Subject: [PATCH 05/18] updating cluster resource --- mmv1/products/redis/Cluster.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml index dfd0d6612c7b..f9a9ad2feaa9 100644 --- a/mmv1/products/redis/Cluster.yaml +++ b/mmv1/products/redis/Cluster.yaml @@ -50,7 +50,7 @@ parameters: description: | The name of the region of the Redis cluster. ignore_read: true - default_from_api: true + default_from_api: true examples: - !ruby/object:Provider::Terraform::Examples name: "redis_cluster_ha" From cebd3b6322c22cab10bef75b7721cabfb43a7be4 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Tue, 8 Aug 2023 00:37:00 +0000 Subject: [PATCH 06/18] updating cluster resource --- mmv1/third_party/terraform/tests/resource_redis_cluster_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go index f73596f472a2..a7cd471ff589 100644 --- a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go +++ b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go @@ -93,7 +93,6 @@ func createOrUpdateRedisCluster(name string, replicaCount int, shardCount int, p return fmt.Sprintf(` resource "google_redis_cluster" "test" { name = "%s" - region = "us-central1" replica_count = %d shard_count = %d region = "us-central1" From f4a5147e723d7d5aeadc44acf2ca0b3d6f4a2b56 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Tue, 8 Aug 2023 22:19:12 +0000 Subject: [PATCH 07/18] updating cluster resource --- mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb | 7 ++----- ..._cluster_test.go => resource_redis_cluster_test.go.erb} | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) rename mmv1/third_party/terraform/tests/{resource_redis_cluster_test.go => resource_redis_cluster_test.go.erb} (94%) diff --git a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb index e90d6fc37f67..73a933a391ec 100644 --- a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb +++ b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb @@ -3,16 +3,13 @@ resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cluster_name'] %>" shard_count = 3 psc_configs { - network = data.google_compute_network.redis-network.id + network = "projects/${data.google_project.project.number}/global/networks/default" } region = "us-central1" replica_count = 1 transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED" } -data "google_compute_network" "redis-network" { - name = "projects/${data.google_project.project.project_id}/global/networks/default" -} - data "google_project" "project" { + provider = google-beta } \ No newline at end of file diff --git a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb similarity index 94% rename from mmv1/third_party/terraform/tests/resource_redis_cluster_test.go rename to mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb index a7cd471ff589..ed14c2339795 100644 --- a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go +++ b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb @@ -1,5 +1,6 @@ package google +<% unless version == 'ga' -%> import ( "fmt" "testing" @@ -16,7 +17,7 @@ func TestAccRedisCluster_updateReplicaCount(t *testing.T) { acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), Steps: []resource.TestStep{ { @@ -53,7 +54,7 @@ func TestAccRedisCluster_updateShardCount(t *testing.T) { acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), Steps: []resource.TestStep{ { @@ -106,3 +107,4 @@ data "google_project" "project" { } `, name, replicaCount, shardCount, lifecycleBlock) } +<% end -%> From 64af36e6c8c2ce56f4ea72d7abd93be91c3f0b3a Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Thu, 17 Aug 2023 23:52:21 +0000 Subject: [PATCH 08/18] update --- mmv1/products/redis/Cluster.yaml | 2 +- .../terraform/tests/resource_redis_cluster_test.go.erb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml index f9a9ad2feaa9..cb43326d23f0 100644 --- a/mmv1/products/redis/Cluster.yaml +++ b/mmv1/products/redis/Cluster.yaml @@ -32,7 +32,6 @@ update_verb: :PATCH update_mask: true autogen_async: true - parameters: - !ruby/object:Api::Type::String name: name @@ -102,6 +101,7 @@ properties: network addresses will be designated to the cluster for client access. Currently, only one PscConfig is supported. required: true + ignore_read: true item_type: !ruby/object:Api::Type::NestedObject properties: - !ruby/object:Api::Type::String diff --git a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb index ed14c2339795..8b4fb446f3ec 100644 --- a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb @@ -1,6 +1,7 @@ -package google +<% autogen_exception -%> +package google_beta +<% unless version == "ga" -%> -<% unless version == 'ga' -%> import ( "fmt" "testing" From b31e8ec5a16d8983ff3611e519117619a292400e Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Fri, 18 Aug 2023 17:32:49 +0000 Subject: [PATCH 09/18] update --- .../tests/resource_redis_cluster_test.go.erb | 111 ------------------ 1 file changed, 111 deletions(-) delete mode 100644 mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb diff --git a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb deleted file mode 100644 index 8b4fb446f3ec..000000000000 --- a/mmv1/third_party/terraform/tests/resource_redis_cluster_test.go.erb +++ /dev/null @@ -1,111 +0,0 @@ -<% autogen_exception -%> -package google_beta -<% unless version == "ga" -%> - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-provider-google/google/acctest" -) - -// Validate that replica count is updated for the cluster -func TestAccRedisCluster_updateReplicaCount(t *testing.T) { - t.Parallel() - - name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), - CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), - Steps: []resource.TestStep{ - { - // create cluster with replica count 1 - Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 3, true), - }, - { - ResourceName: "google_redis_cluster.test", - ImportState: true, - ImportStateVerify: true, - }, - { - // update replica count to 2 - Config: createOrUpdateRedisCluster(name /* replicaCount = */, 2 /* shardCount = */, 3, true), - }, - { - ResourceName: "google_redis_cluster.test", - ImportState: true, - ImportStateVerify: true, - }, - { - // clean up the resource - Config: createOrUpdateRedisCluster(name /* replicaCount = */, 2 /* shardCount = */, 3, false), - }, - }, - }) -} - -// Validate that shard count is updated for the cluster -func TestAccRedisCluster_updateShardCount(t *testing.T) { - t.Parallel() - - name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), - CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), - Steps: []resource.TestStep{ - { - // create cluster with shard count 3 - Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 3, true), - }, - { - ResourceName: "google_redis_cluster.test", - ImportState: true, - ImportStateVerify: true, - }, - { - // update shard count to 5 - Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 5, true), - }, - { - ResourceName: "google_redis_cluster.test", - ImportState: true, - ImportStateVerify: true, - }, - { - // clean up the resource - Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 5, false), - }, - }, - }) -} - -func createOrUpdateRedisCluster(name string, replicaCount int, shardCount int, preventDestroy bool) string { - lifecycleBlock := "" - if preventDestroy { - lifecycleBlock = ` - lifecycle { - prevent_destroy = true - }` - } - return fmt.Sprintf(` -resource "google_redis_cluster" "test" { - name = "%s" - replica_count = %d - shard_count = %d - region = "us-central1" - psc_configs { - network = "projects/${data.google_project.project.number}/global/networks/default" - } - %s -} - -data "google_project" "project" { -} -`, name, replicaCount, shardCount, lifecycleBlock) -} -<% end -%> From c5b85c01d1bf896904ea460264c4bd62b09e3493 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Fri, 18 Aug 2023 17:35:45 +0000 Subject: [PATCH 10/18] update --- .../redis/resource_redis_cluster_test.go.erb | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb diff --git a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb new file mode 100644 index 000000000000..e6139d706311 --- /dev/null +++ b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb @@ -0,0 +1,111 @@ +<% autogen_exception -%> +package redis_test +<% unless version == "ga" -%> + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-provider-google/google/acctest" +) + +// Validate that replica count is updated for the cluster +func TestAccRedisCluster_updateReplicaCount(t *testing.T) { + t.Parallel() + + name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), + CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), + Steps: []resource.TestStep{ + { + // create cluster with replica count 1 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 3, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // update replica count to 2 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 2 /* shardCount = */, 3, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // clean up the resource + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 2 /* shardCount = */, 3, false), + }, + }, + }) +} + +// Validate that shard count is updated for the cluster +func TestAccRedisCluster_updateShardCount(t *testing.T) { + t.Parallel() + + name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t)) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), + CheckDestroy: testAccCheckRedisClusterDestroyProducer(t), + Steps: []resource.TestStep{ + { + // create cluster with shard count 3 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 3, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // update shard count to 5 + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 5, true), + }, + { + ResourceName: "google_redis_cluster.test", + ImportState: true, + ImportStateVerify: true, + }, + { + // clean up the resource + Config: createOrUpdateRedisCluster(name /* replicaCount = */, 1 /* shardCount = */, 5, false), + }, + }, + }) +} + +func createOrUpdateRedisCluster(name string, replicaCount int, shardCount int, preventDestroy bool) string { + lifecycleBlock := "" + if preventDestroy { + lifecycleBlock = ` + lifecycle { + prevent_destroy = true + }` + } + return fmt.Sprintf(` +resource "google_redis_cluster" "test" { + name = "%s" + replica_count = %d + shard_count = %d + region = "us-central1" + psc_configs { + network = "projects/${data.google_project.project.number}/global/networks/default" + } + %s +} + +data "google_project" "project" { +} +`, name, replicaCount, shardCount, lifecycleBlock) +} +<% end -%> From af6aeeed4311e36be33280874c3f4b7940bb8453 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Mon, 21 Aug 2023 20:55:15 +0000 Subject: [PATCH 11/18] update --- .../terraform/services/redis/resource_redis_cluster_test.go.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb index e6139d706311..4def37f7da48 100644 --- a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb +++ b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb @@ -94,6 +94,7 @@ func createOrUpdateRedisCluster(name string, replicaCount int, shardCount int, p } return fmt.Sprintf(` resource "google_redis_cluster" "test" { + provider = google-beta name = "%s" replica_count = %d shard_count = %d @@ -105,6 +106,7 @@ resource "google_redis_cluster" "test" { } data "google_project" "project" { + provider = google-beta } `, name, replicaCount, shardCount, lifecycleBlock) } From a5756f8262a7332a76b21ce8810acf68555fc029 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Mon, 21 Aug 2023 21:20:44 +0000 Subject: [PATCH 12/18] update --- .../examples/redis_cluster_ha.tf.erb | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb index 73a933a391ec..1809a02c9ebb 100644 --- a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb +++ b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb @@ -3,13 +3,38 @@ resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { name = "<%= ctx[:vars]['cluster_name'] %>" shard_count = 3 psc_configs { - network = "projects/${data.google_project.project.number}/global/networks/default" + network = google_compute_network.producer_net.id } region = "us-central1" replica_count = 1 transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED" + depends_on = [ + google_network_connectivity_service_connection_policy.default + ] } -data "google_project" "project" { +resource "google_network_connectivity_service_connection_policy" "default" { provider = google-beta -} \ No newline at end of file + name = "sc-policy-tf" + location = "us-central1" + service_class = "gcp-memorystore-redis" + description = "my basic service connection policy" + network = google_compute_network.producer_net.id + psc_config { + subnetworks = [google_compute_subnetwork.producer_subnet.id] + } +} + +resource "google_compute_subnetwork" "producer_subnet" { + provider = google-beta + name = "consumer-subnet" + ip_cidr_range = "10.1.0.0/16" + region = "us-central1" + network = google_compute_network.producer_net.id +} + +resource "google_compute_network" "producer_net" { + provider = google-beta + name = "mynetwork" + auto_create_subnetworks = false +} From 66ecf1ea3795dffb0f59d0a5115bfbce758a9c57 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Tue, 22 Aug 2023 04:12:04 +0000 Subject: [PATCH 13/18] update --- mmv1/products/redis/Cluster.yaml | 45 +++++++++++++++++-- .../examples/redis_cluster_ha.tf.erb | 9 ++-- .../redis/resource_redis_cluster_test.go.erb | 29 +++++++++++- 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml index cb43326d23f0..d3390cd6ed9d 100644 --- a/mmv1/products/redis/Cluster.yaml +++ b/mmv1/products/redis/Cluster.yaml @@ -26,11 +26,9 @@ timeouts: !ruby/object:Api::Timeouts min_version: beta base_url: 'projects/{{project}}/locations/{{region}}/clusters' self_link: 'projects/{{project}}/locations/{{region}}/clusters/{{name}}' - create_url: 'projects/{{project}}/locations/{{region}}/clusters?clusterId={{name}}' update_verb: :PATCH update_mask: true - autogen_async: true parameters: - !ruby/object:Api::Type::String @@ -41,6 +39,7 @@ parameters: required: true immutable: true url_param_only: true + default_from_api: true - !ruby/object:Api::Type::String name: 'region' required: false @@ -82,6 +81,17 @@ properties: description: | System assigned, unique identifier for the cluster. output: true + - !ruby/object:Api::Type::Enum + name: authorizationMode + description: | + Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. + values: + - :AUTH_MODE_UNSPECIFIED + - :AUTH_MODE_IAM_AUTH + - :AUTH_MODE_DISABLED + default_value: :AUTH_MODE_DISABLED + immutable: true + required: false - !ruby/object:Api::Type::Enum name: transitEncryptionMode description: | @@ -109,7 +119,7 @@ properties: description: | Required. The consumer network where the network address of the discovery endpoint will be reserved, in the form of - projects/{network_host_project_id}/global/networks/{network_id}. + projects/{network_project_id_or_number}/global/networks/{network_id}. required: true - !ruby/object:Api::Type::Array name: 'discoveryEndpoints' @@ -139,7 +149,34 @@ properties: description: | The consumer network where the network address of the discovery endpoint will be reserved, in the form of - projects/{network_host_project_id}/global/networks/{network_id}. + projects/{network_project_id}/global/networks/{network_id}. + - !ruby/object:Api::Type::Array + name: 'pscConnections' + description: | + Output only. PSC connections for discovery of the cluster topology and accessing the cluster. + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: 'pscConnectionId' + description: | + Output only. The PSC connection id of the forwarding rule connected to the service attachment. + - !ruby/object:Api::Type::String + name: 'address' + description: | + Output only. The IP allocated on the consumer network for the PSC forwarding rule. + - !ruby/object:Api::Type::String + name: 'forwardingRule' + description: | + Output only. The URI of the consumer side forwarding rule. Example: projects/{projectNumOrId}/regions/us-east1/forwardingRules/{resourceId}. + - !ruby/object:Api::Type::String + name: 'projectId' + description: | + Output only. The consumer projectId where the forwarding rule is created from. + - !ruby/object:Api::Type::String + name: 'network' + description: | + The consumer network where the IP address resides, in the form of projects/{projectId}/global/networks/{network_id}. + output: true - !ruby/object:Api::Type::Integer name: replicaCount description: | diff --git a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb index 1809a02c9ebb..a1e3e06b9dc8 100644 --- a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb +++ b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb @@ -1,5 +1,5 @@ resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { - provider = google-beta + provider = google-beta name = "<%= ctx[:vars]['cluster_name'] %>" shard_count = 3 psc_configs { @@ -8,7 +8,8 @@ resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { region = "us-central1" replica_count = 1 transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED" - depends_on = [ + authorization_mode = "AUTH_MODE_DISABLED" + depends_on = [ google_network_connectivity_service_connection_policy.default ] } @@ -26,7 +27,7 @@ resource "google_network_connectivity_service_connection_policy" "default" { } resource "google_compute_subnetwork" "producer_subnet" { - provider = google-beta + provider = google-beta name = "consumer-subnet" ip_cidr_range = "10.1.0.0/16" region = "us-central1" @@ -34,7 +35,7 @@ resource "google_compute_subnetwork" "producer_subnet" { } resource "google_compute_network" "producer_net" { - provider = google-beta + provider = google-beta name = "mynetwork" auto_create_subnetworks = false } diff --git a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb index 4def37f7da48..96c4b317bf60 100644 --- a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb +++ b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb @@ -100,13 +100,38 @@ resource "google_redis_cluster" "test" { shard_count = %d region = "us-central1" psc_configs { - network = "projects/${data.google_project.project.number}/global/networks/default" + network = google_compute_network.producer_net.id } + depends_on = [ + google_network_connectivity_service_connection_policy.default + ] %s } -data "google_project" "project" { +resource "google_network_connectivity_service_connection_policy" "default" { provider = google-beta + name = "sc-policy-tf" + location = "us-central1" + service_class = "gcp-memorystore-redis" + description = "my basic service connection policy" + network = google_compute_network.producer_net.id + psc_config { + subnetworks = [google_compute_subnetwork.producer_subnet.id] + } +} + +resource "google_compute_subnetwork" "producer_subnet" { + provider = google-beta + name = "consumer-subnet" + ip_cidr_range = "10.1.0.0/16" + region = "us-central1" + network = google_compute_network.producer_net.id +} + +resource "google_compute_network" "producer_net" { + provider = google-beta + name = "mynetwork" + auto_create_subnetworks = false } `, name, replicaCount, shardCount, lifecycleBlock) } From 0c6ccff2d9556c3e345d6f689f6cb659b1aeaf1c Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Tue, 22 Aug 2023 19:39:38 +0000 Subject: [PATCH 14/18] update --- mmv1/products/redis/Cluster.yaml | 17 +++++++++++++++++ .../terraform/examples/redis_cluster_ha.tf.erb | 8 ++++---- .../redis/resource_redis_cluster_test.go.erb | 10 +++++----- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml index d3390cd6ed9d..7381365db3b7 100644 --- a/mmv1/products/redis/Cluster.yaml +++ b/mmv1/products/redis/Cluster.yaml @@ -56,6 +56,9 @@ examples: primary_resource_id: "cluster-ha" vars: cluster_name: "ha-cluster" + policy_name: "mypolicy" + subnet_name: "mysubnet" + network_name: "mynetwork" properties: - !ruby/object:Api::Type::Time name: createTime @@ -177,6 +180,20 @@ properties: description: | The consumer network where the IP address resides, in the form of projects/{projectId}/global/networks/{network_id}. output: true + - !ruby/object:Api::Type::NestedObject + name: stateInfo + description: Output only. Additional information about the current state of the cluster. + properties: + - !ruby/object:Api::Type::NestedObject + name: updateInfo + properties: + - !ruby/object:Api::Type::Integer + name: targetShardCount + description: Target number of shards for redis cluster. + - !ruby/object:Api::Type::Integer + name: targetReplicaCount + description: Target number of replica nodes per shard. + output: true - !ruby/object:Api::Type::Integer name: replicaCount description: | diff --git a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb index a1e3e06b9dc8..baaf1bc10f76 100644 --- a/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb +++ b/mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb @@ -16,7 +16,7 @@ resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" { resource "google_network_connectivity_service_connection_policy" "default" { provider = google-beta - name = "sc-policy-tf" + name = "<%= ctx[:vars]['policy_name'] %>" location = "us-central1" service_class = "gcp-memorystore-redis" description = "my basic service connection policy" @@ -28,14 +28,14 @@ resource "google_network_connectivity_service_connection_policy" "default" { resource "google_compute_subnetwork" "producer_subnet" { provider = google-beta - name = "consumer-subnet" - ip_cidr_range = "10.1.0.0/16" + name = "<%= ctx[:vars]['subnet_name'] %>" + ip_cidr_range = "10.0.0.248/29" region = "us-central1" network = google_compute_network.producer_net.id } resource "google_compute_network" "producer_net" { provider = google-beta - name = "mynetwork" + name = "<%= ctx[:vars]['network_name'] %>" auto_create_subnetworks = false } diff --git a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb index 96c4b317bf60..0dde5d71e52c 100644 --- a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb +++ b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb @@ -110,7 +110,7 @@ resource "google_redis_cluster" "test" { resource "google_network_connectivity_service_connection_policy" "default" { provider = google-beta - name = "sc-policy-tf" + name = "%s" location = "us-central1" service_class = "gcp-memorystore-redis" description = "my basic service connection policy" @@ -122,17 +122,17 @@ resource "google_network_connectivity_service_connection_policy" "default" { resource "google_compute_subnetwork" "producer_subnet" { provider = google-beta - name = "consumer-subnet" - ip_cidr_range = "10.1.0.0/16" + name = "%s" + ip_cidr_range = "10.0.0.248/29" region = "us-central1" network = google_compute_network.producer_net.id } resource "google_compute_network" "producer_net" { provider = google-beta - name = "mynetwork" + name = "%s" auto_create_subnetworks = false } -`, name, replicaCount, shardCount, lifecycleBlock) +`, name, replicaCount, shardCount, lifecycleBlock, name, name, name) } <% end -%> From 640ba1b1a00213083fc0d5cca336c4140814c2aa Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Fri, 25 Aug 2023 05:27:29 +0000 Subject: [PATCH 15/18] update --- mmv1/products/redis/product.yaml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/mmv1/products/redis/product.yaml b/mmv1/products/redis/product.yaml index 3aa40f3aa7fa..e72d231664cd 100644 --- a/mmv1/products/redis/product.yaml +++ b/mmv1/products/redis/product.yaml @@ -24,19 +24,8 @@ versions: scopes: - https://www.googleapis.com/auth/cloud-platform async: !ruby/object:Api::OpAsync + # Overrides which API calls return operations. Default: ['create', + # 'update', 'delete'] + # actions: ['create', 'update', 'delete'] operation: !ruby/object:Api::OpAsync::Operation - path: 'name' base_url: '{{op_id}}' - wait_ms: 1000 - result: !ruby/object:Api::OpAsync::Result - path: 'response' - resource_inside_response: true - status: !ruby/object:Api::OpAsync::Status - path: 'done' - complete: true - allowed: - - true - - false - error: !ruby/object:Api::OpAsync::Error - path: 'error' - message: 'message' From 8334728cb2594060e70d581cbc80308ffa6ebc8e Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Fri, 25 Aug 2023 16:24:59 +0000 Subject: [PATCH 16/18] update SCPolicy --- .../ServiceConnectionPolicies.yaml | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml b/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml index 28bd092b254d..4b7b8d67060f 100644 --- a/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml +++ b/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml @@ -107,7 +107,7 @@ properties: name: 'pscConfig' description: | Configuration used for Private Service Connect connections. Used when Infrastructure is PSC. - properties: + properties: - !ruby/object:Api::Type::Array name: 'subnetworks' required: true @@ -125,9 +125,35 @@ properties: - !ruby/object:Api::Type::Array name: 'pscConnections' output: true - item_type: Api::Type::String description: | - Information about each Private Service Connect connection. + Information about each Private Service Connect connection.\ + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::Enum + name: state + description: The state of the PSC connection. + values: + - :STATE_UNSPECIFIED + - :ACTIVE + - :CREATING + - :DELETING + - :FAILED + - !ruby/object:Api::Type::String + name: consumerForwardingRule + description: | + The resource reference of the PSC Forwarding Rule within the consumer VPC + - !ruby/object:Api::Type::String + name: gceOperation + description: xyz + - !ruby/object:Api::Type::String + name: consumerTargetProject + description: xyz + - !ruby/object:Api::Type::String + name: pscConnectionId + description: xyz + - !ruby/object:Api::Type::String + name: consumerAddress + description: xyz - !ruby/object:Api::Type::String name: 'infrastructure' output: true From 65cbf5d4c4afb26a9770e6f6bb679cf951ee8442 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Fri, 25 Aug 2023 19:43:18 +0000 Subject: [PATCH 17/18] Update Service connection policy --- .../ServiceConnectionPolicies.yaml | 52 ++++++++++++++++--- mmv1/products/redis/Cluster.yaml | 2 +- .../redis/resource_redis_cluster_test.go.erb | 5 ++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml b/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml index 4b7b8d67060f..c0c2e2e5f7a2 100644 --- a/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml +++ b/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml @@ -142,18 +142,58 @@ properties: name: consumerForwardingRule description: | The resource reference of the PSC Forwarding Rule within the consumer VPC + - !ruby/object:Api::Type::String + name: consumerAddress + description: | + The resource reference of the consumer address. + - !ruby/object:Api::Type::Enum + name: errorType + description: | + The error type indicates whether the error is consumer facing, producer + facing or system internal. + values: + - :CONNECTION_ERROR_TYPE_UNSPECIFIED + - :ERROR_INTERNAL + - :ERROR_CONSUMER_SIDE + - :ERROR_PRODUCER_SIDE + - !ruby/object:Api::Type::NestedObject + name: error + description: | + The most recent error during operating this connection. + properties: + - !ruby/object:Api::Type::String + name: message + description: A developer-facing error message. + - !ruby/object:Api::Type::Integer + name: code + description: The status code, which should be an enum value of [google.rpc.Code][]. - !ruby/object:Api::Type::String name: gceOperation - description: xyz + description: | + The last Compute Engine operation to setup PSC connection. - !ruby/object:Api::Type::String name: consumerTargetProject - description: xyz + description: | + The project where the PSC connection is created. - !ruby/object:Api::Type::String name: pscConnectionId - description: xyz - - !ruby/object:Api::Type::String - name: consumerAddress - description: xyz + description: | + The PSC connection id of the PSC forwarding rule. + - !ruby/object:Api::Type::NestedObject + name: errorInfo + description: | + The error info for the latest error during operating this connection. + properties: + - !ruby/object:Api::Type::String + name: reason + description: The reason of the error. + - !ruby/object:Api::Type::String + name: domain + description: The logical grouping to which the "reason" belongs. + - !ruby/object:Api::Type::KeyValuePairs + name: metadata + description: | + Additional structured details about this error. - !ruby/object:Api::Type::String name: 'infrastructure' output: true diff --git a/mmv1/products/redis/Cluster.yaml b/mmv1/products/redis/Cluster.yaml index 7381365db3b7..a523584b5c5f 100644 --- a/mmv1/products/redis/Cluster.yaml +++ b/mmv1/products/redis/Cluster.yaml @@ -18,7 +18,7 @@ description: | references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Official Documentation': 'https://cloud.google.com/memorystore/docs/cluster/' - api: 'https://cloud.google.com/memorystore/docs/cluster/reference/rest/v1alpha1/projects.locations.clusters' + api: 'https://cloud.google.com/memorystore/docs/cluster/reference/rest/v1beta1/projects.locations.clusters' timeouts: !ruby/object:Api::Timeouts insert_minutes: 60 update_minutes: 120 diff --git a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb index 0dde5d71e52c..105025ed90d1 100644 --- a/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb +++ b/mmv1/third_party/terraform/services/redis/resource_redis_cluster_test.go.erb @@ -29,6 +29,7 @@ func TestAccRedisCluster_updateReplicaCount(t *testing.T) { ResourceName: "google_redis_cluster.test", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"psc_configs"}, }, { // update replica count to 2 @@ -38,6 +39,7 @@ func TestAccRedisCluster_updateReplicaCount(t *testing.T) { ResourceName: "google_redis_cluster.test", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"psc_configs"}, }, { // clean up the resource @@ -66,6 +68,8 @@ func TestAccRedisCluster_updateShardCount(t *testing.T) { ResourceName: "google_redis_cluster.test", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"psc_configs"}, + }, { // update shard count to 5 @@ -75,6 +79,7 @@ func TestAccRedisCluster_updateShardCount(t *testing.T) { ResourceName: "google_redis_cluster.test", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"psc_configs"}, }, { // clean up the resource From 76c85f65d903dc2f92a0867fc986f44f1256d6a1 Mon Sep 17 00:00:00 2001 From: Himani Khanduja Date: Fri, 25 Aug 2023 19:50:35 +0000 Subject: [PATCH 18/18] Update Service connection policy --- .../networkconnectivity/ServiceConnectionPolicies.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml b/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml index c0c2e2e5f7a2..211c71d9735c 100644 --- a/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml +++ b/mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml @@ -126,7 +126,7 @@ properties: name: 'pscConnections' output: true description: | - Information about each Private Service Connect connection.\ + Information about each Private Service Connect connection. item_type: !ruby/object:Api::Type::NestedObject properties: - !ruby/object:Api::Type::Enum @@ -141,7 +141,7 @@ properties: - !ruby/object:Api::Type::String name: consumerForwardingRule description: | - The resource reference of the PSC Forwarding Rule within the consumer VPC + The resource reference of the PSC Forwarding Rule within the consumer VPC. - !ruby/object:Api::Type::String name: consumerAddress description: |