Skip to content

Support protective prevent_destroy: true for Database resources #600

@Ropes

Description

@Ropes

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions