-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
executable file
·71 lines (60 loc) · 1.86 KB
/
deploy.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -eux
: ${AWS_ACCESS_KEY_ID?"Should have AWS_ACCESS_KEY_ID"}
: ${AWS_SECRET_ACCESS_KEY?"Should have AWS_SECRET_ACCESS_KEY"}
: ${REGION?"Should have REGION"}
: ${TERMINATION_PROBABILITY?"Should have TERMINATION_PROBABILITY"}
function cleanup {
rm -rf node_modules lambda.zip
}
trap cleanup EXIT
cleanup
PROJECT=chaos-testing
docker run \
--volume $(pwd):/project \
--workdir /project \
node:4 npm install \
--production \
--quiet \
--depth=0 \
--process=false
docker run \
--volume $(pwd):/project \
--workdir /project \
kramos/alpine-zip lambda.zip \
--quiet \
--must-match \
--recurse-paths \
*.json *.js node_modules
AWS_ACCOUNT_ID=`docker run \
--env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
cgswong/aws:aws \
sts get-caller-identity --output text --query 'Account'`
TERRAFORM_CONFIG_BUCKET=$PROJECT-tfstate-$AWS_ACCOUNT_ID
docker run \
--env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
cgswong/aws:aws \
s3api create-bucket \
--bucket $TERRAFORM_CONFIG_BUCKET \
--acl private
docker run \
--env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
--volume $(pwd):/project \
--workdir /project \
hashicorp/terraform:light remote config \
-backend=s3 \
-backend-config="bucket=$TERRAFORM_CONFIG_BUCKET" \
-backend-config="key=$PROJECT-$REGION.tfstate" \
-backend-config="region=us-east-1"
docker run \
--env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
--env AWS_DEFAULT_REGION=$REGION \
--env TF_VAR_termination_probability=$TERMINATION_PROBABILITY \
--env TF_VAR_project=$PROJECT \
--volume $(pwd):/project \
--workdir /project \
hashicorp/terraform:light apply