-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdelete-stack.sh
executable file
·32 lines (22 loc) · 944 Bytes
/
delete-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
#!/bin/bash
# sudo chmod +x *.sh
# ./delete-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:-cloudproviders}
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/cloudproviders.git
aws s3api list-buckets --query 'Buckets[?starts_with(Name, `'$S3BUCKET'`) == `true`].[Name]' --output text | xargs -I {} aws s3 rb s3://{} --force
sleep 20
aws cloudformation delete-stack --stack-name $SAMSTACK
aws cloudformation wait stack-delete-complete --stack-name $SAMSTACK
aws cloudformation delete-stack --stack-name $CFNSTACK
aws cloudformation wait stack-delete-complete --stack-name $CFNSTACK