-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paths3_sync.sh
More file actions
executable file
·46 lines (43 loc) · 1.21 KB
/
s3_sync.sh
File metadata and controls
executable file
·46 lines (43 loc) · 1.21 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Set variables
function usage()
{
echo "ERROR: Incorrect arguments provided."
echo "Usage: $0 {args}"
echo "Where valid args are: "
echo " -p <profile> (REQUIRED) -- Profile to use for AWS commands"
echo " -b <bucket> (REQUIRED) -- bucket name to sync to"
exit 1
}
# Parse args
if [[ "$#" -lt 2 ]] ; then
echo 'parse error'
usage
fi
PROFILE=default
while getopts "p:r:b:" opt; do
case $opt in
p)
PROFILE=$OPTARG
;;
b)
BUCKET=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG"
usage
;;
esac
done
REGION=$(aws configure list --profile ${PROFILE} | grep region | awk '{print $2}')
ACCOUNT_ID=$(aws ec2 describe-security-groups --query 'SecurityGroups[0].OwnerId' --output text)
CWD=$(echo $PWD | rev | cut -d'/' -f1 | rev)
if [ $CWD != "SAM-Example" ]
then
echo "These tools are expecting to be ran from the base of the SAM-Example repo."
exit 1
fi
sed -i.bak "s/<region>/${REGION}/g" docs/awscats.yml
sed -i.bak "s/<account_id>/${ACCOUNT_ID}/g" docs/awscats.yml
aws s3 sync ./builds/ s3://${BUCKET}/builds/ --profile ${PROFILE} --exclude *.git/* --exclude *.swp
aws s3 sync ./docs/ s3://${BUCKET}/docs/ --profile ${PROFILE} --exclude *.git/* --exclude *.swp