From f7fd747a354bad52b07881bba5415977eb204343 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 31 Oct 2023 14:08:03 -0700 Subject: [PATCH] Add prevent_destroy metadata configuration. (#9383) (#16415) [upstream:921c254d638895d06d284f899a57c684ecc205a3] Signed-off-by: Modular Magician --- .changelog/9383.txt | 4 ++ .../resource_redis_cluster_generated_test.go | 7 ++- .../resource_redis_instance_generated_test.go | 43 +++++++++++++++---- website/docs/r/redis_cluster.html.markdown | 4 ++ website/docs/r/redis_instance.html.markdown | 23 ++++++++++ 5 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 .changelog/9383.txt diff --git a/.changelog/9383.txt b/.changelog/9383.txt new file mode 100644 index 00000000000..da5b3169b78 --- /dev/null +++ b/.changelog/9383.txt @@ -0,0 +1,4 @@ +```release-note:none +redis: Updated the documentation examples to include the prevent_destroy metadata configuration + +``` diff --git a/google/services/redis/resource_redis_cluster_generated_test.go b/google/services/redis/resource_redis_cluster_generated_test.go index f13501d7de8..825bcced3cc 100644 --- a/google/services/redis/resource_redis_cluster_generated_test.go +++ b/google/services/redis/resource_redis_cluster_generated_test.go @@ -34,7 +34,8 @@ func TestAccRedisCluster_redisClusterHaExample(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), + "prevent_destroy": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -70,6 +71,10 @@ resource "google_redis_cluster" "cluster-ha" { depends_on = [ google_network_connectivity_service_connection_policy.default ] + + lifecycle { + prevent_destroy = %{prevent_destroy} + } } resource "google_network_connectivity_service_connection_policy" "default" { diff --git a/google/services/redis/resource_redis_instance_generated_test.go b/google/services/redis/resource_redis_instance_generated_test.go index db229262526..5b779cbed39 100644 --- a/google/services/redis/resource_redis_instance_generated_test.go +++ b/google/services/redis/resource_redis_instance_generated_test.go @@ -34,7 +34,8 @@ func TestAccRedisInstance_redisInstanceBasicExample(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), + "prevent_destroy": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -60,6 +61,10 @@ func testAccRedisInstance_redisInstanceBasicExample(context map[string]interface resource "google_redis_instance" "cache" { name = "tf-test-memory-cache%{random_suffix}" memory_size_gb = 1 + + lifecycle { + prevent_destroy = %{prevent_destroy} + } } `, context) } @@ -68,8 +73,9 @@ func TestAccRedisInstance_redisInstanceFullExample(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "network_name": acctest.BootstrapSharedTestNetwork(t, "redis-full"), - "random_suffix": acctest.RandString(t, 10), + "network_name": acctest.BootstrapSharedTestNetwork(t, "redis-full"), + "prevent_destroy": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -122,6 +128,10 @@ resource "google_redis_instance" "cache" { } } } + + lifecycle { + prevent_destroy = %{prevent_destroy} + } } // This example assumes this network already exists. @@ -142,8 +152,9 @@ func TestAccRedisInstance_redisInstanceFullWithPersistenceConfigExample(t *testi t.Parallel() context := map[string]interface{}{ - "network_name": acctest.BootstrapSharedTestNetwork(t, "redis-full-persis"), - "random_suffix": acctest.RandString(t, 10), + "network_name": acctest.BootstrapSharedTestNetwork(t, "redis-full-persis"), + "prevent_destroy": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -177,6 +188,10 @@ resource "google_redis_instance" "cache-persis" { persistence_mode = "RDB" rdb_snapshot_period = "TWELVE_HOURS" } + + lifecycle { + prevent_destroy = %{prevent_destroy} + } } `, context) } @@ -185,8 +200,9 @@ func TestAccRedisInstance_redisInstancePrivateServiceTestExample(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "vpc-network-1"), - "random_suffix": acctest.RandString(t, 10), + "network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "vpc-network-1"), + "prevent_destroy": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -234,6 +250,10 @@ resource "google_redis_instance" "cache" { redis_version = "REDIS_4_0" display_name = "Terraform Test Instance" + + lifecycle { + prevent_destroy = %{prevent_destroy} + } } `, context) } @@ -242,8 +262,9 @@ func TestAccRedisInstance_redisInstanceMrrExample(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "network_name": acctest.BootstrapSharedTestNetwork(t, "redis-mrr"), - "random_suffix": acctest.RandString(t, 10), + "network_name": acctest.BootstrapSharedTestNetwork(t, "redis-mrr"), + "prevent_destroy": false, + "random_suffix": acctest.RandString(t, 10), } acctest.VcrTest(t, resource.TestCase{ @@ -286,6 +307,10 @@ resource "google_redis_instance" "cache" { my_key = "my_val" other_key = "other_val" } + + lifecycle { + prevent_destroy = %{prevent_destroy} + } } // This example assumes this network already exists. diff --git a/website/docs/r/redis_cluster.html.markdown b/website/docs/r/redis_cluster.html.markdown index 798a0264c5a..1596c0c7f78 100644 --- a/website/docs/r/redis_cluster.html.markdown +++ b/website/docs/r/redis_cluster.html.markdown @@ -50,6 +50,10 @@ resource "google_redis_cluster" "cluster-ha" { depends_on = [ google_network_connectivity_service_connection_policy.default ] + + lifecycle { + prevent_destroy = true + } } resource "google_network_connectivity_service_connection_policy" "default" { diff --git a/website/docs/r/redis_instance.html.markdown b/website/docs/r/redis_instance.html.markdown index dab74d7ff60..551c74a517d 100644 --- a/website/docs/r/redis_instance.html.markdown +++ b/website/docs/r/redis_instance.html.markdown @@ -40,6 +40,10 @@ To get more information about Instance, see: resource "google_redis_instance" "cache" { name = "memory-cache" memory_size_gb = 1 + + lifecycle { + prevent_destroy = true + } } ```
@@ -81,6 +85,10 @@ resource "google_redis_instance" "cache" { } } } + + lifecycle { + prevent_destroy = true + } } // This example assumes this network already exists. @@ -115,6 +123,10 @@ resource "google_redis_instance" "cache-persis" { persistence_mode = "RDB" rdb_snapshot_period = "TWELVE_HOURS" } + + lifecycle { + prevent_destroy = true + } } ``` ## Example Usage - Redis Instance Private Service @@ -163,6 +175,9 @@ resource "google_redis_instance" "cache" { depends_on = [google_service_networking_connection.private_service_connection] + lifecycle { + prevent_destroy = true + } } ```
@@ -194,6 +209,10 @@ resource "google_redis_instance" "cache" { my_key = "my_val" other_key = "other_val" } + + lifecycle { + prevent_destroy = true + } } // This example assumes this network already exists. @@ -231,6 +250,10 @@ resource "google_redis_instance" "cache" { other_key = "other_val" } customer_managed_key = google_kms_crypto_key.redis_key.id + + lifecycle { + prevent_destroy = true + } } resource "google_kms_key_ring" "redis_keyring" {