Skip to main content

Infrastructure Deployment

Deployment

Pushing to main runs terraform plan via CodeBuild. Deploy locally (faster + free):

cd statux-infra/environments/prod
terraform plan # Review changes
terraform apply # Apply changes
warning

Always review the plan before applying. Destructive changes require extra care.

CodeBuild Projects

ProjectTriggerActions
statux-prod-codebuild-infra-planPush to mainFormat check → Init → Validate → Plan
statux-prod-codebuild-infra-applyManual onlyInit → Apply

To trigger apply via CodeBuild:

aws codebuild start-build --project-name statux-prod-codebuild-infra-apply

State Management

Terraform state is stored in S3 with DynamoDB locking:

  • Bucket: statux-terraform-state
  • Lock table: statux-terraform-locks

State Lock Issues

If a previous run failed and left a lock:

terraform force-unlock <LOCK_ID>

Viewing Plan Output (CodeBuild)

# Get recent builds
aws codebuild list-builds-for-project \
--project-name statux-prod-codebuild-infra-plan \
--max-items 3

# View in AWS Console
# CodeBuild > Build projects > statux-prod-codebuild-infra-plan > Build history