agent-ready AWS guide

Use an AI Agent to Deploy Docker Compose to AWS

How developers can use Claude Code, Codex, Copilot, or another AI coding agent to prepare a Docker Compose app for AWS deployment with Defang.

When you use an AI coding agent to prepare a Docker Compose application for AWS, keep the deployment plan in Compose. Defang can turn that service intent into AWS infrastructure after you review the file.

That gives you a readable deployment contract. Your agent can help edit compose.yaml, explain the intent, and prepare the deployment command without generating a large amount of cloud-specific infrastructure code.

Prerequisites

Before deploying, the user needs:

  • Defang CLI installed (brew install defang or npm i -g defang)
  • Authenticated with defang login
  • AWS credentials configured (e.g., aws configure or environment variables)
  • A Defang stack targeting AWS: run defang stack new and select AWS when prompted for provider

Deployment path

After the Compose file is reviewed, deploy it with Defang:

defang login
defang stack new    # interactive: select AWS, choose region, name the stack
defang compose up

Use Defang Agent Skills

If you use Claude Code, Codex, or another coding agent, install Defang Agent Skills so the agent has Defang’s estimate, deploy, and debug workflows available in its own environment.

This path fits when:

  • The repository already has a compose.yaml or docker-compose.yml.
  • You want AWS but do not want to hand-author ECS task definitions.
  • The app needs common production pieces such as HTTPS, a load balancer, logs, managed Postgres, Redis, MongoDB, or LLM access.
  • You want your agent’s deployment changes concentrated in one file you can review.

Why this works well with coding agents

Coding agents are useful at editing structured text. Docker Compose is compact, reviewable, and widely understood by developers. A Compose file can define services, ports, environment variables, health checks, resource intent, and managed-service annotations in one place.

Defang then maps that intent to AWS primitives (ECS Fargate for compute, ALB for routing, RDS for Postgres, ElastiCache for Redis, DocumentDB for MongoDB). Instead of reviewing generated VPCs, IAM roles, ECS services, target groups, and certificates, you review a Compose file and let Defang handle the cloud translation.

Guardrails to keep in the Compose file

Add explicit health checks for public services. Declare required environment variables by name and store values as secrets using defang config set SECRET_NAME. Use managed-service annotations such as x-defang-postgres, x-defang-redis, x-defang-mongodb, and x-defang-llm when the app needs AWS-managed backing services (RDS, ElastiCache, DocumentDB) or LLM access (Bedrock). The x-defang-llm annotation configures cloud AI access for the annotated service and, for supported model runner images, provisions an OpenAI-compatible LLM proxy.

For production, set resource reservations appropriate for the app size:

services:
  web:
    build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000"]
      interval: 30s
      timeout: 10s
      retries: 3
    deploy:
      resources:
        reservations:
          cpus: "0.5"
          memory: 512M

  db:
    image: postgres:17
    x-defang-postgres: true

Defang also supports Railpack, which can build and deploy apps without a Dockerfile. If the project has no Dockerfile, Defang will auto-detect the runtime.

Note: The image field (e.g., postgres:17) is required — Defang uses it to determine the managed service version. Locally, docker compose up uses the same image as a regular container. The x-defang- annotations are only interpreted by Defang during cloud deployment.

What to ask your agent to produce

Ask for a reviewed compose.yaml, a short explanation of which services are public, a list of required secrets to set with defang config set, and the final Defang commands. That keeps the deployment plan visible while still giving you a direct path to AWS.