Deployment Overview
This document covers the deployment architecture and process for the portfolio application.
Deployment Stack
| Component | Technology | |-----------|------------| | Build | OpenNext (Next.js to Lambda) | | Infrastructure | AWS CDK | | CI/CD | GitHub Actions | | CDN | CloudFront | | Compute | Lambda@Edge + Regional Lambda | | Storage | S3 + DynamoDB |
Deployment Flow

Pre-requisites
AWS Account Setup
- OIDC Provider - GitHub Actions assumes IAM role via OIDC
- Deploy Role - IAM role with CDK deployment permissions
- Domain (optional) - Route53 hosted zone
- Certificate (optional) - ACM certificate in us-east-1
GitHub Configuration
Repository variables:
AWS_REGION- Deployment region (default: us-east-1)CDK_DEPLOY_ROLE_ARN- IAM role for deploymentAPP_DOMAIN_NAME- Custom domainNEXT_PUBLIC_SITE_URL- Public URL
Repository secrets:
GH_TOKEN- GitHub PAT for API accessREVALIDATE_SECRET- ISR revalidation secretNEXTAUTH_SECRET- Auth session secret
Quick Deploy
First-Time Setup
- Configure AWS credentials:
aws configure
- Bootstrap CDK (once per account/region):
cd infra/cdk
pnpm exec cdk bootstrap
- Build and deploy:
# From root
pnpm build
cd infra/cdk
pnpm deploy
Subsequent Deploys
Push to main triggers automatic deployment:
git push origin main
Or manual deployment:
pnpm build
cd infra/cdk && pnpm deploy
Environment Tiers
| Environment | Branch | Domain | Purpose | |-------------|--------|--------|---------| | Production | main | example.com | Live site | | Staging | staging | staging.example.com | Pre-production testing | | Development | feature/* | - | Local development |
Post-Deploy Steps
After each deployment:
- Cache Invalidation - CloudFront paths invalidated
- Revalidation - ISR caches refreshed via API
- Smoke Tests - Automated integration tests
Rollback
Quick Rollback
Revert to previous commit:
git revert HEAD
git push origin main
CDK Rollback
CloudFormation automatically rolls back failed deployments. For manual rollback:
cd infra/cdk
pnpm exec cdk deploy --rollback
Monitoring
Post-deployment monitoring:
- CloudWatch Logs - Lambda execution logs
- CloudWatch Metrics - OpenAI cost tracking
- CloudFront Metrics - Request/error rates
- Smoke Test Results - GitHub Actions artifacts
Related Documentation
- CI/CD Pipeline - GitHub Actions workflow
- Environments - Environment configuration
- Infrastructure - AWS resources
