-
Notifications
You must be signed in to change notification settings - Fork 0
/
AWS_deploy.sh
executable file
·59 lines (37 loc) · 1.86 KB
/
AWS_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
export REGION="us-east-1"
myKey='NVirginia'
REPO_NAME="biotech"
echo ""
echo "creating vpc stack"
echo ""
aws cloudformation create-stack --capabilities CAPABILITY_IAM --stack-name ecs-core-infrastructure --template-body file://./templates/core-infrastructure-setup.yml
aws cloudformation wait stack-create-complete --stack-name ecs-core-infrastructure
export CORE_STACK_NAME="ecs-core-infrastructure"
export vpc=$(aws cloudformation describe-stacks --stack-name $CORE_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`VpcId`].OutputValue' --output text)
export subnet_1=$(aws cloudformation describe-stacks --stack-name $CORE_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`PublicSubnetOne`].OutputValue' --output text)
export subnet_2=$(aws cloudformation describe-stacks --stack-name $CORE_STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`PublicSubnetTwo`].OutputValue' --output text)
echo "vpc: $vpc"
echo "subnet1: $subnet_1"
echo "subnet2: $subnet_2"
REPO_URI=$(aws ecr describe-repositories --repository-names "${REPO_NAME}" --query "repositories[0].repositoryUri" --output text 2>/dev/null || \
aws ecr create-repository --repository-name "${REPO_NAME}" --query "repository.repositoryUri" --output text)
echo ""
echo "repository uri" $REPO_URI
STACK_NAME="BiotechDashboard"
aws cloudformation deploy \
--stack-name $STACK_NAME \
--template-file ./templates/ecs-webapp-stack.yml \
--capabilities CAPABILITY_IAM \
--parameter-overrides KeyName=$myKey \
VpcId=$vpc \
SubnetId=$subnet_1,$subnet_2 \
ContainerPort=8000 \
DesiredCapacity=2 \
EcsImageUri=$REPO_URI \
EcsImageVersion='latest' \
InstanceType=t2.micro \
MaxSize=3
ALB_DNS=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[0].Outputs[?OutputKey==`ecsalb`].OutputValue' --output text)
echo ""
echo $ALB_DNS