Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prevent_destroy metadata configuration. #9383

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mmv1/products/redis/Cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ examples:
policy_name: "mypolicy"
subnet_name: "mysubnet"
network_name: "mynetwork"
prevent_destroy: 'true'
test_vars_overrides:
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
properties:
- !ruby/object:Api::Type::Time
name: createTime
Expand Down
30 changes: 30 additions & 0 deletions mmv1/products/redis/Instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,56 +44,86 @@ examples:
primary_resource_id: 'cache'
vars:
instance_name: 'memory-cache'
prevent_destroy: 'true'
test_vars_overrides:
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
- !ruby/object:Provider::Terraform::Examples
name: 'redis_instance_full'
primary_resource_id: 'cache'
vars:
instance_name: 'ha-memory-cache'
network_name: 'redis-test-network'
prevent_destroy: 'true'
test_vars_overrides:
network_name: 'acctest.BootstrapSharedTestNetwork(t, "redis-full")'
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
- !ruby/object:Provider::Terraform::Examples
name: 'redis_instance_full_with_persistence_config'
primary_resource_id: 'cache-persis'
vars:
instance_name: 'ha-memory-cache-persis'
network_name: 'redis-test-network'
prevent_destroy: 'true'
test_vars_overrides:
network_name: 'acctest.BootstrapSharedTestNetwork(t, "redis-full-persis")'
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
- !ruby/object:Provider::Terraform::Examples
name: 'redis_instance_private_service'
primary_resource_id: 'cache'
vars:
instance_name: 'private-cache'
address_name: 'address'
network_name: 'redis-test-network'
prevent_destroy: 'true'
test_vars_overrides:
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
skip_test: true
- !ruby/object:Provider::Terraform::Examples
name: 'redis_instance_private_service_test'
primary_resource_id: 'cache'
vars:
instance_name: 'private-cache'
network_name: 'redis-test-network'
prevent_destroy: 'true'
test_vars_overrides:
network_name: 'acctest.BootstrapSharedServiceNetworkingConnection(t, "vpc-network-1")'
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
skip_docs: true
- !ruby/object:Provider::Terraform::Examples
name: 'redis_instance_mrr'
primary_resource_id: 'cache'
vars:
instance_name: 'mrr-memory-cache'
network_name: 'redis-test-network'
prevent_destroy: 'true'
test_vars_overrides:
network_name: 'acctest.BootstrapSharedTestNetwork(t, "redis-mrr")'
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
- !ruby/object:Provider::Terraform::Examples
name: 'redis_instance_cmek'
primary_resource_id: 'cache'
skip_test: true
vars:
instance_name: 'cmek-memory-cache'
network_name: 'redis-test-network'
prevent_destroy: 'true'
test_vars_overrides:
network_name: 'acctest.BootstrapSharedTestNetwork(t, "redis-cmek")'
prevent_destroy: 'false'
oics_vars_overrides:
prevent_destroy: 'false'
parameters:
# TODO: resourceref?
- !ruby/object:Api::Type::String
Expand Down
4 changes: 4 additions & 0 deletions mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" {
depends_on = [
google_network_connectivity_service_connection_policy.default
]

lifecycle {
rileykarson marked this conversation as resolved.
Show resolved Hide resolved
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}

resource "google_network_connectivity_service_connection_policy" "default" {
Expand Down
4 changes: 4 additions & 0 deletions mmv1/templates/terraform/examples/redis_instance_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
resource "google_redis_instance" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]["instance_name"] %>"
memory_size_gb = 1

lifecycle {
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}
4 changes: 4 additions & 0 deletions mmv1/templates/terraform/examples/redis_instance_cmek.tf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ resource "google_redis_instance" "<%= ctx[:primary_resource_id] %>" {
other_key = "other_val"
}
customer_managed_key = google_kms_crypto_key.redis_key.id

lifecycle {
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}

resource "google_kms_key_ring" "redis_keyring" {
Expand Down
4 changes: 4 additions & 0 deletions mmv1/templates/terraform/examples/redis_instance_full.tf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ resource "google_redis_instance" "<%= ctx[:primary_resource_id] %>" {
}
}
}

lifecycle {
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}

// This example assumes this network already exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ resource "google_redis_instance" "<%= ctx[:primary_resource_id] %>" {
persistence_mode = "RDB"
rdb_snapshot_period = "TWELVE_HOURS"
}

lifecycle {
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}
4 changes: 4 additions & 0 deletions mmv1/templates/terraform/examples/redis_instance_mrr.tf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ resource "google_redis_instance" "<%= ctx[:primary_resource_id] %>" {
my_key = "my_val"
other_key = "other_val"
}

lifecycle {
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}

// This example assumes this network already exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ resource "google_redis_instance" "<%= ctx[:primary_resource_id] %>" {

depends_on = [google_service_networking_connection.private_service_connection]

}
lifecycle {
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ resource "google_redis_instance" "<%= ctx[:primary_resource_id] %>" {

redis_version = "REDIS_4_0"
display_name = "Terraform Test Instance"
}

lifecycle {
prevent_destroy = <%= ctx[:vars]['prevent_destroy'] %>
}
}