forked from cloudshiftstrategies/flask_docker_lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_ecr_secrets.sh
executable file
·30 lines (25 loc) · 1.29 KB
/
create_ecr_secrets.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
set -e
# This script uses the aws cli to get the ecr login information
# and stores it in the ecr.secrets file locally
OUTFILE=ecr.secrets
# TODO: make this dynamic...
AWS_REGION='us-west-2'
echo "Creating ecs.secret file"
# This is the command that gives us docker login command w/ credentials
# Note, must be authenticated to aws for this command
ECR_CMD="aws ecr get-login --no-include-email --region ${AWS_REGION}"
# Run ecr command, then extract the user name of the repo, store in secrets file
echo "ECR_USER=`${ECR_CMD} | awk '{print$4}'`" > ${OUTFILE}
# Run ecr command, then extract the password for the repo, store in secrets file
echo "ECR_PASS=`${ECR_CMD} | awk '{print$6}'`" >> ${OUTFILE}
# Run ecr command, then extract the url of the repo, store in secrets file
echo "ECR_URL=`${ECR_CMD} | awk '{print$7}'`" >> ${OUTFILE}
# Run ecr command, then extract the dns name for the repo, store in secrets file
echo "ECR_DNS=`${ECR_CMD} | awk '{print$7}' | sed s/'https:\/\/'//`" >> ${OUTFILE}
echo "Encrypting the ${OUTFILE} file"
# Now, encrypt the ecs.secrets file into ecs.secretes.enc and add decoding
# instructions to the .travis.yml file.
# Note, must be logged into travis for this step
travis encrypt-file ${OUTFILE} --add -f
echo "Successfully created and encrypted ${OUTFILE}"