Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Deploy to AWS Fargate


This guide walks you through deploying your TAC application to AWS Fargate using CloudFormation. The deployment creates an ECS Fargate cluster behind an Application Load Balancer (ALB) with all required networking and IAM configuration.


Architecture overview

architecture-overview page anchor

The deployment creates the following AWS resources:

  • ECS Fargate — Container runtime for your TAC server
  • Application Load Balancer — Stable DNS endpoint with health checks and WebSocket support
  • VPC — Network isolation (10.0.0.0/16) with multi-AZ public subnets
  • Security Groups — Firewall rules for ALB and ECS
  • CloudWatch Logs — Application logs with 7-day retention
  • IAM Roles — Permissions for Bedrock access

Before you begin, make sure you have:

(information)

Info

For AgentCore deployments, you must first deploy your agent to the AgentCore runtime before deploying the TAC server. See Deploy agent to AgentCore below.


Deploy agent to AgentCore (AgentCore only)

deploy-agent-to-agentcore-agentcore-only page anchor

If you're using the AgentCore connector, deploy your agent to the AgentCore runtime first.

Install the AgentCore CLI

install-the-agentcore-cli page anchor
pip install bedrock-agentcore-starter-toolkit
1
# Configure your agent
2
agentcore configure --entrypoint agent.py --name simpleagent --non-interactive
3
4
# Deploy to AgentCore
5
agentcore launch

Save the Agent ARN from the output — you'll need it when deploying the TAC server.

Agent ARN: arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/simpleagent-XXX
agentcore invoke '{"prompt": "Hello"}'

Build and publish the Docker image

build-and-publish-the-docker-image page anchor

Clone the TAC AWS repository to get the deployment files:

1
git clone https://github.com/twilio/twilio-agent-connect-aws.git
2
cd twilio-agent-connect-aws

Navigate to your deployment directory and build the wheel files:

StrandsBedrock AgentAgentCore
1
cd deploy/strands_aws_fargate
2
./build-wheels.sh
StrandsBedrock AgentAgentCore
docker build -t tac-strands-server:latest -f Dockerfile .

Tag and push your image to ECR:

StrandsBedrock AgentAgentCore
1
# Authenticate with ECR
2
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
3
4
# Tag the image
5
docker tag tac-strands-server:latest YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/tac-strands-server:latest
6
7
# Push to ECR
8
docker push YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/tac-strands-server:latest

Replace YOUR_ACCOUNT_ID with your AWS account ID.


Deploy the CloudFormation stack

deploy-the-cloudformation-stack page anchor

Deploy the infrastructure using CloudFormation:

StrandsBedrock AgentAgentCore
1
aws cloudformation deploy \
2
--template-file cloudformation.yaml \
3
--stack-name TACStack \
4
--parameter-overrides \
5
ImageURI=YOUR_ECR_URI:latest \
6
TwilioAccountSid=YOUR_ACCOUNT_SID \
7
TwilioAuthToken=YOUR_AUTH_TOKEN \
8
TwilioApiKey=YOUR_API_KEY \
9
TwilioApiSecret=YOUR_API_SECRET \
10
TwilioPhoneNumber=YOUR_PHONE_NUMBER \
11
TwilioConversationConfigurationId=YOUR_CONVERSATION_CONFIGURATION_ID \
12
TwilioVoicePublicDomain=YOUR_HTTPS_DOMAIN \
13
--capabilities CAPABILITY_IAM \
14
--region us-east-1

Find your Twilio credentials:

  • Auth Token & API Keys: Twilio Console > Account > API Keys & Tokens
  • Conversation Configuration ID: Twilio Console > Conversation Orchestrator > Conversation Configurations

After the stack deploys, retrieve the load balancer DNS name:

StrandsBedrock AgentAgentCore
1
aws cloudformation describe-stacks \
2
--stack-name TACStack \
3
--query 'Stacks[0].Outputs[?OutputKey==`LoadBalancerDNS`].OutputValue' \
4
--output text \
5
--region us-east-1

The output looks similar to TAC-ALB-xxx.us-east-1.elb.amazonaws.com.


Connect HTTPS endpoint to ALB

connect-https-endpoint-to-alb page anchor

Point your HTTPS endpoint to the ALB DNS name.

Using ngrok (development):

ngrok http TAC-ALB-xxx.us-east-1.elb.amazonaws.com:80 --domain=your-domain.ngrok.app

Using CloudFront or Route53 (production):

Configure your CloudFront distribution or Route53 DNS record to point to the ALB DNS name.


Configure Twilio webhooks

configure-twilio-webhooks page anchor
  1. Go to Twilio Console > Phone Numbers > Active Numbers.
  2. Select your phone number.
  3. Set Voice URL to https://your-https-domain.com/twiml (POST).
  1. Go to Twilio Console > Conversation Orchestrator.
  2. Select your Conversation Service.
  3. Set Webhook URL to https://your-https-domain.com/webhook (POST).

Call or text your Twilio phone number to verify the deployment works. Check CloudWatch Logs if you encounter issues:

StrandsBedrock AgentAgentCore
aws logs tail /ecs/tac-server-alb --follow --region us-east-1