resource replacement
When Terraform must destroy a resource and create a new one because a changed setting cannot be updated in place.
In more detail
For a database or bucket holding restricted data, a replacement means data loss whatever the intent. replace_paths in the plan shows which attribute forced it, and a guardrail can refuse such plans.
Examples
terraform plan -replace="null_resource.example"In Terraform: The plan marks it with -/+ or +/- and names the attribute that forces replacement. A replacement gives the object a new identity, so anything holding data, or referred to by other systems, needs extra review. You can also force one deliberately with terraform apply -replace and the resource address, which replaced the older taint command.Related terms
- terraform plan — The command that compares configuration, state and reality and prints the actions needed to make them match, without changing anything.
- data classification — Labelling data by how sensitive it is, such as public, confidential or restricted, so the right controls are applied.
- plan symbols — The marks at the start of each plan line that say what will happen: + create, - destroy, ~ update in place, -/+ or +/- replace, <= read.
- lifecycle block — A block inside a resource that changes how Terraform replaces or protects it, with settings such as create_before_destroy, prevent_destroy and ignore_changes.
- resource address — The type and name of a resource joined by a dot, such as local_file.greeting, which identifies it everywhere.
Taught in
- Least Privilege Enforcement & CIEM Architecture — Cloud Security & DevSecOps Engineering
- Enforcing OPA Guardrails on Terraform Plan Payloads — Cloud Security & DevSecOps Engineering
- Predicting Changes, Then Applying Them — Infrastructure as Code with Terraform
- Scaling Resources With Count — Infrastructure as Code with Terraform
- Iterating Over Maps With For Each — Infrastructure as Code with Terraform
- Safe Changes With Lifecycle Rules — Infrastructure as Code with Terraform
- What State Really Is And Why It Is Needed — Infrastructure as Code with Terraform
- Forcing Replacement — Infrastructure as Code with Terraform
- The Plan That Wanted To Destroy Production — HashiCorp Terraform Associate (004) Exam Prep
- Reading A Plan, Saving It, Applying It — HashiCorp Terraform Associate (004) Exam Prep
- Validate, Format, Destroy, And The Flags That Bend A Plan — HashiCorp Terraform Associate (004) Exam Prep
- Dependencies, depends_on And Lifecycle Rules — HashiCorp Terraform Associate (004) Exam Prep
- Sensitive Data, Ephemeral Values And Secrets From Vault — HashiCorp Terraform Associate (004) Exam Prep
- Moved And Removed Blocks: Refactoring Without Rebuilding — HashiCorp Terraform Associate (004) Exam Prep
- Collaboration And Governance: Teams, Policies, Registry And Health — HashiCorp Terraform Associate (004) Exam Prep