-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-stack.sh
executable file
·50 lines (42 loc) · 1.32 KB
/
create-stack.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
#!/bin/bash
rootDir="${0%/*}"
# Test to make sure variables are defined
: "${1:? domainName not set. create-stack <domainName> <environment> <?stackName>}"
: "${2:? environment not set. create-stack <domainName> <environment> <?stackName>}"
projectName=$3
if [ -z "$3" ]
then
projectName=$npm_package_name
else
projectName=$3
fi
: "${projectName:? stackName not provided. Run create-stack through npm or provide stackName as third arg.}"
stackName="$projectName-$2"
fullDomain="$2.$1"
read -p "Creating stack with the following details:
Stack name: $stackName
Domain: $fullDomain
Continue? (y/n)
" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
if
aws cloudformation create-stack \
--stack-name $stackName \
--capabilities CAPABILITY_NAMED_IAM \
--template-body file://$rootDir/resources-cloudformation.yml \
--parameters \
ParameterKey=RootDomainName,ParameterValue=$1 \
ParameterKey=EnvironmentName,ParameterValue=$2 ;
then
echo "Creating stack... (this can take several minutes)"
aws cloudformation wait stack-create-complete --stack-name $stackName
echo "Stack creation complete."
sh $rootDir/stack-info.sh $2 $projectName
else
echo "Could not create stack"
fi
else
echo "Exiting..."
fi