Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWS ECR token refresh script
#!/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)
@daniilyar

This comment has been minimized.

Copy link
Owner Author

daniilyar commented May 16, 2019

Usage example for cron:

0 * * * * /usr/local/bin/ecr_secrets_refresher.sh -p my_aws_profile -r us-east-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.