Using Amazon Q to provide task definition recommendations in the Amazon ECS console - Amazon Elastic Container Service

Using Amazon Q to provide task definition recommendations in the Amazon ECS console

Amazon Q is a generative artificial intelligence (AI) powered conversational assistant that can help you understand, build, extend, and operate AWS applications.

For more information about Amazon Q, see the Amazon Q Developer User Guide.

When you use the JSON editor in the Amazon ECS console to create a task definition, you can use Amazon Q to provide AI-generated code suggestions for your task definitions.

There is no additional cost for this feature. You can use this feature in Regions where Amazon Q is supported. For more information, see Supported Regions for Amazon Q.

Prerequisites

The following are prerequisites for using Amazon ECS on Amazon Q:

Get task definition recommendations

When you create a task definition using the JSON editor, you can have Amazon Q provide recommendations to help you create a task definition more quickly.

  1. Open the console at https://console.aws.amazon.com/ecs/v2.

  2. In the navigation pane, choose Task definitions.

  3. On the Create new task definition menu, choose Create new task definition with JSON.

    The Create task definition page displays.

    The console provides the following default template.

    { "requiresCompatibilities": [ "FARGATE" ], "family": "", "containerDefinitions": [ { "name": "", "image": "", "essential": true } ], "volumes": [], "networkMode": "awsvpc", "memory": "3 GB", "cpu": "1 vCPU", "executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole" }
  4. In the Amazon Q inline suggestions pop-up, choose Allow.

    If you dismiss the pop-up, you can enable Amazon Q under the gear icon.

  5. In the JSON editor box, edit the JSON file.

    To have Amazon Q create and populate the parameters, enter a comment with what you want to add. In the example below, the comment causes Amazon Q to generate the lines in bold.

    { "requiresCompatibilities": [ "FARGATE" ], "family": "", "containerDefinitions": [ { "name": "", "image": "", "essential": true }, // add a nginx container using an image from Public ECR, with port 80 open, and send logs to CloudWatch log group "myproxy" { "name": "nginx", "image": "public.ecr.aws/nginx/nginx:latest", "essential": true, "portMappings": [ { "containerPort": 80, "hostPort": 80, "protocol": "tcp" } ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "myproxy", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "nginx" } } } ], "volumes": [], "networkMode": "awsvpc", "memory": "3 GB", "cpu": "1 vCPU", "executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole" }
  6. Choose Create.