Deploy to AWS
Deploy the Pitfal Solutions website following this sequence:
Pre-deployment Checks
-
Verify all tests pass: pnpm test
-
Verify TypeScript compiles: pnpm type-check
-
Check for uncommitted changes: git status
Build Process
-
Build the Next.js application: pnpm build
-
Verify the out/ directory was created
Infrastructure Deployment
-
Navigate to terraform: cd infrastructure/terraform
-
Initialize if needed: terraform init
-
Plan changes: terraform plan -out=tfplan
-
Show plan summary to user and confirm before applying
-
Apply changes: terraform apply tfplan
Static Site Deployment
-
Sync static assets to S3: aws s3 sync out/ s3://pitfal-static-site
--delete
--cache-control "public, max-age=31536000, immutable"
--exclude "*.html"
--profile pitfal -
Sync HTML with no-cache: aws s3 sync out/ s3://pitfal-static-site
--cache-control "public, max-age=0, must-revalidate"
--include "*.html"
--profile pitfal
Post-deployment
Get CloudFront Distribution ID (if not already known):
Option 1: From Terraform output
cd infrastructure/terraform && terraform output cloudfront_distribution_id
Option 2: From AWS CLI (finds distribution for pitfal.solutions)
aws cloudfront list-distributions --profile pitfal
--query "DistributionList.Items[?contains(Aliases.Items, 'pitfal.solutions')].Id"
--output text
Option 3: Export as environment variable for reuse
export DISTRIBUTION_ID=$(terraform -chdir=infrastructure/terraform output -raw cloudfront_distribution_id)
Invalidate CloudFront cache:
aws cloudfront create-invalidation
--distribution-id $DISTRIBUTION_ID
--paths "/*"
--profile pitfal
--no-cli-pager
Note: Cache invalidation takes 1-5 minutes to propagate globally.
Verify site is accessible at https://pitfal.solutions
Run smoke tests if available
Rollback
If deployment fails:
-
Check Terraform state: terraform state list
-
Restore previous S3 version if needed
-
Provide specific rollback instructions based on failure point