How do I configure a log driver for my Amazon ECS tasks on AWS Fargate?
Last updated: 2020-11-20
I want to configure a log driver for my Amazon Elastic Container Service (Amazon ECS) tasks on AWS Fargate.
When you create a task definition for AWS Fargate, you have the option to allow Amazon ECS to auto-configure your Amazon CloudWatch logs. This option creates a log group on your behalf using the task definition family name with ecs as the prefix.
- Open the Amazon ECS console.
- From the navigation pane, choose Task Definitions, and then choose Create new Task Definition.
- In the Select launch type compatibility section, choose FARGATE, and then choose Next Step.
- In the Configure task and container definitions section, for Task Definition Name, enter a name for your task definition.
- In the Container Definitions, choose Add container.
- Fill out the required fields based on your container requirements.
- In the STORAGE AND LOGGING section, for Log configuration, choose one of the following options:
If you want to accept the default values of awslogs-group, awslogs-region, and awslogs-stream-prefix, select the Auto-configure CloudWatch Logs check box. Then, skip to step 8.
If you want a custom log group and stream, clear the Auto-configure CloudWatch Logs check box. Then, complete the following steps:
For Log driver, select awslogs. If the log group doesn't exist, set the awslogs-create-group parameter and use the required logs:CreateLogGroup action for the task execution role.
(Required) For the awslogs-group key, leave the auto-populated value in place, or enter a value for your group if the text box is empty.
(Required) For the awslogs-region key, leave the auto-populated value in place, or enter a value for your AWS Region if the text box is empty.
(Required) For the awslogs-stream-prefix key, leave the auto-populated value in place, or enter a value for your stream if the text box is empty. You can define other parameters based on your use case. For more information, see Specifying a log configuration in your task definition.
- Choose Add.
- Fill out the remaining fields in the task definition wizard, and then choose Create.