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.
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:
- AWS CLI configured with appropriate credentials
- Docker installed
- An Amazon ECR repository to store your Docker image
- An HTTPS endpoint (choose one):
- ngrok — For testing and development
- CloudFront — For production with AWS-provided HTTPS domain
- Route53 + ACM — For production with custom domain
- A working TAC application with your chosen connector (Strands, Bedrock Agent, or AgentCore)
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.
If you're using the AgentCore connector, deploy your agent to the AgentCore runtime first.
pip install bedrock-agentcore-starter-toolkit
1# Configure your agent2agentcore configure --entrypoint agent.py --name simpleagent --non-interactive34# Deploy to AgentCore5agentcore 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"}'
Clone the TAC AWS repository to get the deployment files:
1git clone https://github.com/twilio/twilio-agent-connect-aws.git2cd twilio-agent-connect-aws
Navigate to your deployment directory and build the wheel files:
1cd deploy/strands_aws_fargate2./build-wheels.sh
docker build -t tac-strands-server:latest -f Dockerfile .
Tag and push your image to ECR:
1# Authenticate with ECR2aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com34# Tag the image5docker tag tac-strands-server:latest YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/tac-strands-server:latest67# Push to ECR8docker 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 infrastructure using CloudFormation:
1aws cloudformation deploy \2--template-file cloudformation.yaml \3--stack-name TACStack \4--parameter-overrides \5ImageURI=YOUR_ECR_URI:latest \6TwilioAccountSid=YOUR_ACCOUNT_SID \7TwilioAuthToken=YOUR_AUTH_TOKEN \8TwilioApiKey=YOUR_API_KEY \9TwilioApiSecret=YOUR_API_SECRET \10TwilioPhoneNumber=YOUR_PHONE_NUMBER \11TwilioConversationConfigurationId=YOUR_CONVERSATION_CONFIGURATION_ID \12TwilioVoicePublicDomain=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:
1aws 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.
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.
- Go to Twilio Console > Phone Numbers > Active Numbers.
- Select your phone number.
- Set Voice URL to
https://your-https-domain.com/twiml(POST).
- Go to Twilio Console > Conversation Orchestrator.
- Select your Conversation Service.
- 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:
aws logs tail /ecs/tac-server-alb --follow --region us-east-1
- AWS connectors: Learn about the available connectors.
- Troubleshooting: Debug common issues.
- Escalate to a human agent: Transfer conversations to a human agent.