Introduction
When you create or delete cloud resources with Terraform, some actions happen when you first make the resource, and others happen when you remove it. Understanding when these actions run helps you control your infrastructure safely.
When you want to run a script only once when a resource is created, like setting up a database schema.
When you need to clean up external resources or data when deleting a cloud resource.
When you want to avoid running expensive or risky commands every time you update your infrastructure.
When you want to manage lifecycle hooks to control resource creation and destruction order.
When you want to automate backups before deleting storage buckets.