Created
January 26, 2020 17:25
-
-
Save jkinkead/94ddedcb18bdd31a380a5d730aa91e48 to your computer and use it in GitHub Desktop.
ECR login helper for fish.
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
function ecr_login -d \ | |
"ecr_login [profile_name] [region]: Log in to ECR via the AWS CLI." \ | |
-a profile_name region | |
set -l args | |
if [ -n "$profile_name" ] | |
set args $args "--profile=$profile_name" | |
end | |
if [ -n "$region" ] | |
set args $args "--region=$region" | |
end | |
set -l auth_result (aws $args ecr get-authorization-token --output text) | |
if [ -z "$auth_result" ] | |
return | |
end | |
set -l token (echo "$auth_result" | cut -f2 | base64 --decode | cut -d: -f2) | |
set -l url (echo "$auth_result" | cut -f4) | |
echo "$token" | docker login --password-stdin -u AWS "$url" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment