-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws-deploy
executable file
·43 lines (35 loc) · 1.2 KB
/
aws-deploy
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
#!/bin/bash -e
[[ -n "$verbose" ]] && set -x
fail() {
[[ -n "$2" ]] && echo -e "ERROR: $2\n"
echo "usage: AWS_PROFILE=... CODE_VERSION=... $0"
exit ${1:-1}
}
[[ -n "$AWS_PROFILE" ]] || fail 1 "No AWS_PROFILE setup."
[[ -n "$CODE_VERSION" ]] || fail 2 "No CODE_VERSION provided, e.g. '3.6.3'"
get-cf-export-value() {
aws cloudformation list-exports --output text --query "Exports[?Name==\`$1\`].Value"
}
APP_NAME=$(get-cf-export-value CodeDeployApp)
APP_BUCKET=$(get-cf-export-value CodeBucket)
APP_KEY="codedeploy/Techscore-${CODE_VERSION}.zip"
DEPLOYMENT_GROUP=$(get-cf-export-value CodeDeploymentGroup)
get-md5sum() {
aws s3api head-object --bucket ${APP_BUCKET} --key $APP_KEY --output text --query ETag | tr -d '"'
}
push() {
aws deploy push \
--application-name=${APP_NAME} \
--s3-location s3://${APP_BUCKET}/${APP_KEY} \
--source ./techscore \
--ignore-hidden-files
}
deploy() {
aws deploy create-deployment \
--application-name ${APP_NAME} \
--s3-location bucket=${APP_BUCKET},key=${APP_KEY},bundleType=zip,eTag=$(get-md5sum) \
--file-exists-behavior OVERWRITE \
--deployment-group-name ${DEPLOYMENT_GROUP}
}
push
deploy