-
Notifications
You must be signed in to change notification settings - Fork 1
/
uninstall.sh
executable file
·59 lines (44 loc) · 2.57 KB
/
uninstall.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
#!/bin/bash
set -euo pipefail
export $(grep -v '^#' .env | xargs -0)
STACK_PREFIX=nitro-vault
VPC_STACK_NAME="${STACK_PREFIX}-vpc"
KEY_STACK_NAME="${STACK_PREFIX}-key"
CI_STACK_NAME="${STACK_PREFIX}-ci"
VAULT_STACK_NAME="${CI_STACK_NAME}-vault"
API_STACK_NAME="${CI_STACK_NAME}-api"
CANARY_STACK_NAME="${CI_STACK_NAME}-canary"
printf "[!] Deleting ${CANARY_STACK_NAME} CloudFormation Stack..."
aws cloudformation delete-stack --stack-name "${CANARY_STACK_NAME}"
printf "\n[!] Deleting ${API_STACK_NAME} CloudFormation Stack..."
aws cloudformation delete-stack --stack-name "${API_STACK_NAME}"
printf "\n[!] Deleting ${VAULT_STACK_NAME} CloudFormation Stack..."
aws cloudformation delete-stack --stack-name "${VAULT_STACK_NAME}"
printf "\n[!] Waiting for ${VAULT_STACK_NAME} stack to be deleted..."
aws cloudformation wait stack-delete-complete --stack-name "${VAULT_STACK_NAME}"
printf "\n[-] Deleted ${VAULT_STACK_NAME}.\n"
printf "\n[!] Waiting for ${API_STACK_NAME} stack to be deleted..."
aws cloudformation wait stack-delete-complete --stack-name "${API_STACK_NAME}"
printf "\n[-] Deleted ${API_STACK_NAME}.\n"
printf "\n[!] Waiting for ${CANARY_STACK_NAME} stack to be deleted..."
aws cloudformation wait stack-delete-complete --stack-name "${CANARY_STACK_NAME}"
printf "\n[-] Deleted ${CANARY_STACK_NAME}.\n"
BUCKET_NAME=$(aws cloudformation describe-stacks --stack-name "${CI_STACK_NAME}" --query "Stacks[0].Outputs[?OutputKey=='oArtifactBucketName'].OutputValue" --output text)
printf "\n[!] Deleting ${KEY_STACK_NAME} CloudFormation Stack..."
aws cloudformation delete-stack --stack-name "${KEY_STACK_NAME}"
printf "\n[!] Waiting for ${KEY_STACK_NAME} stack to be deleted..."
aws cloudformation wait stack-delete-complete --stack-name "${KEY_STACK_NAME}"
printf "\n[-] Deleted ${KEY_STACK_NAME}.\n"
printf "\n[!] Deleting ${CI_STACK_NAME} CloudFormation Stack..."
aws cloudformation delete-stack --stack-name "${CI_STACK_NAME}"
printf "\n[!] Waiting for ${CI_STACK_NAME} stack to be deleted..."
aws cloudformation wait stack-delete-complete --stack-name "${CI_STACK_NAME}"
printf "\n[-] Deleted ${CI_STACK_NAME}.\n"
printf "\n[!] Deleting ${VPC_STACK_NAME} CloudFormation Stack..."
aws cloudformation delete-stack --stack-name "${VPC_STACK_NAME}"
printf "\n[!] Waiting for ${VPC_STACK_NAME} stack to be deleted..."
aws cloudformation wait stack-delete-complete --stack-name "${VPC_STACK_NAME}"
printf "\n[-] Deleted ${VPC_STACK_NAME}.\n"
printf "\n[!] Please empty the ${BUCKET_NAME} S3 bucket and delete it to finish deleting all resources."
printf "\n[-] Nitro Vault Successfully Uninstalled"
exit 0