Deploy a Mastra AI agent to AWS with Defang

Learn to deploy the Mastra Extended sample through Defang, with GitHub Actions, pgvector embeddings and Redis queues in your AWS account.

Player not loading? Watch on YouTube

This tutorial follows the Mastra Extended sample through a browser-based deployment with Defang. The presenter connects an AWS account, chooses project and stack names, then creates a repository from a GitHub template. GitHub Actions starts the deployment. He explains that the first run takes longer because AWS must provision the database, cache and other resources.

The sample AI agent answers questions about generated tasks and events. A background worker takes incoming items from a queue, uses an LLM to assign tags and priorities, and creates embeddings for semantic search. The demonstration asks about resource usage and shows the agent making tool calls to retrieve events. Connecting real systems through webhooks is suggested, rather than demonstrated. The presenter explicitly notes that the sample has no authentication.

The AWS walkthrough shows four ECS services: the worker, the application UI and API, and separate chat and embedding services. RDS stores embeddings with pgvector, while Redis in ElastiCache handles queuing. The presenter says Defang maps Docker Model Runner models used during Docker Compose development to cloud inference services through a LiteLLM proxy, preserving the application's API calls. This is a deployment into the user's cloud account; the demonstrated inference path uses a cloud provider.