When replacing infrastructure, Terraform normally destroys the existing object before creating its replacement. A resource lifecycle block lets configuration change that behavior and govern other management rules. section 2.7.2
Use the block once inside a resource or data source to configure:
- create_before_destroy, which creates the replacement first when temporary resource loss is unacceptable, though unique names or shared resources can make this fail. section 2.7.2
- prevent_destroy, which makes plans that destroy the resource fail; use it rarely because lifecycle values must be hardcoded literals. section 2.7.2
