-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlaunch-stack.sh
executable file
·31 lines (22 loc) · 1.04 KB
/
launch-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
#!/bin/bash
# sudo chmod +x *.sh
# ./launch-stack.sh
AWS_REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/')
MYNAME=${1:-pmd}
PROJECTNAME=${2:-diagrams}
TMPDIR=${3:-tmp-gitrepo}
S3BUCKET=${4:-$PROJECTNAME-$MYNAME}
SAMSTACK=${5:-$PROJECTNAME-$MYNAME-$AWS_REGION}
CFNSTACK=${6:-$PROJECTNAME-$MYNAME}
PIPELINEYAML=${7:-pipeline.yml}
OTHER=${8:-pmd-serverless}
sudo rm -rf $TMPDIR
mkdir $TMPDIR
cd $TMPDIR
git clone https://github.com/PaulDuvall/diagrams-as-code.git
aws s3api list-buckets --query 'Buckets[?starts_with(Name, `'$S3BUCKET'`) == `true`].[Name]' --output text | xargs -I {} aws s3 rb s3://{} --force
aws s3 mb s3://$S3BUCKET-$(aws sts get-caller-identity --output text --query 'Account')
aws cloudformation delete-stack --stack-name $CFNSTACK
aws cloudformation wait stack-delete-complete --stack-name $CFNSTACK
cd diagrams-as-code
aws cloudformation create-stack --stack-name $CFNSTACK --capabilities CAPABILITY_NAMED_IAM --disable-rollback --template-body file://$PIPELINEYAML