Created
May 16, 2019 09:45
-
-
Save daniilyar/2beba8e70584f34601c9196f0d258832 to your computer and use it in GitHub Desktop.
AWS ECR token refresh script
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 | |
HELP_MSG="This script read the AWS credentials from the execution environment and does the docker-login via the AWS-CLI utility.\n | |
Available arguments: '-s' for the name of the ECR secret will add, '-p' for the profile, '-h' for this message." | |
while getopts :r:p:h: option | |
do | |
case "${option}" | |
in | |
r) AWS_REGION="$OPTARG";; | |
p) AWS_PROFILE="$OPTARG";; | |
h) NEED_HELP="1";; | |
*) NEED_HELP="1";; | |
esac | |
done | |
if [[ "$#" -eq 0 ]] | |
then | |
echo -e "$HELP_MSG" | |
exit 1 | |
fi | |
if [[ "$NEED_HELP" -eq 1 ]] | |
then | |
echo -e "$HELP_MSG" | |
exit 1 | |
fi | |
$(aws --region $AWS_REGION ecr get-login --no-include-email --profile $AWS_PROFILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage example for cron: