Skip to main content
Time to deploy: 10 minutes ⏱️
Get a production-ready Buildkite stack with auto-scaling agents on AWS.

Overview

The Buildkite Stack pattern deploys a complete CI/CD infrastructure including:
  • Auto-scaling EC2 agents (spot instances for cost optimization)
  • S3 bucket for artifact storage
  • Secrets Manager for API tokens
  • CloudWatch logs and metrics
  • VPC with proper security groups

Quick Start

fjall create buildkite-stack
Follow the prompts to configure:
  • Buildkite agent token
  • Instance types and scaling policies
  • VPC configuration
  • S3 bucket settings

Architecture

Components
  • ECS cluster with Buildkite agents
  • Auto-scaling group (1-10 agents)
  • Application Load Balancer
  • S3 bucket for build artifacts
  • CloudWatch dashboard

Configuration

const buildkiteStack = new BuildkiteStack(this, 'BuildkiteStack', {
  agentToken: SecretValue.secretsManager('buildkite-agent-token'),
  minAgents: 1,
  maxAgents: 10,
  instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.MEDIUM),
  useSpotInstances: true,
  spotMaxPrice: '0.05'
});

Cost Optimization

This pattern uses several cost-saving features:
  • Spot Instances: Save up to 90% on compute costs
  • Auto-scaling: Only pay for what you use
  • S3 Lifecycle Policies: Automatically archive old artifacts
Estimated monthly cost: $50-200 depending on usage

Customization

Adding GitHub Integration

buildkiteStack.addGitHubWebhook({
  secret: SecretValue.secretsManager('github-webhook-secret'),
  repositories: ['my-org/my-repo']
});

Custom Agent Configuration

buildkiteStack.addAgentUserData(`
  # Install additional tools
  yum install -y docker git
  
  # Configure Docker
  systemctl start docker
  usermod -aG docker buildkite-agent
`);

Monitoring

The stack includes pre-configured CloudWatch dashboards:
  • Agent utilization
  • Build queue depth
  • Failed builds
  • Cost tracking
Access your dashboard at:
https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#dashboards:name=BuildkiteStack

Next Steps