09

Promote One Artifact Across Four Environments

Make local, dev, staging, and production differ by configuration and scale—not by manually reconstructed architecture.

The enterprise problem and today’s slice

Enterprise problem: A workflow that works on a laptop is not production-ready if each environment uses different topology, mutable image tags, shared credentials, or undocumented console changes.

Whole-course context: The application and security boundaries now exist. Today turns them into repeatable infrastructure and a controlled release path.

Today’s slice: Use Compose with PostgreSQL and LocalStack locally; provision VPC, ECS Fargate, RDS, EventBridge, SQS/DLQs, KMS, S3, ECR, logs, and per-service IAM with Terraform elsewhere.

End-of-day evidence: One image digest progresses local → dev → staging → production, a stale promotion is rejected, and a failed canary rolls back to the previous digest.

Still unsolved: Day 10 proves recovery across the whole workflow under combined failures.

Repository lab

Use the Terraform environment roots and local Compose topology.

const decision = await this.canaries.evaluate(command);
if (!decision.approved) {
  await this.deployments.rollback({
    tenantId: command.tenantId,
    releaseId: command.releaseId,
    environment: command.environment,
    previousArtifactDigest: promotion.previousArtifactDigest,
  });
  throw new CanaryRejectedError(`Canary rejected promotion: ${decision.reason}`);
}

Release policy lives in one use case; ECS, a test double, or another deployment target implements the injected gateway.

from laptop to controlled production

Same service contract

The deployable is content-addressed once.

Never promote a mutable tag as release identity.

Local dependency parity

Developers exercise the same dependency categories without cloud credentials.

Local emulation may reduce scale, never security boundaries or contract shape.

Environment configuration

DRY infrastructure with reviewed differences in capacity, retention, and safeguards.

Put environment variance in typed inputs, not copied resources or console state.

Workload isolation

Network, data, and identity boundaries match service ownership.

A service receives only the database, queue, secret, and event permissions it needs.

Progressive release

Promotion is an evidence-backed state transition with compare-and-swap protection.

Promote the same digest in order; reject stale expected state and automate rollback on failed health criteria.

Implementation and verification

Run terraform fmt -check, terraform validate, docker compose config, pnpm verify, and pnpm smoke:product. Plan dev and production with different variable files and inspect every IAM diff. Simulate a failed canary and confirm the recorded active digest returns to the prior value.

Practical next action and falsifiable evidence

The claim is falsified if an environment is rebuilt manually, a mutable tag reaches production, two services share an unrestricted role, or failed canary traffic remains on the rejected digest. Passing evidence contains the Terraform plan, image digest, promotion events, canary decision, rollback receipt, and active deployment digest.