Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:23blocks OS Ai maestro AWS CLI

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Cloud
Last Updated 2026-10-26 18:00 GMT

Overview

AWS CLI and Terraform for provisioning EC2 and ECS Fargate cloud agents on AWS infrastructure.

Description

AI Maestro's cloud-agent service creates agents on AWS via Terraform. Two providers are supported: EC2 (dedicated VM with native Node.js/tmux/AI CLI install) and ECS Fargate (serverless container with auto-built Docker image pushed to ECR). The `agents-cloud-service.ts` module orchestrates `terraform init`, `apply`, and `destroy` through `execFile`, using AWS named profiles for credentials.

Terraform modules live in `infrastructure/terraform/aws-agent` (EC2) and `infrastructure/terraform/aws-agent-ecs` (ECS). The service validates AWS credentials with `sts get-caller-identity`, checks Terraform availability with `terraform version`, and checks Docker availability with `docker info` (for ECS image builds).

Usage

Use this environment when creating cloud agents via the dashboard. Required for EC2-based agents (native install on a VM) and ECS Fargate agents (serverless containers). The operator must have a configured AWS named profile and Terraform installed on the AI Maestro host.

System Requirements

Category Requirement Notes
OS Linux / macOS Terraform and AWS CLI run on the host
Software Terraform >= 1.0 Checked via `terraform version`
Software AWS CLI >= 2.0 With named profile configured
Software Docker (ECS only) For auto-building and pushing the container image to ECR
Network AWS API access HTTPS to `*.amazonaws.com`

Dependencies

System Packages

  • `terraform` >= 1.0
  • `aws-cli` >= 2.0
  • `docker` (ECS only, for image build/push)

Node Packages

  • `execFile` from `child_process` (no additional npm package)

Credentials

  • `awsProfile`: Named AWS profile (validated: `^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,63}$`)
  • `awsRegion`: AWS region (validated: `^[a-z]{2}(-[a-z]+)+-\d$`)
  • `githubToken`: Injected into the cloud VM for git access
  • `anthropicApiKey`: Injected into the cloud VM for Claude API
  • `keyName`: EC2 SSH key pair name (EC2 only)
  • `allowedSshCidr`: CIDR block for SSH access (EC2 only)

Quick Install

# Install Terraform
wget https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
unzip terraform_1.6.0_linux_amd64.zip && sudo mv terraform /usr/local/bin/

# Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip && sudo ./aws/install

# Configure a named profile
aws configure --profile my-profile

Code Evidence

Terraform availability check from `services/agents-cloud-service.ts:73-80`:

async function checkTerraformAvailable(): Promise<boolean> {
  try {
    await execFileAsync('terraform', ['version'], { timeout: 5000 })
    return true
  } catch { return false }
}

AWS credential validation from `services/agents-cloud-service.ts:82-89`:

async function checkAwsCredentials(profile: string): Promise<boolean> {
  try {
    await execFileAsync('aws', ['sts', 'get-caller-identity', '--profile', profile], { timeout: 10000 })
    return true
  } catch { return false }
}

Validation regexes from `services/agents-cloud-service.ts:27-29`:

const AWS_PROFILE_RE = /^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,63}$/
const AWS_REGION_RE = /^[a-z]{2}(-[a-z]+)+-\d$/

Common Errors

Error Message Cause Solution
`Terraform not found` `terraform` not on PATH Install Terraform and ensure it's on PATH
`AWS credentials not found` Profile not configured or expired Run `aws configure --profile <name>` or refresh credentials
`Docker not available` (ECS) Docker daemon not running Start Docker for ECS image build/push
Terraform `apply` fails on region Invalid region format Region must match `^[a-z]{2}(-[a-z]+)+-\d$`

Compatibility Notes

  • EC2 provider: Installs Node.js, tmux, and AI CLIs natively on the VM. No Docker/ECR needed.
  • ECS provider: Auto-builds a Docker image from `agent-container/Dockerfile` and pushes to ECR if no `ecrImageUrl` is provided. Docker must be available on the host.
  • Terraform work directory is per-agent: `~/.aimaestro/agents/{agentId}/terraform`.
  • Terraform module path is resolved relative to `process.cwd()`, so the server must run from the repository root.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment