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:
-
In addition to the console permissions, the user that creates the task definition in the console must have the
codewhisperer:GenerateRecommendations
permission. For more information, see Permissions required for using Amazon Q to provide recommendations in the console.
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.
Open the console at https://console.aws.amazon.com/ecs/v2
. -
In the navigation pane, choose Task definitions.
-
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" }
-
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.
-
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" }
-
Choose Create.