From DSG Governance Control Plane
Deploy and manage DSG ONE / ProofGate control plane infrastructure on AWS using CDK. Automate the complete deployment pipeline: CloudFormation stack creation, resource validation, Secrets Manager integration, ECS cluster setup, ALB configuration, database provisioning, and post-deployment verification. Use this skill when deploying to AWS (dev, staging, production), verifying infrastructure health, documenting AWS resources, and troubleshooting CloudFormation issues. Also covers: stack naming conventions, resource tagging, environment configuration, cost tracking, and disaster recovery procedures.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dsg-governance:dsg-infrastructure-deployerThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Automated deployment and lifecycle management of **DSG ONE / ProofGate Control Plane** infrastructure on AWS.
Automated deployment and lifecycle management of DSG ONE / ProofGate Control Plane infrastructure on AWS.
| Intent | Use this skill |
|---|---|
| "Deploy DSG to AWS dev/staging/production" | ✅ Yes — full CDK deployment pipeline |
| "Verify AWS infrastructure is healthy" | ✅ Yes — health checks and diagnostics |
| "Check deployment status and resource count" | ✅ Yes — CloudFormation status monitoring |
| "Document AWS resource outputs" | ✅ Yes — automated capture and templating |
| "Troubleshoot CloudFormation deployment failure" | ✅ Yes — error diagnosis and recovery |
| "Update infrastructure configuration" | ✅ Yes — CDK synth and targeted updates |
| "Set up production AWS accounts" | ✅ Yes — account setup and IAM configuration |
| "Build a generic AWS app (not DSG)" | ❌ Out of scope — use AWS CDK docs directly |
1. CHECK ENVIRONMENT
✓ AWS credentials available (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
✓ AWS region configured (AWS_REGION, default: us-east-1)
✓ AWS account ID known (AWS_ACCOUNT_ID)
✓ CDK CLI available (npm exec cdk)
✓ Node.js and npm installed
2. VALIDATE CONFIGURATION
✓ Environment type specified (dev, staging, prod)
✓ Stack name follows convention: dsg-one-{env}-v2
✓ No conflicting CloudFormation stacks
✓ Supabase connection configured (if database required)
✓ Docker registry configured (if ECR push needed)
3. REVIEW CONSTRUCTS
✓ Networking (VPC, subnets, NAT, security groups)
✓ ECS (cluster, Fargate task definition, service)
✓ ALB (load balancer, listeners, target groups)
✓ Database (DynamoDB tables)
✓ Storage (S3 buckets for evidence, CloudTrail logs)
✓ Security (KMS encryption keys, Secrets Manager)
✓ Monitoring (CloudWatch logs, X-Ray)
✓ Audit (CloudTrail, VPC Flow Logs)
cd infra/cdk
npx cdk synth --require-approval=never
# Review generated CloudFormation template
# Expected output: DSGOneStack-{env}.template.json (~80KB)
cd infra/cdk
npx cdk deploy --require-approval=never
# Expected duration: 15-45 minutes for first deployment
# CloudFormation creates ~75 resources
# Outputs: ALB DNS, ECS cluster ARN, RDS endpoint (if applicable)
1. VERIFY CLOUDFORMATION
✓ Stack status: CREATE_COMPLETE or UPDATE_COMPLETE
✓ Resource count: 75 resources created
✓ No DELETE_FAILED or CREATE_FAILED resources
✓ Stack outputs available (ALB DNS, RDS endpoint, etc.)
2. HEALTH CHECKS
✓ curl GET /api/health → 200 OK
✓ curl GET /api/readiness → ready: true
✓ curl GET /api/agent/status → deployment info
✓ AWS ECS service running desired task count
✓ ALB health checks passing (target group healthy)
✓ RDS database accepting connections
✓ Secrets Manager secrets accessible
3. RESOURCE VALIDATION
✓ VPC CIDR: 10.0.0.0/16 (configurable)
✓ Subnets: 2 public + 2 private (multi-AZ)
✓ NAT Gateway: 1 per AZ (for private egress)
✓ ECS cluster: Running tasks = desired count
✓ ALB: Listening on :80 and :443
✓ DynamoDB tables: 3 tables (policies, audit, replay-proofs)
✓ S3 buckets: Evidence bucket + CloudTrail bucket + CDK bucket
✓ KMS keys: Master key + data key, rotation enabled
✓ Secrets: api-secrets, database-secrets, oauth-secrets
4. SECURITY VERIFICATION
✓ All data encrypted at rest (KMS)
✓ All data encrypted in transit (TLS)
✓ IAM roles follow least-privilege principle
✓ RLS policies on Supabase tables (if using)
✓ VPC endpoints for private service access
✓ Security groups restrict traffic to required ports
✓ CloudTrail logging enabled
✓ CloudWatch Logs retention configured
5. COMPLIANCE READINESS
✓ Audit trail tables created (DynamoDB)
✓ Evidence bucket configured (S3)
✓ Compliance matrix seeded
✓ CCVS pipeline ready for evidence collection
{
environment: "dev",
vpcCidr: "10.0.0.0/16",
ecsDesiredCount: 1, // Single task for cost savings
ecsTaskMemory: 512, // Minimal for dev
rdsInstanceClass: "t3.micro", // Minimal for dev
enableAutoScaling: false,
enableCloudTrail: true,
cloudWatchRetention: 7, // Days
backupRetention: 7,
tags: { Environment: "dev", ManagedBy: "CDK" }
}
{
environment: "staging",
vpcCidr: "10.0.0.0/16",
ecsDesiredCount: 2,
ecsTaskMemory: 1024,
rdsInstanceClass: "t3.small",
enableAutoScaling: true,
enableCloudTrail: true,
cloudWatchRetention: 30,
backupRetention: 30,
tags: { Environment: "staging", ManagedBy: "CDK" }
}
{
environment: "prod",
vpcCidr: "10.0.0.0/16",
ecsDesiredCount: 3,
ecsTaskMemory: 2048,
rdsInstanceClass: "t3.large", // Or dedicated provisioned throughput
enableAutoScaling: true,
enableCloudTrail: true,
enableVPCFlowLogs: true,
cloudWatchRetention: 365, // 1 year
backupRetention: 90,
enableMultiAZ: true, // RDS multi-AZ for HA
enableBackupVault: true, // AWS Backup for disaster recovery
tags: { Environment: "prod", ManagedBy: "CDK", CostCenter: "Engineering" }
}
DSG uses a versioned stack naming convention to avoid CloudFormation conflicts:
Pattern: dsg-one-{environment}-v{number}
Examples:
dsg-one-dev-v1 (old, may be stuck in DELETE_FAILED)
dsg-one-dev-v2 (current)
dsg-one-dev-v3 (next version if v2 conflicts)
dsg-one-staging-v1
dsg-one-prod-v1
Why versioning?
DELETE_FAILED if the old stack can't clean up resources-v{N} suffix (e.g., dsg-policy-table-v2)# 1. Verify environment
echo $AWS_REGION # Should be us-east-1
echo $AWS_ACCOUNT_ID # Should be 121205961822
# 2. Synth
cd infra/cdk && npx cdk synth --require-approval=never
# 3. Deploy
npx cdk deploy --require-approval=never
# 4. Verify
curl https://<ALB_DNS>/api/health
npm run go:no-go https://<ALB_DNS>
# Make changes to CDK constructs
# e.g., update infra/cdk/lib/constructs/ecs.ts
# Synth to see what will change
cd infra/cdk && npx cdk synth --require-approval=never
# Review the diff (CDK shows what will be added/modified/removed)
# Deploy targeted stack
npx cdk deploy DSGOneStack-dev --require-approval=never
# Verify changes
curl https://<ALB_DNS>/api/agent/status
# Check CloudFormation stack status
aws cloudformation describe-stacks --stack-name dsg-one-dev-v2 --region us-east-1
# If stack is in CREATE_FAILED or DELETE_FAILED:
# Option 1: Rename stack and redeploy (dsg-one-dev-v3)
# Option 2: Manually delete via AWS Console → CloudFormation → Delete Stack
# Check specific resource failure
aws cloudformation describe-stack-resources \
--stack-name dsg-one-dev-v2 \
--query 'StackResources[?ResourceStatus==`CREATE_FAILED`]' \
--region us-east-1
# Review CDK build errors
cd infra/cdk && npx cdk synth --require-approval=never
npm run typecheck
# Use the provided capture script
./scripts/capture-aws-outputs.sh \
--stack-name dsg-one-dev-v2 \
--region us-east-1 \
--environment dev
# Generates:
# - docs/infrastructure/DSG_AWS_Infrastructure_Outputs.md
# - docs/infrastructure/dsg-aws-outputs.json
# - docs/infrastructure/dsg-aws-outputs.env (for reference only, never commit)
# Build Next.js app
npm run build
# Build Docker image
docker build -t dsg-control-plane:latest .
# Push to ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com
docker tag dsg-control-plane:latest <ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/dsg-api:latest
docker push <ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/dsg-api:latest
# Update ECS task definition and service
aws ecs update-service \
--cluster dsg-one-dev-v2 \
--service dsg-service \
--force-new-deployment
# Add Route53 record pointing to ALB
aws route53 change-resource-record-sets \
--hosted-zone-id <ZONE_ID> \
--change-batch file://route53-change.json
# Request ACM certificate (if not using AWS-managed)
# Or use existing certificate in ALB listener
# Enable detailed CloudWatch metrics
aws cloudwatch put-metric-alarm \
--alarm-name dsg-alb-unhealthy-targets \
--alarm-description "Alert if ALB has unhealthy targets" \
--metric-name UnHealthyHostCount \
--namespace AWS/ApplicationELB \
--statistic Sum \
--period 300 \
--threshold 1 \
--comparison-operator GreaterThanOrEqualToThreshold
# Set up SNS notifications
aws sns subscribe \
--topic-arn <SNS_TOPIC> \
--protocol email \
--notification-endpoint [email protected]
Cause: Previous CDK deploy didn't complete or is still running
Solution:
# Option 1: Wait for process to finish
ps aux | grep cdk
# If still running, wait 30+ minutes
# Option 2: Check stack events for specific resource
aws cloudformation describe-stack-events \
--stack-name dsg-one-dev-v2 \
--query 'StackEvents[0:10]' \
--region us-east-1
# Option 3: If truly stuck, increment version
# Edit infra/cdk/bin/dsg-one.ts
# Change stackName from dsg-one-dev-v2 to dsg-one-dev-v3
# Run: npx cdk deploy --require-approval=never
Cause: ECS task is crashing or not responding to health checks
Solution:
# Check ECS task logs
aws ecs describe-tasks \
--cluster dsg-one-dev-v2 \
--tasks <TASK_ARN> \
--region us-east-1
# Get CloudWatch logs
aws logs tail /ecs/dsg-control-plane --follow
# Common issues:
# - Missing environment variables (check ECS task definition)
# - Database connection failed (check Supabase)
# - Port mismatch (ALB expects :3000, ECS using :8080?)
Cause: CloudFormation tries to delete non-empty S3 buckets
Solution:
# Option 1: Empty buckets before deletion
aws s3 rm s3://dsg-cloudtrail-bucket-<account> --recursive
aws s3 rm s3://dsg-evidence-bucket-<account> --recursive
# Option 2: Disable auto-deletion in CDK
# Edit infra/cdk/lib/constructs/s3.ts
// removalPolicy: cdk.RemovalPolicy.DESTROY,
// → removalPolicy: cdk.RemovalPolicy.RETAIN,
# Then retry stack deletion
aws cloudformation delete-stack --stack-name dsg-one-dev-v2
Cause: Table names like dsg-policy-table already exist from previous deployment
Solution:
# Update table names with -v2 suffix in CDK
# infra/cdk/lib/constructs/governance.ts
// tableName: 'dsg-policy-table-v2',
# Or use auto-generated names (recommended)
// CDK auto-generates unique names without explicit tableName
# Then deploy new version (dsg-one-dev-v3)
npx cdk deploy --require-approval=never
✅ Deployment is ready when:
CREATE_COMPLETEGET /api/health returns 200 OKGET /api/readiness returns ready: trueGET /api/agent/status returns deployment info✅ Production readiness when:
npm run go:no-go https://<PROD_URL> passesnpx claudepluginhub tdealer01-crypto/tdealer01-crypto-dsg-control-plane --plugin dsg-governanceValidate DSG ONE / ProofGate control plane is production-ready across infrastructure, compliance, security, and governance dimensions. Run comprehensive checks on AWS resources, Supabase database, deterministic gates, evidence collection, audit trails, and compliance matrices. Use when preparing for production GO/NO-GO decision, audit preparation, certification compliance checks, or pre-deployment verification. Produces compliance evidence pack, audit readiness report, governance validation, and GO/NO-GO verdict with proof hash for deterministic replay.
Handles deployment automation: containerization, CI/CD pipelines, cloud provisioning, and environment configuration with structured progress output and configurable autonomy levels.
Deploys infrastructure to staging or production using Terraform, Pulumi, CDK, Fly, or Railway. Enforces environment promotion, CI/CD checks, cost gates, safety layers, and resource tracking.