brief-vase-33757
08/03/2025, 3:17 PMtall-airline-16756
08/03/2025, 3:17 PMtall-airline-16756
08/03/2025, 3:18 PMbrief-vase-33757
08/03/2025, 3:32 PMtall-airline-16756
08/03/2025, 3:33 PMResources:
AgentExampleTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
RequiresCompatibilities:
- FARGATE
Cpu: "2048"
Memory: "4096"
NetworkMode: awsvpc
ExecutionRoleArn: !GetAtt TaskExecutionRole.Arn
ContainerDefinitions:
- Name: agent-example
Image: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.<http://amazonaws.com/${DockerRepository}:<version|amazonaws.com/${DockerRepository}:<version>>"
Essential: true
Secrets:
- Name: LIVEKIT_URL
ValueFrom: arn:aws:secretsmanager:us-east-1:203125320322:secret:ecs/agent-example/livekit-url-<unique-id>
- Name: LIVEKIT_API_KEY
ValueFrom: arn:aws:secretsmanager:us-east-1:203125320322:secret:ecs/agent-example/livekit-api-key-<unique-id>
- Name: LIVEKIT_API_SECRET
ValueFrom: arn:aws:secretsmanager:us-east-1:203125320322:secret:ecs/agent-example/livekit-api-secret-<unique-id>
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AgentExampleLogGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: agent-example
TaskExecutionRole:
Type: AWS::IAM::Role
Properties:
RoleName: ecsTaskExecutionRole
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: <http://ecs-tasks.amazonaws.com|ecs-tasks.amazonaws.com>
Action: "sts:AssumeRole"
Policies:
- PolicyName: ECSTaskExecutionAndSecretsPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
- ssm:GetParameters
- ssm:GetParameter
- ssm:DescribeParameters
- kms:Decrypt
- ecr:GetAuthorizationToken
- ecr:GetDownloadUrlForLayer
- ecr:BatchCheckLayerAvailability
- ecr:BatchGetImage
- logs:CreateLogStream
- logs:PutLogEvents
- s3:GetObject
Resource: "*"
AgentExampleLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: "/ecs/agent-example"
RetentionInDays: 14
Just a few quick tips to keep in mind:
• Make sure to swap out <version> in the image URL with the version that matches your image.
• Update the Secrets Manager ARNs to point to your actual secrets.
• Double-check that the IAM role permissions fit your security needs.
• Feel free to tweak the CPU, memory, and logging settings to best suit your workload.
This task definition should give you a solid foundation for deploying LiveKit agents on AWS ECS. If you have any questions or need a hand, just let me know!