forked from nasa/cumulus-template-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployment-one-time-setup.sh
43 lines (32 loc) · 1.35 KB
/
deployment-one-time-setup.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
#!/bin/bash
set -e
echo Using prefix $PREFIX
### CREATE BUCKETS
echo Creating buckets
if [[ $AWS_REGION = "us-east-1" ]]; then
aws s3api create-bucket --bucket $PREFIX-internal
aws s3api create-bucket --bucket $PREFIX-public
aws s3api create-bucket --bucket $PREFIX-private
aws s3api create-bucket --bucket $PREFIX-protected
else
aws s3api create-bucket --bucket $PREFIX-internal --create-bucket-configuration LocationConstraint=$AWS_REGION
aws s3api create-bucket --bucket $PREFIX-public --create-bucket-configuration LocationConstraint=$AWS_REGION
aws s3api create-bucket --bucket $PREFIX-private --create-bucket-configuration LocationConstraint=$AWS_REGION
aws s3api create-bucket --bucket $PREFIX-protected --create-bucket-configuration LocationConstraint=$AWS_REGION
fi
### CREATE JWT SECRET FOR TEA ###
echo Creating JWT
TEA_JWT_SECRET=$PREFIX"_jwt_secret_for_tea"
ssh-keygen -N '' -t rsa -b 4096 -m PEM -f ./jwtcookie.key
rsa_priv_key=$(openssl base64 -in jwtcookie.key -A)
rsa_pub_key=$(openssl base64 -in jwtcookie.key.pub -A)
cat << EOL > jwtkeys.json
{
"rsa_priv_key": "$rsa_priv_key",
"rsa_pub_key": "$rsa_pub_key"
}
EOL
echo Storing JWT in secret $TEA_JWT_SECRET
aws secretsmanager create-secret --name $TEA_JWT_SECRET\
--description "RS256 keys for TEA app JWT cookies" \
--secret-string file://jwtkeys.json