Hello, TPP maintainers, thank you for the helpful Provider!
After testing against an active database, it appears setting the lifecycle: { prevent_destroy: true } does not protect the Database resource from being destroyed.
Situation is asserting that renaming the Database resource name field would not destroy the Database resource. In this case the Database is destroyed and re-created under the changed name.
Ideally when lifecycle: { prevent_destroy: true } is set on a resource, upon terraform deploy the command exits with an error code and reports that the resource is protected.
An example of resource being protected, resulting in deploy exiting with an error(database service example):
│ Error: Instance cannot be destroyed
│
│ Resource
│ azurerm_postgresql_flexible_server.postgres_server has
│ lifecycle.prevent_destroy set, but the plan calls for this resource to be
│ destroyed. To avoid this error and continue with the plan, either disable
│ lifecycle.prevent_destroy or reduce the scope of the plan using the -target
│ flag.
Noticed there is a case where the lifecycle attribute is being tested:
However I haven't been able to find a case of lifecycle: { prevent_destroy: bool }. If I understand correctly from searching, and testing, it appears this attribute isn't implemented? I know Go, so could potentially take a crack at implementing/updating if you have guidance. Thank you!
Hello, TPP maintainers, thank you for the helpful Provider!
After testing against an active database, it appears setting the
lifecycle: { prevent_destroy: true }does not protect the Database resource from being destroyed.Situation is asserting that renaming the Database resource
namefield would not destroy the Database resource. In this case the Database is destroyed and re-created under the changed name.Ideally when
lifecycle: { prevent_destroy: true }is set on a resource, uponterraform deploythe command exits with an error code and reports that the resource is protected.An example of resource being protected, resulting in
deployexiting with an error(database service example):Noticed there is a case where the
lifecycleattribute is being tested:terraform-provider-postgresql/postgresql/resource_postgresql_database_test.go
Line 533 in 450ce85
However I haven't been able to find a case of
lifecycle: { prevent_destroy: bool }. If I understand correctly from searching, and testing, it appears this attribute isn't implemented? I know Go, so could potentially take a crack at implementing/updating if you have guidance. Thank you!