-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit-config
executable file
·75 lines (57 loc) · 1.69 KB
/
init-config
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
#!/usr/bin/env bash
# MacOS by default has BSD grep, and brew installs GNU grep as ggrep
if command -v ggrep &>/dev/null; then
grep="ggrep"
else
grep="grep"
fi
if [ -e samconfig.toml ]; then
echo The file samconfig.toml exists
echo
echo If you actually mean to initialize the configuration for this deployment, move or delete the existing file
exit 1
fi
# Text highlighting escape sequences
__hi="\e[33m"
__endhi="\e[0m"
profiles=$([ -e ~/.aws/credentials ] && $grep -Po '(?<=^\[).+(?=\]$)' < ~/.aws/credentials)
if [ ${#profiles} -eq 0 ]; then
echo No AWS profiles defined in ~/.aws/credentials
echo
echo -e "${__hi}If you configure your AWS profile manually by running \`aws configure\`, the profile used for deployment"
echo -e "can then be manually added to the samconfig.toml file under [default.deploy.parameters]$__endhi"
else
echo Your configured AWS profiles:
echo
echo "$profiles"
echo
echo Which AWS profile would you like to use for deployment?
echo
read -rp "> " profile
if [ -z "$profile" ]; then
echo
echo Profile must be specified
exit 1
fi
echo
echo Using profile: "$profile"
fi
echo
echo Creating initial configuration...
echo
echo -n "Generating strong passwords for database access and administration"
function pw () {
./manage gen-rds-db-password
}
p1="DBAdminPassword=\\\"$(pw)\\\"" && echo -n .
p2="DBWriterPassword=\\\"$(pw)\\\"" && echo -n .
p3="DBReaderPassword=\\\"$(pw)\\\"" && echo -n .
echo \ done
echo
cp -v .config-templates/* .
echo
echo Writing initial configuration...
echo profile = \""$profile"\" >> samconfig.toml
echo parameter_overrides = \""$p1" "$p2" "$p3"\" >> samconfig.toml
echo
echo Created: samconfig.toml