I'm trying to download ECR images on my EC2 instance without having to provide a credentials file. So I created a role with the policy AmazonEC2ContainerRegistryReadOnly and attached to my running instance. However, when I run aws ecr describe-repositories --region us-east-2, I get the following error:

Unable to locate credentials. You can configure credentials by running "aws configure".

I'm not sure if attaching the role to the instance is sufficient, but I already tried to restart the instance and it still doesn't work.

Here's some screenshots from the AWS Console that may help find the problem:

  • 1
    are you sure your aws cli is configured correctly?
    – c4f4t0r
    Commented Sep 23, 2022 at 0:30
  • 1
    @c4f4t0r: There was no configuration file (I didn't created one and the instances comes without one). I launched a new instance and it worked. I compared the versions and it was the same, but they both was at version 1. I upgraded AWS cli on the old machine and it worked, no idea why. Thanks for helping out.
    – rodorgas
    Commented Sep 23, 2022 at 2:59

1 Answer 1


Reinstalling/upgrading AWS cli made it work.

The AWS cli was at version 1, after upgrading to version 2 it worked. Before that, I launched a new EC2 instance (Amazon Linux 2) with the attached role and it worked at AWS cli version 1, the exact same of the old machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .