sample ecs task definition for agents
# ask-ai
b
sample ecs task definition for agents
t
Thanks for reaching out, Sandeep. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Here is a sample ECS task definition for deploying LiveKit agents:
b
nothiing provided can you please povide task defination again
t
Here’s a sample ECS task definition to help you get started with deploying LiveKit agents:
Copy code
Resources:
  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!