Introduction
Your team has committed a report-store proposal. A successful plan is ready for inspection, but it has not yet been reviewed or applied. The delivery workflow must consume the specific artifact that was reviewed and still respect Terraform's current state.
You will try an unreviewed artifact, bind a review to its exact context, apply the approved plan, and observe a second saved plan become stale. You will then generate, review and apply a fresh plan. This is a local workflow with persistent records and a supplied execution entry point; it demonstrates review admission and state consistency, without claiming administrative tamper resistance.
You should understand saved-plan artifacts, module tests, Git revision selection, Terraform state locking and separate environments. This lab starts independently with existing report stores and a prepared source proposal; it does not reuse any earlier VM.
Certification Relevance
| Certification | Exam task | Practice |
|---|---|---|
| DevOps Engineer – Professional (DOP-C02) | Task 1.3 | Foundational artifact-lifecycle practice: review a particular saved plan, consume that artifact and handle its invalidation after a state change. |

Prepare Specific Artifacts Before Review
In this step, you will create two saved plans from the same committed proposal and prove that an unreviewed plan cannot pass the supplied application entry point.
Enter the prepared repository and load its tools.
cd /home/labex/project/report-release
source environment.sh
Read the proposal, quality stages and recent history.
cat release.auto.tfvars.json pipeline.json
git log --oneline -2
The prepared proposal requests release-two and release two report. The current preview and review stores still contain release one report. Their state files are separate. The neighboring delivery-release-neighbor/keep.txt is unrelated data to preserve. Keep the supplied module, provider, lock, tests, executors and quality stages intact.
Record the full commit identifier you intend to release. The selection file is untracked request information; later commands use its contents rather than follow a moving HEAD.
git rev-parse HEAD > selected-revision.txt
Generate the first preview artifact. The command substitution reads the selected commit into --revision; --environment preview explicitly selects the target.
python3 delivery.py plan release-two --revision "$(cat selected-revision.txt)" --environment preview
Expect fmt, validate and plan-mode tests to pass, followed by a native plan with two updates and no additions or deletions. Native plan exit 2 means changes exist; the delivery command returns 0 because it produced the artifact successfully.
Generate a second artifact for the same source and current state. Its separate name represents a plan that will be delayed while another approved execution proceeds.
python3 delivery.py plan delayed-two --revision "$(cat selected-revision.txt)" --environment preview
Both plans currently propose the same release. Each has its own binary plan, readable/JSON views and recorded context. Neither has been applied.
Try the first plan through the application entry point before reviewing it. This command intentionally returns exit 1.
python3 delivery.py apply release-two --revision "$(cat selected-revision.txt)" --environment preview
Expect No matching review of this concrete artifact. The result records native_exit: null: admission stopped before a Terraform apply command was run. This differs from a native Terraform failure. A plan's existence does not grant approval.
Read the current preview report.
aws s3 cp s3://delivery-release-preview/report.txt -
It must still say release one report. Both plans and the refused request have left the business environment unchanged.
Review and Apply the Concrete Plan
In this step, you will review the actual proposed actions and record approval for the exact artifacts. The review persists across the separate delivery commands.
Inspect the first plan.
python3 delivery.py inspect release-two
Confirm the saved plan targets delivery-release-preview, updates the release tag and report content to the requested values, and has no additions or deletions. Its revision must match selected-revision.txt; its source, lock and binary-plan fingerprints identify the concrete review object.
Record the review using the same artifact, revision and environment.
python3 delivery.py review release-two --revision "$(cat selected-revision.txt)" --environment preview
Expect review_recorded: true. This records a local workflow decision; it is not a Terraform resource operation. A different source revision, environment or changed artifact would not match this review.
Inspect the delayed artifact as a separate review object. Confirm the same requested revision, preview environment and two intended updates.
python3 delivery.py inspect delayed-two
Record its own review. A matching proposal does not make the two artifact records interchangeable.
python3 delivery.py review delayed-two --revision "$(cat selected-revision.txt)" --environment preview
Apply only the first artifact.
python3 delivery.py apply release-two --revision "$(cat selected-revision.txt)" --environment preview
The entry point rechecks the selected context, exact artifact bytes and matching persisted review, then invokes native Terraform on the saved binary plan. Its supplied writer lock serializes this workflow's writes, while Terraform handles backend state locking. Expect native apply exit 0 and two changed resources. The command consumes the saved proposal rather than silently generating another plan.
Read the actual deployed report.
aws s3 cp s3://delivery-release-preview/report.txt -
It should now say release two report. Inspect the actual bucket tags as well.
aws s3api get-bucket-tagging --bucket delivery-release-preview
Expect Environment=preview and Release=release-two. Storage data and tags prove that the intended environment changed; a successful command alone would not establish that outcome.
Refuse the Stale Plan and Review a Fresh One
In this step, you will observe why approval alone cannot make a saved plan current. The first apply advanced preview's state after both plans were generated. The delayed plan retains its original state snapshot even though its source and review still match.
Try applying the already-reviewed delayed artifact. This command intentionally returns exit 1.
python3 delivery.py apply delayed-two --revision "$(cat selected-revision.txt)" --environment preview
Expect Terraform's actual Saved plan is stale diagnostic and native exit 1. This time the workflow admitted the matching reviewed artifact, but native Terraform refused its outdated state context. The completed release must remain intact. Do not rewrite state or delete the state file to bypass this refusal.
Generate a new artifact against current state, keeping the same explicitly selected source and environment.
python3 delivery.py plan release-current --revision "$(cat selected-revision.txt)" --environment preview
Expect a successful artifact with native plan exit 0: the requested release is already deployed. No changes is a valid result, distinct from an execution error. A new artifact still requires its own review.
Inspect the regenerated proposal and its context.
python3 delivery.py inspect release-current
Confirm it describes no changes and still identifies the chosen revision and preview environment. Its concrete plan and generation record differ from the old delayed artifact.
Review this new artifact.
python3 delivery.py review release-current --revision "$(cat selected-revision.txt)" --environment preview
Apply it through the same entry point.
python3 delivery.py apply release-current --revision "$(cat selected-revision.txt)" --environment preview
Expect native apply exit 0 with no resource changes. Review is bound to an artifact; it is not a general permission to apply any later plan. Terraform's stale-plan check concerns its recorded state and does not establish that nothing outside Terraform has changed; the next lab introduces a separate observation workflow.
Confirm the current preview report is retained.
aws s3 cp s3://delivery-release-preview/report.txt -
Expect release two report. Check the neighboring environment.
aws s3 cp s3://delivery-release-review/report.txt -
It must still say release one report. Finally, read the unrelated data.
aws s3 cp s3://delivery-release-neighbor/keep.txt -
Expect preserve release neighbor. You updated an existing store and created local artifacts, without creating a separate cloud stack. Preserve the deployed release, both existing state files and neighboring resources for assessment.
Summary
You separated planning, reviewing and applying; refused an unreviewed request; and verified actual report/tag changes after consuming a reviewed binary plan. A second reviewed plan then failed Terraform's native stale-plan check after state advanced. You generated, inspected and reviewed a fresh no-change artifact before applying it successfully, preserving the other environment and unrelated data.
This workflow binds a local review to exact artifact context and delegates state freshness checks to native Terraform. It does not turn an approval into blanket authority for new artifacts. See the official saved-plan application reference for the Terraform operation used by the supplied entry point.



