Skip to content

cloud-agent deploy

The deploy command is the core of Agent Cloud. It runs a 5-phase deployment workflow: environment validation, project analysis, deployment planning, human approval, and real cloud execution.

Terminal window
cloud-agent deploy [options]
FlagDescription
-c, --cloud <provider>Cloud provider to deploy to. One of aws, gcp, azure. If not specified, uses the default from config or prompts interactively.
-p, --path <directory>Path to the project directory. Defaults to the current working directory.
-y, --yesAuto-approve the deployment plan without interactive confirmation.
--app-name <name>Override the application name. Defaults to the name field in package.json or the directory name.
--port <number>Override the container port. Defaults to the port detected during analysis.
--image <name>Use an existing Docker image instead of building one.
--build-dir <path>Specify the build output directory for static site deployments.
--dry-runGenerate and display the deployment plan without executing it.
  • An AI API key (GOOGLE_GENERATIVE_AI_API_KEY or OPENAI_API_KEY)
  • The target cloud’s CLI installed and authenticated
  • Docker (for container-based deployments)

The deploy command creates a Mastra workflow run and executes it through five phases:

The validator agent checks your environment:

  • Cloud CLI installed and version is recent enough
  • You are authenticated with the cloud provider
  • Required environment variables are set
  • Network connectivity to cloud APIs
  • Basic permissions to create resources

If critical issues are found, the workflow stops and reports what needs to be fixed.

The analyzer agent scans your project:

  • Detects runtime, framework, and dependencies
  • Identifies databases and external services
  • Checks for Docker configuration
  • Determines build and start commands

The deployment agent generates a plan:

  • Maps your project to specific cloud services
  • Estimates monthly cost
  • Generates the exact CLI commands that will be executed
  • Identifies potential warnings or issues

The workflow suspends and displays the plan to you:

── Deployment Plan ──────────────────────
Services:
- ECS Fargate
- Application Load Balancer
- CloudWatch Logs
Estimated Cost: $35.00 /month
Commands to execute:
aws ecr create-repository --repository-name my-app
docker build -t my-app .
docker tag my-app:latest 123456789.dkr.ecr.us-east-1.amazonaws.com/my-app
aws ecs create-cluster --cluster-name my-app-cluster
aws ecs register-task-definition ...
aws ecs create-service ...
... and 2 more
? Proceed with this deployment? (y/N)
  • Press y to approve and proceed to execution
  • Press n to cancel (no resources are created)
  • With --yes, this step is skipped and the plan is auto-approved

The workflow state is persisted to a local LibSQL database, so it can theoretically survive process crashes.

Once approved, Agent Cloud:

  1. Dynamically imports the appropriate cloud provider module
  2. Authenticates with the cloud provider
  3. Executes the deployment commands in sequence
  4. Records the result (URL, resources created, duration) to deployment history
Terminal window
cloud-agent deploy --cloud aws
Terminal window
cloud-agent deploy --cloud gcp --yes
Terminal window
cloud-agent deploy --cloud azure --path /path/to/project
Terminal window
cloud-agent deploy --cloud aws --app-name my-service --port 8080
Terminal window
cloud-agent deploy --cloud aws --dry-run

The resources created depend on the cloud provider and project type. See the provider-specific pages for details:

  • AWS Provider — ECS clusters, ECR repos, load balancers, S3 buckets
  • GCP Provider — Cloud Run services, Cloud Functions, Firebase sites
  • Azure Provider — Container Apps, Function Apps, Static Web Apps

Every deployment (successful or failed) is recorded in .agent-cloud/config.json. View past deployments with:

Terminal window
cloud-agent history

The deploy command reads environment variables from a .env file in your project directory (if present) and passes them to the deployed application. Sensitive variables like API keys are forwarded securely to the cloud environment.

CodeMeaning
0Deployment completed successfully
1Deployment failed or was cancelled