---
name: tf-apply
description: Apply a previously reviewed Terraform plan for the Book Review App (assumes plan has already been reviewed)
---

Apply the Terraform plan for the Book Review App. This skill assumes you have already run `/tf-plan` and reviewed the output.

Work from the `terraform/` directory.

## Pre-apply check
Verify that `tfplan.out` exists from a prior `/tf-plan` run. If it does not exist, stop and tell the user to run `/tf-plan` first. Do not run apply without a saved plan file — this prevents surprise changes.

Check that the plan file is recent (less than 30 minutes old based on file modification time). If it is stale, warn the user that the plan may no longer reflect the current state and recommend re-running `/tf-plan`.

## Apply
Run:
```
TF_APPLY_APPROVED=true terraform apply tfplan.out
```

The `TF_APPLY_APPROVED=true` prefix is required to pass the pre-tool-guard hook. Stream output as it runs. Do not use `-auto-approve` — the saved plan file already encodes approval.

## Post-apply
After apply completes:

1. Run `terraform output` and display all outputs. Highlight the `public_alb_dns` value as the app entry point.
2. Check for any resources that failed to create — if any exist, read the error and attempt to diagnose the root cause.
3. Print a short post-apply checklist:
   - [ ] Public ALB DNS resolves and returns HTTP 200
   - [ ] Internal ALB health checks passing (check via AWS Console or CLI)
   - [ ] RDS instance status is `available`
   - [ ] App tier EC2 instances are NOT reachable from the public internet

If apply succeeded cleanly, print:
"Apply complete. Access the app at: <public_alb_dns>
Run through the Validation Checklist in CLAUDE.md to confirm full functionality."
