Question: How do I resolve "ResourceInitializationError: failed to validate logger args" error in Amazon ECS?

When I run a task in Amazon Elastic Container Service (Amazon ECS), I receive a "ResourceInitializationError: failed to validate logger args" error.

Short descriptionWhen an Amazon ECS task can't find the Amazon CloudWatch log group that's defined in the task definitionAmazon, Amazon ECS returns a ResourceInitialization error. You receive the following error message: "ResourceInitializationError: failed to validate logger args: create stream has been retried 1 times: failed to create Cloudwatch log stream: ResourceNotFoundException: The specified log group does not exist. : exit status 1"To resolve the error, create a new log group for the task.

ResolutionTo resolve the ResourceInitialization error, review the following solutions to create a new log group for the task.If you don't know which log group is defined in the task definition and returning an error, then run the following command:aws ecs describe-task-definition --task-definition nginx-fargate:3 | jq -r .taskDefinition.containerDefinitions[].logConfigurationThe output describes the log group that you must recreate in CloudWatch.Create a CloudWatch log group in the console1.    Open the CloudWatch console.2.    From the navigation bar, choose the Region where Amazon ECS cluster is located.3.    In the left navigation pane, choose Logs and then select Log groups.4.    In the Log groups window, choose Create log group.Create a CloudWatch log group using AWS CLICreate a CloudWatch log group with the create-log-group AWS Command Line Interface (AWS CLI) command. The following example command creates a log group named mylogs:Note: If you receive errors when running AWS CLI commands, then make sure that you’re using the most recent version of the AWS CLI.aws logs create-log-group --log-group-name mylogsUse the auto-configuration feature in the Amazon ECS consoleThe auto-configure option creates a log group on your behalf using the task definition family name with ecs as the prefix. The following example specifies a Log Configuration in your Task Definition:{  "containerDefinitions": [    {      "logConfiguration": {        "logDriver": "awslogs",        "options": {          "awslogs-create-group": "true",          "awslogs-group": "awslogs-wordpress",          "awslogs-region": "us-west-2",          "awslogs-stream-prefix": "awslogs-example"        }      }    }  ]}You can also create a custom log group with the following steps:1.    Specify log configuration options.   Add the key awslogs-create-group with a value of true. This creates the log group on your behalf.The following example specifies a Log Configuration in your Task Definition with options set:{  "containerDefinitions": [    {      "logConfiguration": {        "logDriver": "awslogs",        "options": {          "awslogs-group": "example_container",          "awslogs-region": "eu-west-1",          "awslogs-create-group": "true",          "awslogs-stream-prefix": "example"        }      }    }  ]}Note: Managed AWS Identity and Access Management (IAM) policy AmazonECSTaskExecutionRolePolicy doesn't include logs:CreateLogGroup permissions. To use the awslogs-create-group option, add logs:CreateLogGroup as an inline IAM policy.