Last active
July 19, 2018 20:00
-
-
Save qmcree/bf71cc4d5b1b462857d972fa675cfbc8 to your computer and use it in GitHub Desktop.
Authenticates to ECR without exposing password to other processes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
AWS_ACCOUNT= | |
AWS_REGION=us-east-1 | |
ECR_URL=https://${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com | |
# On Mac, replace "base64 -d" with "base64 -D". | |
aws ecr get-authorization-token --query authorizationData[].authorizationToken --output text | base64 -d | cut -d: -f2 \ | |
| docker login -u AWS --password-stdin ${ECR_URL} \ | |
|| echo "Failed to authenticate to ECR." && exit 1 | |
# Alternative | |
aws ecr get-login --no-include-email --region ${AWS_REGION} | awk '{printf $6}' \ | |
| docker login -u AWS --password-stdin ${ECR_URL} \ | |
|| echo "Failed to authenticate to ECR." && exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See related aws/aws-cli#2875