teluzia.Cloud Engineer · Day 89
CHAPTER 13 · TERRAFORM FUNDAMENTALS

Plan/apply/destroy safety

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

A plan is the contractor’s proposed work order; apply authorizes that order and destroy proposes removing tracked objects. Read each addition, update, replacement, and deletion in the plan. Some attribute changes require replacement, which can affect identities and data. A saved plan records a particular proposal and may contain sensitive values; protect it and re-plan when relevant inputs or environment conditions change. Verify account, region, workspace, backend, and variables before apply. Applying a saved plan avoids silently reviewing one proposal then applying a different freshly generated proposal, but it still needs trustworthy inputs and a current operational context. Partial failures require investigation.

Think of it this way

A plan is the contractor’s proposed work order; apply authorizes that order and destroy proposes removing tracked objects.

TOPIC 01 / 03Step by step

Plan actions and replacements

Read each addition, update, replacement, and deletion in the plan. Some attribute changes require replacement, which can affect identities and data. A saved plan records a particular proposal and may contain sensitive values; protect it and re-plan when relevant inputs or environment conditions change. For example, a resource marked -/+ is being replaced rather than updated in place, which deserves careful dependency and downtime review.

WORKED EXAMPLE
A resource marked -/+ is being replaced rather than updated in place, which deserves careful dependency and downtime review.

A database identifier changes in configuration. The provider may report that the change requires replacement rather than an in-place update. The plan displays removal and creation behavior, and dependent resources may also change. Read those actions as operational consequences, not a harmless text diff.

An update modifies an existing object. Replacement substitutes another object, potentially changing identity or losing attached data. A saved plan captures a proposal with its inputs and planning context. Protect it because it may contain sensitive information. Review why each action occurs, how dependencies are affected, and whether the service imposes uniqueness or capacity constraints. Some values are unknown until apply, which limits what can be confirmed in advance. Plans provide essential evidence but cannot promise uninterrupted behavior or eliminate every service-time failure. Re-plan after relevant changes and apply the proposal that was actually reviewed rather than relying on memory of an older terminal output.

Why this matters

A resource marked -/+ is being replaced rather than updated in place, which deserves careful dependency and downtime review.

A common trap

Do not overlook this operational distinction: A saved plan records a particular proposal and may contain sensitive values; protect it and re-plan when relevant inputs or environment conditions change.

MAKE IT VISIBLE

Rehearse a release decision

A RELEASE IS A SERIES OF DECISIONS

Can you ship without losing the old version?

This browser simulation shows why tests, plan review, health validation and rollback belong in a pipeline.

1Tests
2Plan review
3Deploy
4Health check
Currently serving: v1

Ready to run

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Plan actions and replacements

Read each addition, update, replacement, and deletion in the plan. Some attribute changes require replacement, which can affect identities and data. A saved plan records a particular proposal and may contain sensitive values; protect it and re-plan when relevant inputs or environment conditions change. For example, a resource marked -/+ is being replaced rather than updated in place, which deserves careful dependency and downtime review.

WORKED EXAMPLE
A resource marked -/+ is being replaced rather than updated in place, which deserves careful dependency and downtime review.

A database identifier changes in configuration. The provider may report that the change requires replacement rather than an in-place update. The plan displays removal and creation behavior, and dependent resources may also change. Read those actions as operational consequences, not a harmless text diff.

An update modifies an existing object. Replacement substitutes another object, potentially changing identity or losing attached data. A saved plan captures a proposal with its inputs and planning context. Protect it because it may contain sensitive information. Review why each action occurs, how dependencies are affected, and whether the service imposes uniqueness or capacity constraints. Some values are unknown until apply, which limits what can be confirmed in advance. Plans provide essential evidence but cannot promise uninterrupted behavior or eliminate every service-time failure. Re-plan after relevant changes and apply the proposal that was actually reviewed rather than relying on memory of an older terminal output.

Why this matters

A resource marked -/+ is being replaced rather than updated in place, which deserves careful dependency and downtime review.

A common trap

Do not overlook this operational distinction: A saved plan records a particular proposal and may contain sensitive values; protect it and re-plan when relevant inputs or environment conditions change.

Apply identity and scope

Verify account, region, workspace, backend, and variables before apply. Applying a saved plan avoids silently reviewing one proposal then applying a different freshly generated proposal, but it still needs trustworthy inputs and a current operational context. Partial failures require investigation. For example, use aws sts get-caller-identity before cloud work and compare Account against the intended dedicated sandbox.

WORKED EXAMPLE
Use aws sts get-caller-identity before cloud work and compare Account against the intended dedicated sandbox.

An operator opens a development directory, but the AWS profile points to a production account and the backend key also targets production state. A safe workflow catches this before any apply: inspect caller account, region, backend, workspace where applicable, and variable inputs. Directory names and branch names describe intent but are not authoritative target verification.

Preflight checks verify execution context. Scope identifies owned objects and permitted operations. A partial apply means some requested actions completed before another failed. Applying a saved reviewed plan reduces proposal mismatch, but does not fix a wrong account selected during planning. After failure, inspect resulting state and remote resources, then produce a new plan; do not assume nothing happened. Separate routine deployment privileges from broad administrative credentials. A teammate should be able to read the evidence and understand exactly which environment and objects the operation will affect before authorizing the change.

Why this matters

Use aws sts get-caller-identity before cloud work and compare Account against the intended dedicated sandbox.

A common trap

Do not overlook this operational distinction: Partial failures require investigation.

Destroy and retained data

Destroy targets objects tracked by the current configuration/state context. It can remove important data and may be blocked by lifecycle settings or service constraints. Teardown requires verifying the intended practice scope and separately checking supporting or intentionally retained resources after the operation. For example, a local terraform_data exercise can be destroyed safely; a production database should never be removed merely to clear a failed practice command.

WORKED EXAMPLE
A local terraform_data exercise can be destroyed safely; a production database should never be removed merely to clear a failed practice command.

A learner finishes a local Terraform exercise and inspects a destroy plan. It proposes deleting only the tracked practice objects. In a cloud project, the same action might delete a database and its storage, while separately created load balancers or retained backups remain. Both deletion risk and residual cost require review.

Destroy proposes removal under the selected configuration/state context. A retained resource is deliberately left for recovery or another owner. A teardown inventory explains what should disappear and what may remain. Lifecycle constraints or service rules can block deletion, and removing a guardrail just to complete a command can erase important data. Confirm ownership and data retention before execution. Afterward, inspect the relevant owned-resource inventory instead of assuming a successful exit proves the whole account is empty. Teardown is an operational process with verification, not merely a final command appended to every tutorial.

Why this matters

A local terraform_data exercise can be destroyed safely; a production database should never be removed merely to clear a failed practice command.

A common trap

Do not overlook this operational distinction: Teardown requires verifying the intended practice scope and separately checking supporting or intentionally retained resources after the operation.

KEEP THESE WITH YOU

Today’s takeaways

Plan actions and replacements: Read each addition, update, replacement, and deletion in the plan. Some attribute changes require replacement, which can affect identities and data. A saved plan records a particular proposal and may contain sensitive values; protect it and re-plan when relevant inputs or environment conditions change.

Apply identity and scope: Verify account, region, workspace, backend, and variables before apply. Applying a saved plan avoids silently reviewing one proposal then applying a different freshly generated proposal, but it still needs trustworthy inputs and a current operational context. Partial failures require investigation.

Destroy and retained data: Destroy targets objects tracked by the current configuration/state context. It can remove important data and may be blocked by lifecycle settings or service constraints. Teardown requires verifying the intended practice scope and separately checking supporting or intentionally retained resources after the operation.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed