Environment Reset

Resetting an ephemeral environment to a clean, seeded baseline is a single command. Instead of hand-assembling the wipe-runner invocation and the env-seed step (and verifying each through CloudWatch), run pnpm script reset-environment and read its output.

When to use it

  • Before a demo on an ephemeral (pr0001pr9999) environment, so you start from the known-good integration baseline.
  • Any time an ephemeral environment's data has drifted and you want it reset.

This command is ephemeral-only. It refuses integration and production before touching any data.

Prerequisites

  • Your .env points at the target environment: pnpm script update-env <N>.
  • AWS_PROFILE and AWS_REGION are set in .env.
  • Your AWS identity has lambda:InvokeFunction on the environment's wipe-runner function (see Deploy Role Permissions).

The command

pnpm script update-env <N>         # once, to point .env at the target
pnpm script reset-environment <N>  # wipe + reseed in one step

What it does

  1. Wipes PostgreSQL via the in-VPC wipe-runner Lambda (invoked with force).
  2. Reseeds Cognito users from integration, the same baseline a fresh ephemeral deploy seeds. The optional S3 copy step in reseed logs a no-op when there is no content bucket to copy.

The command prints the wipe stats, a reseed-complete line, and a final ✅ Environment "<env>" reset (wiped + reseeded) successfully.

Failure behavior

If either half fails, the command exits non-zero and prints the failing step (❌ Reset FAILED during wipe … or ❌ Reset FAILED during reseed …) with the underlying cause. A failed wipe never proceeds to reseed. Nothing is silently swallowed, matching the loud env-seed behavior in the deploy pipeline.

Caveats

  • Ephemeral only. Integration and production are refused up front.
  • CI can re-dirty the environment. If CI redeploys or reruns against the same environment after you reset it, it can repopulate test data. Run the reset immediately before your demo.
  • Baseline scope. The reseed copies Cognito users. Postgres tables are truncated by the wipe but not repopulated by the baseline seed, matching deploy-time ephemeral seeding in this repository.