Deployment Guide
This guide covers deployment strategies, best practices, and production considerations for your Wrist Agent system.
Deployment Methods
Local Deployment
Deploy directly from your development machine using AWS CDK.
Prerequisites:
- AWS CLI configured with appropriate credentials
- Node.js 18+ and npm installed
- Go 1.22+ installed
Steps:
# Clone and setup
git clone https://github.com/Stealinglight/wrist-agent.git
cd wrist-agent
# Install dependencies
cd cdk && npm install && cd ..
cd lambda && go mod tidy && cd ..
# Bootstrap CDK (first time only)
cd cdk
npx cdk bootstrap
# Deploy
npx cdk deploy --require-approval never
# Note the outputs
When to use:
- Initial setup and testing
- Development iterations
- Personal deployments
- Quick prototyping
GitHub Actions Deployment
Automated deployment using GitHub Actions with OIDC authentication.
Prerequisites:
- GitHub repository (fork or your own)
- AWS OIDC provider configured
- IAM role for GitHub Actions
Setup:
# 1. Create OIDC provider (one-time)
aws iam create-open-id-connect-provider \
--url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.com \
--thumbprint-list 6938fd4d98bab03faadb97b34396831e3780aea1
# 2. Create IAM role for GitHub Actions
cat > github-trust-policy.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:YOUR_GITHUB_USERNAME/wrist-agent:*"
}
}
}
]
}
EOF
# Replace ACCOUNT_ID and YOUR_GITHUB_USERNAME
aws iam create-role \
--role-name WristAgentGitHubActions \
--assume-role-policy-document file://github-trust-policy.json
# 3. Attach permissions
# Note: PowerUserAccess grants broad permissions. For production deployments,
# create a custom policy with only the required permissions:
# - cloudformation:* (for CDK stack management)
# - lambda:* (for function deployment)
# - iam:GetRole, iam:PassRole (limited IAM access)
# - ssm:GetParameter, ssm:PutParameter (for parameter store)
# - bedrock:InvokeModel (for Bedrock access)
# - logs:CreateLogGroup, logs:PutRetentionPolicy (for CloudWatch)
# For quick setup, you can use PowerUserAccess:
aws iam attach-role-policy \
--role-name WristAgentGitHubActions \
--policy-arn arn:aws:iam::aws:policy/PowerUserAccess
# 4. Configure GitHub secrets
# Repository → Settings → Secrets and variables → Actions
# Add secret: AWS_ROLE_ARN = arn:aws:iam::ACCOUNT_ID:role/WristAgentGitHubActions
Workflow:
# .github/workflows/deploy.yml
name: Deploy to AWS
on:
push:
branches: [main]
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-west-2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Deploy CDK
run: |
cd cdk
npm ci
npx cdk bootstrap --require-approval never
npx cdk deploy --require-approval never
When to use:
- Production deployments
- Team environments
- Continuous delivery
- Automated testing
Environment Configuration
Development Environment
Optimized for fast iteration and debugging.
# .env.development
AWS_REGION=us-west-2
AWS_PROFILE=dev
BEDROCK_MODEL_ID=anthropic.claude-haiku-4-5-20251001-v1:0
CLIENT_TOKEN_PARAM_NAME=/wrist-agent/dev/client-token
LAMBDA_TIMEOUT=60
LAMBDA_MEMORY=512
LOG_LEVEL=DEBUG
Characteristics:
- Extended timeouts for debugging
- Debug logging enabled
- Separate SSM parameter namespace
- Lower cost priority over performance
Staging Environment
Production-like environment for testing.
# .env.staging
AWS_REGION=us-west-2
AWS_PROFILE=staging
BEDROCK_MODEL_ID=anthropic.claude-haiku-4-5-20251001-v1:0
CLIENT_TOKEN_PARAM_NAME=/wrist-agent/staging/client-token
LAMBDA_TIMEOUT=30
LAMBDA_MEMORY=256
LOG_LEVEL=INFO
Characteristics:
- Production-equivalent configuration
- Same region as production
- Separate authentication tokens
- Full monitoring enabled
Production Environment
Optimized for reliability and performance.
# .env.production
AWS_REGION=us-west-2
AWS_PROFILE=production
BEDROCK_MODEL_ID=anthropic.claude-haiku-4-5-20251001-v1:0
CLIENT_TOKEN_PARAM_NAME=/wrist-agent/client-token
LAMBDA_TIMEOUT=30
LAMBDA_MEMORY=256
LOG_LEVEL=INFO
ENABLE_XRAY=true
Characteristics:
- Optimized memory allocation
- Production timeout limits
- X-Ray tracing enabled
- CloudWatch alarms configured
Multi-Region Deployment
Deploy to multiple regions for redundancy or regional requirements.
Primary Region (us-west-2)
export AWS_REGION=us-west-2
cd cdk
npx cdk deploy --context region=us-west-2
Secondary Region (eu-west-1)
export AWS_REGION=eu-west-1
cd cdk
npx cdk bootstrap
npx cdk deploy --context region=eu-west-1
Region Selection Considerations
us-west-2 (Oregon):
- ✅ Full Bedrock model availability
- ✅ Lower latency for US West Coast
- ✅ Typically lower costs
us-east-1 (N. Virginia):
- ✅ Full Bedrock model availability
- ✅ Lower latency for US East Coast
- ✅ Most services available first
eu-west-1 (Ireland):
- ✅ GDPR compliance
- ✅ Lower latency for Europe
- ⚠️ Check Bedrock model availability
Blue-Green Deployment
Zero-downtime deployment strategy.
// cdk/lib/blue-green-stack.ts
import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
export class BlueGreenStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Blue version (current)
const blueFunction = new lambda.Function(this, 'BlueFunction', {
// ... configuration
});
// Green version (new)
const greenFunction = new lambda.Function(this, 'GreenFunction', {
// ... configuration
});
// Alias for gradual traffic shifting
const alias = new lambda.Alias(this, 'LiveAlias', {
aliasName: 'live',
version: blueFunction.currentVersion,
});
// CodeDeploy for traffic shifting
new codedeploy.LambdaDeploymentGroup(this, 'DeploymentGroup', {
alias: alias,
deploymentConfig: codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
});
}
}
Infrastructure as Code Best Practices
Version Control
# Tag releases
git tag -a v1.0.0 -m "Production release 1.0.0"
git push origin v1.0.0
# Deploy specific version
git checkout v1.0.0
cd cdk
npx cdk deploy
CDK Stack Organization
// cdk/bin/app.ts
import * as cdk from 'aws-cdk-lib';
import { WristAgentStack } from '../lib/wrist-agent-stack';
import { MonitoringStack } from '../lib/monitoring-stack';
const app = new cdk.App();
// Main application stack
const appStack = new WristAgentStack(app, 'WristAgentStack', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
},
});
// Monitoring stack (separate lifecycle)
new MonitoringStack(app, 'WristAgentMonitoring', {
functionArn: appStack.function.functionArn,
});