'use a specific profile to create ecr repository with AWS CLI

I am new in AWS CLI. I have configured my aws & in my ~/.aws/config I have two profiles:

[profile dev]
...

[profile prod]
...

Now, I would like to create an ECR registry from command line with my dev profile (which is associated with our development environment in AWS cloud).

I checked this document, and I get that I could execute a command like:

aws ecr create-repository \
    --repository-name sample-repo \
    --image-tag-mutability IMMUTABLE

But how can I specify the dev profile to use when executing this command?



Solution 1:[1]

This is how you can use the named profile.

aws ecr create-repository \
    --repository-name sample-repo \
    --image-tag-mutability IMMUTABLE \
    --profile dev

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jellycsc