| name | dsg-infrastructure-deployer |
| version | 1.0.0 |
| author | DSG Team |
| license | MIT |
| description | 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 inte |
DSG Infrastructure Deployer
Automated deployment and lifecycle management of DSG ONE / ProofGate Control Plane infrastructure on AWS.
When to invoke this skill
| 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 |
Core deployment workflow
Phase 1: Pre-deployment validation
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)
Phase 2: Synth and dry-run
cd infra/cdk
npx cdk synth --require-approval=never
Phase 3: Deploy infrastructure
cd infra/cdk
npx cdk deploy --require-approval=never
Phase 4: Post-deployment verification
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
Configuration by environment
Development (dev)
{
environment: "dev",
vpcCidr: "10.0.0.0/16",
ecsDesiredCount: 1,
ecsTaskMemory: 512,
rdsInstanceClass: "t3.micro",
enableAutoScaling: false,
enableCloudTrail: true,
cloudWatchRetention: 7,
backupRetention: 7,
tags: { Environment: "dev", ManagedBy: "CDK" }
}
Staging
{
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" }
}
Production (prod)
{
environment: "prod",
vpcCidr: "10.0.0.0/16",
ecsDesiredCount: 3,
ecsTaskMemory: 2048,
rdsInstanceClass: "t3.large",
enableAutoScaling: true,
enableCloudTrail: true,
enableVPCFlowLogs: true,
cloudWatchRetention: 365,
backupRetention: 90,
enableMultiAZ: true,
enableBackupVault: true,
tags: { Environment: "prod", ManagedBy: "CDK", CostCenter: "Engineering" }
}
Stack naming and versioning
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?
- CloudFormation can get stuck in
DELETE_FAILED if the old stack can't clean up resources
- Incrementing version allows immediate redeployment without waiting
- Old stacks can be manually cleaned up later
- Resource naming also uses
-v{N} suffix (e.g., dsg-policy-table-v2)
Common deployment scenarios
Scenario 1: Fresh deployment to dev
echo $AWS_REGION
echo $AWS_ACCOUNT_ID
cd infra/cdk && npx cdk synth --require-approval=never
npx cdk deploy --require-approval=never
curl https://<ALB_DNS>/api/health
npm run go:no-go https://<ALB_DNS>
Scenario 2: Update existing infrastructure
cd infra/cdk && npx cdk synth --require-approval=never
npx cdk deploy DSGOneStack-dev --require-approval=never
curl https://<ALB_DNS>/api/agent/status
Scenario 3: Troubleshoot deployment failure
aws cloudformation describe-stacks --stack-name dsg-one-dev-v2 --region us-east-1
aws cloudformation describe-stack-resources \
--stack-name dsg-one-dev-v2 \
--query 'StackResources[?ResourceStatus==`CREATE_FAILED`]' \
--region us-east-1
cd infra/cdk && npx cdk synth --require-approval=never
npm run typecheck
Post-deployment tasks
1. Capture infrastructure outputs
./scripts/capture-aws-outputs.sh \
--stack-name dsg-one-dev-v2 \
--region us-east-1 \
--environment dev
2. Build and deploy application
npm run build
docker build -t dsg-control-plane:latest .
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
aws ecs update-service \
--cluster dsg-one-dev-v2 \
--service dsg-service \
--force-new-deployment
3. Configure DNS and TLS
aws route53 change-resource-record-sets \
--hosted-zone-id <ZONE_ID> \
--change-batch file://route53-change.json
4. Set up monitoring and alerts
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
aws sns subscribe \
--topic-arn <SNS_TOPIC> \
--protocol email \
--notification-endpoint ops@dsg.pics
Troubleshooting
CloudFormation stack stuck in UPDATE_IN_PROGRESS
Cause: Previous CDK deploy didn't complete or is still running
Solution:
ps aux | grep cdk
aws cloudformation describe-stack-events \
--stack-name dsg-one-dev-v2 \
--query 'StackEvents[0:10]' \
--region us-east-1
ALB target group reports "Unhealthy"
Cause: ECS task is crashing or not responding to health checks
Solution:
aws ecs describe-tasks \
--cluster dsg-one-dev-v2 \
--tasks <TASK_ARN> \
--region us-east-1
aws logs tail /ecs/dsg-control-plane --follow
S3 bucket deletion failed
Cause: CloudFormation tries to delete non-empty S3 buckets
Solution:
aws s3 rm s3://dsg-cloudtrail-bucket-<account> --recursive
aws s3 rm s3://dsg-evidence-bucket-<account> --recursive
// removalPolicy: cdk.RemovalPolicy.DESTROY,
// โ removalPolicy: cdk.RemovalPolicy.RETAIN,
aws cloudformation delete-stack --stack-name dsg-one-dev-v2
DynamoDB table naming conflicts
Cause: Table names like dsg-policy-table already exist from previous deployment
Solution:
// tableName: 'dsg-policy-table-v2',
// CDK auto-generates unique names without explicit tableName
npx cdk deploy --require-approval=never
Deployment success criteria
โ
Deployment is ready when:
โ
Production readiness when:
Next steps
- Complete CDK deployment (wait 30-45 minutes for initial stack)
- Verify infrastructure health (run health checks and diagnostics)
- Capture AWS outputs (document resources created)
- Build and deploy application (Docker โ ECR โ ECS)
- Configure DNS and TLS (Route53 + ACM)
- Set up monitoring (CloudWatch alarms, SNS)
- Run production readiness validator (compliance checks)
- Document runbooks (deployment, scaling, recovery procedures)
- Schedule runbook reviews (monthly for prod)