DEV Community

Cover image for How to fix the Cloudwatch log stream: ResourceNotFoundException error from ECS
Federico Navarrete
Federico Navarrete

Posted on • Edited on • Originally published at supernovaic.blogspot.com

6 1 1

How to fix the Cloudwatch log stream: ResourceNotFoundException error from ECS

Probably, if you are reading this article, you are facing the following bug after you've run a Task or Service in ECS:

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

This is happening because your task doesn't have permission to create the CloudWatch Log. To fix it, you must make changes using the JSON format definition. The first one is to add the following line in the logConfiguration section:

"awslogs-create-group": "true"
Enter fullscreen mode Exit fullscreen mode

It will look like this:

"logConfiguration": {
    "logDriver": "awslogs",
    "options": {
        "awslogs-create-group": "true",
        "awslogs-group": "/YOUR_CLOUD_WATCH_LOCATION",
        "awslogs-region": "YOUR_AWS_REGION",
        "awslogs-stream-prefix": "ecs"
    }
}
Enter fullscreen mode Exit fullscreen mode

The second change, you must add a new inline policy to the role that is running your task (check in the Task definition).

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup"
            ],
            "Resource": "*"
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

That's all that you need. After you make these changes, your task or service should start running as expected.

Follow me on:

Personal LinkedIn YouTube Instagram Cyber Prophets Sharing Your Stories
Personal LinkedIn YouTube Instagram RedCircle Podcast RedCircle Podcast

sponsor me

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay