-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdestroy-all.sh
30 lines (23 loc) · 939 Bytes
/
destroy-all.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
#!/bin/sh
# Verify that the AZ_RESOURCE_GROUP environment variable is defined
if [ -z "$AZ_RESOURCE_GROUP" ]; then
echo "Error: The AZ_RESOURCE_GROUP environment variable is not defined."
exit 1
fi
# Confirm the deletion of the resource group
echo "You are about to delete the resource group: $AZ_RESOURCE_GROUP"
read -p "Are you sure? This action cannot be undone. (yes/no): " confirm
# Convert the response to lowercase to facilitate comparison
confirm=$(echo "$confirm" | tr '[:upper:]' '[:lower:]')
# Check if the response is a form of "yes"
if [ "$confirm" != "yes" ] && [ "$confirm" != "y" ] && [ "$confirm" != "sí" ] && [ "$confirm" != "s" ]; then
echo "Operation canceled."
exit 0
fi
# Deleting resource group
echo "Deleting resource group: $AZ_RESOURCE_GROUP"
az group delete \
--name $AZ_RESOURCE_GROUP \
--yes \
--no-wait
echo "Resource group deletion initiated. This may take a few minutes."