Skip to content

Instantly share code, notes, and snippets.

@builtroller
Last active April 7, 2022 20:19
Show Gist options
  • Save builtroller/52f2f48c777923527586de0a83c53c78 to your computer and use it in GitHub Desktop.
Save builtroller/52f2f48c777923527586de0a83c53c78 to your computer and use it in GitHub Desktop.
ECR Login with Makefile

ECR Login with Makefile

  • allow an alias for the aws account id
  • default to the default region for aws
# login to bp account (222222222222), region = AWS_DEFAULT_REGION 
make ecr_login

# login to dev account (111111111111), region = us-west-2
make ecr_login aws_account=dev region=us-west-2

References

# map bp/dev to aws account id
aws_account ?= bp
aws_account_dev := 111111111111
aws_account_bp := 222222222222
aws_account_id := $(aws_account_$(aws_account))
region ?= $(AWS_DEFAULT_REGION)
ecr_login:
aws ecr get-login-password --region $(region) | \
docker login --username AWS --password-stdin $(aws_account_id).dkr.ecr.$(region).amazonaws.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment