Skip to content

Instantly share code, notes, and snippets.

@jsleeio
jsleeio / docker-login-ecr.bash
Created November 28, 2021 02:38
automatic Docker login to ECR via AWS configuration data
docker-login-ecr() {
local ecr_account_profile=${ECR_ACCOUNT_PROFILE:-utility}
local ecr_region
local ecr_account_id
ecr_account_id="$(aws configure get "$ecr_account_profile.role_arn" | awk -F: '{ print $5 }')"
if [[ -z "$ecr_account_id" ]] ; then
return 1
fi
ecr_region=$(aws configure get "$ecr_account_profile.region")
if [[ -z "$ecr_region" ]] ; then