-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-stack-aws.sh
executable file
·94 lines (81 loc) · 1.89 KB
/
deploy-stack-aws.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
set -e
set -o pipefail
usage() {
cat << EOF
Deploys a stack to AWS with everything defined here.
Assumes aws-vault installed and your profile is created.
Options:
-a <profile> --aws-profile <profile> Sets the profile to use (see: ~/.aws/config and aws-vault list)
-u <email> --test-user <email> Sets the test user email address
-s <name> --stack <name> Sets the name of the stack (required)
-h --help Prints this help message and exits
EOF
}
# parameters
while [ -n "$1" ]; do
case $1 in
-a | --aws-profile)
shift
PROFILE=$1
;;
-s | --stack)
shift
STACK_NAME=$1
;;
-u | --test-user)
shift
TEST_USER_EMAIL=$1
;;
-h | --help)
usage
exit 0
;;
*)
echo -e "Unknown option $1...\n"
usage
exit 1
;;
esac
shift
done
if [ -z "$PROFILE" ]; then
echo "Please provide a profile."
usage
exit 1
fi
if [ -z "$STACK_NAME" ]; then
echo "Please set the stack name."
usage
exit 1
fi
if [ -z "$TEST_USER_EMAIL" ]; then
echo "Please set a test user email address."
usage
exit 1
fi
# build
aws-vault exec $PROFILE --no-session -- \
sam build
# deploy
aws-vault exec $PROFILE --no-session -- \
sam deploy \
--stack-name $STACK_NAME \
--region eu-west-2 \
--capabilities CAPABILITY_IAM \
--resolve-s3 \
--parameter-overrides CognitoTestUserEmail=$TEST_USER_EMAIL
# get outputs from stack
eval $(util-scripts/export-stack-outputs.sh -a $PROFILE -s $STACK_NAME -x OUT_)
export -p | grep OUT_
echo
# update the test user password
TEST_USER_PASSWORD="testpass1"
echo "Setting password for ${TEST_USER_EMAIL} to: ${TEST_USER_PASSWORD}"
echo
aws-vault exec $PROFILE --no-session -- \
aws cognito-idp admin-set-user-password \
--user-pool-id $OUT_UserPoolId \
--username $TEST_USER_EMAIL \
--password $TEST_USER_PASSWORD \
--permanent