-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy.sh
executable file
·45 lines (39 loc) · 1.29 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
!/usr/bin/env bash
set -ex
bucket_name_prefix=$1
TERRAFORM_BUCKET=$bucket_name_prefix
mkdir -p cache
rm -f cache/*.zip
# Create a .zip of src for the remediator
pushd resources/remediator
zip -r --exclude=module_cache/* ../../cache/remediator.zip *
pushd module_cache
zip -r ../../../cache/remediator.zip -u *
popd
popd
# Create a .zip of src for the poller
pushd resources/poller
zip -r --exclude=module_cache/* ../../cache/poller.zip *
popd
# Create a .zip of src for the event_translator
pushd resources/event_translator
zip -r --exclude=module_cache/* ../../cache/event_translator.zip *
popd
#iterate over regions
Field_Separator=$IFS
# set comma as internal field separator for the string list
IFS=,
for region in $regions;
do
if [ $region = $master_region ]; then
#poller and remediator will be deployed in main_region
aws s3 cp cache/remediator.zip s3://$TERRAFORM_BUCKET-$region/remediator.zip --sse
aws s3 cp cache/poller.zip s3://$TERRAFORM_BUCKET-$region/poller.zip --sse
aws s3 cp cache/event_translator.zip s3://$TERRAFORM_BUCKET-$region/event_translator.zip --sse
else
# This lambda needs to be moved to all regions
aws s3 cp cache/event_translator.zip s3://$TERRAFORM_BUCKET-$region/event_translator.zip --sse
fi
done
# Deploy the AWS resources
terraform apply -var lambda_bucket=$TERRAFORM_BUCKET