Stacks Deployment
The deployment workflow for Stacks applications.
Quick Deploy
buddy deploy
Preview the complete environment-aware plan before changing anything:
buddy deploy --dry-run
buddy deploy --dry-run --env staging
buddy deploy --dry-run --site docs
buddy deploy --dry-run --json
The preview uses the same environment transformation and ts-cloud site
classification as a real deploy. It reports the ordered validation,
infrastructure, build, package, release, runtime, gateway, DNS, TLS, and
optional container operations. It exits before prerequisite setup, builds,
packaging, hooks, provider calls, persistence, DNS, TLS, or service restarts.
The JSON form emits a versioned STACKS_DEPLOY_PREVIEW_JSON= line for API and
tool consumers.
Deployment Prerequisites
- AWS credentials configured:
buddy configure:aws
- APP_KEY generated:
buddy key:generate (must be colon-separated format)
- APP_URL set in
.env
- Team configured in
config/team.ts
Deployment Flow
- Validation — checks APP_KEY format, AWS region, app URL, team config
- Build — compiles application for production
- Infrastructure — generates CloudFormation template via ts-cloud
- Deploy — creates or updates the CloudFormation stack
- Capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM
- OnFailure: ROLLBACK
- Tags: Environment, Project, ManagedBy
Deploy Hooks (cloud/deploy-script.ts)
export default {
beforeDeploy({ environment, region }) {
// Build assets, run tests, send notifications
console.log(`Deploying to ${environment} in ${region}`)
},
afterDeploy({ environment, region, outputs }) {
// Cache warming, smoke tests, database seeding
console.log('Public IP:', outputs.PublicIp)
console.log('DNS:', outputs.DNS)
console.log('Endpoint:', outputs.Endpoint)
}
}
Deployment Modes
Server Mode (default)
- EC2 instances with ALB
- Best for: full-stack apps, WebSocket support, persistent connections
- Config:
config/cloud.ts → mode: 'server'
Serverless Mode
- Lambda + API Gateway + CloudFront
- Best for: API-only, cost optimization, auto-scaling
- Config:
config/cloud.ts → mode: 'serverless'
First Deployment Checklist
# 1. Configure AWS
buddy configure:aws
# 2. Generate app key
buddy key:generate
# 3. Set environment variables
buddy env:set APP_URL https://myapp.com
buddy env:set APP_ENV production
# 4. Review cloud config
# Edit config/cloud.ts
# 5. Deploy
buddy deploy
CLI Commands
buddy deploy # deploy to cloud
buddy deploy --dry-run # preview without changing anything
buddy cloud --diff # preview infrastructure changes before deploying
buddy cloud --ssh # SSH into deployed server
buddy cloud:remove # tear down infrastructure
buddy cloud:cleanup # clean retained resources
Gotchas
- First deployment creates the CloudFormation stack — subsequent deploys update it
- APP_KEY must be colon-separated format (validated during deployment)
- Default region is
us-east-1 (from AWS_DEFAULT_REGION env)
buddy cloud --diff shows changes BEFORE deploying — always review first
- Deploy hooks run in the deployment process, not on the target server
- For infrastructure details (EC2, Lambda, VPC, etc.), see the
stacks-cloud skill
1---2name: stacks-deploy-33description: Use when deploying a Stacks application — the deployment workflow (build → deploy), pre/post deploy hooks, server vs serverless mode selection, first-time deployment setup, deployment troubleshooting, or the buddy deploy command. For cloud infrastructure details (EC2, Lambda, CloudFormation, Route53, IAM), see stacks-cloud.4license: MIT5---67# Stacks Deployment89The deployment workflow for Stacks applications.1011## Quick Deploy1213```bash14buddy deploy15```1617Preview the complete environment-aware plan before changing anything:1819```bash20buddy deploy --dry-run21buddy deploy --dry-run --env staging22buddy deploy --dry-run --site docs23buddy deploy --dry-run --json24```2526The preview uses the same environment transformation and ts-cloud site27classification as a real deploy. It reports the ordered validation,28infrastructure, build, package, release, runtime, gateway, DNS, TLS, and29optional container operations. It exits before prerequisite setup, builds,30packaging, hooks, provider calls, persistence, DNS, TLS, or service restarts.31The JSON form emits a versioned `STACKS_DEPLOY_PREVIEW_JSON=` line for API and32tool consumers.3334## Deployment Prerequisites35361. **AWS credentials configured**: `buddy configure:aws`372. **APP_KEY generated**: `buddy key:generate` (must be colon-separated format)383. **APP_URL set** in `.env`394. **Team configured** in `config/team.ts`4041## Deployment Flow42431. **Validation** — checks APP_KEY format, AWS region, app URL, team config442. **Build** — compiles application for production453. **Infrastructure** — generates CloudFormation template via ts-cloud464. **Deploy** — creates or updates the CloudFormation stack47 - Capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM48 - OnFailure: ROLLBACK49 - Tags: Environment, Project, ManagedBy5051## Deploy Hooks (cloud/deploy-script.ts)5253```typescript54export default {55 beforeDeploy({ environment, region }) {56 // Build assets, run tests, send notifications57 console.log(`Deploying to ${environment} in ${region}`)58 },5960 afterDeploy({ environment, region, outputs }) {61 // Cache warming, smoke tests, database seeding62 console.log('Public IP:', outputs.PublicIp)63 console.log('DNS:', outputs.DNS)64 console.log('Endpoint:', outputs.Endpoint)65 }66}67```6869## Deployment Modes7071### Server Mode (default)72- EC2 instances with ALB73- Best for: full-stack apps, WebSocket support, persistent connections74- Config: `config/cloud.ts` → `mode: 'server'`7576### Serverless Mode77- Lambda + API Gateway + CloudFront78- Best for: API-only, cost optimization, auto-scaling79- Config: `config/cloud.ts` → `mode: 'serverless'`8081## First Deployment Checklist8283```bash84# 1. Configure AWS85buddy configure:aws8687# 2. Generate app key88buddy key:generate8990# 3. Set environment variables91buddy env:set APP_URL https://myapp.com92buddy env:set APP_ENV production9394# 4. Review cloud config95# Edit config/cloud.ts9697# 5. Deploy98buddy deploy99```100101## CLI Commands102103```bash104buddy deploy # deploy to cloud105buddy deploy --dry-run # preview without changing anything106buddy cloud --diff # preview infrastructure changes before deploying107buddy cloud --ssh # SSH into deployed server108buddy cloud:remove # tear down infrastructure109buddy cloud:cleanup # clean retained resources110```111112## Gotchas113- First deployment creates the CloudFormation stack — subsequent deploys update it114- APP_KEY must be colon-separated format (validated during deployment)115- Default region is `us-east-1` (from AWS_DEFAULT_REGION env)116- `buddy cloud --diff` shows changes BEFORE deploying — always review first117- Deploy hooks run in the deployment process, not on the target server118- For infrastructure details (EC2, Lambda, VPC, etc.), see the `stacks-cloud` skill