how to generate login password forAWS ECR with AWS CLI v2?
there have some breaking changes from CLI v1 to v2. for v2 command to generate the ECR login password:
aws ecr get-login-password --region xxx # for original region specific
aws ecr get-login-password --profile xxx # for named profile config
now copy the password string & paste to replace the below xxx (you can pipe to login directly, this is only for that you want to generate the password send to other people)
echo xxx | docker login --password-stdin -u AWS https://xxx.dkr.ecr.xxx.amazonaws.com
ECR repository link format like this (you can get it from your aws ecr repositories list):
${aws_account}.dkr.ecr.${aws_region}.amazonaws.com/${repository_name}
Since CLI v2 the config file uses a different naming format than the CLI credentials file for named profiles, the config file includes the prefix word "profile".
PS: include the prefix word "profile" only when configuring a named profile in the config file. Do not use the word profile when creating an entry in the credentials file.
~/.aws/config
[default]
region=us-west-2
output=json
[profile user1]
region=us-east-1
output=text
~/.aws/credentials
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[user1]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY