Catalogue
Sequel: Pushing to ECR Without Logging In (aws ecr get-login)

Sequel: Pushing to ECR Without Logging In (aws ecr get-login)

🌐 日本語で読む

Overview

Last time I set things up so that I could push a Docker image to ECR without running the authentication command beforehand.

Pushing to ECR Without Logging In (aws ecr get-login)

However,
the setup is a bit of a hassle, which makes it inconvenient when you want to quickly write a one-liner in CircleCI, AWS CodeBuild, and the like.

Solution

By using a profile configured with awscli profile together with ecs-cli, authentication is handled for you.

1
ecs-cli push <image> --aws-profile <profile> --region <region>

Setup Steps

1
2
3
aws configure set --profile hogehoge aws_access_key_id $ACCESS_KEY_ID
aws configure set --profile hogehoge aws_secret_access_key $SECRET_ACCESS_KEY
aws configure set --profile hogehoge region ap-northeast-1
1
2
3
ecs-cli push 123456789012.dkr.ecr.ap-northeast-1.amazonaws.com/stg-mogemoge-rails:latest \
--aws-profile hogehoge \
--region ap-northeast-1

That’s it. Now you can push to ECR without using aws ecr get-login. ♪

kenzo0107

kenzo0107