Skip to content

Commit

Permalink
destroy-coco-aks: don't delete resource group
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Jan 15, 2024
1 parent 9014099 commit 047b1b7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ get-credentials:
# Destroy a running AKS cluster.
destroy:
nix run .#destroy-coco-aks -- "$azure_resource_group"
nix run .#destroy-coco-aks -- --name="$azure_resource_group"
# Run code generators.
codegen:
Expand Down
2 changes: 1 addition & 1 deletion packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ rec {
destroy-coco-aks = writeShellApplication {
name = "destroy-coco-aks";
runtimeInputs = [ azure-cli-with-extensions ];
text = ''az group delete --name "$1"'';
text = builtins.readFile ./destroy-coco-aks.sh;
};

generate = writeShellApplication {
Expand Down
33 changes: 33 additions & 0 deletions packages/destroy-coco-aks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -euo pipefail
set -x

for i in "$@"; do
case $i in
--name=*)
name="${i#*=}"
shift
;;
*)
echo "Unknown option $i"
exit 1
;;
esac
done

exitcode=0

az aks nodepool delete \
--resource-group "${name}" \
--name nodepool2 \
--cluster-name "${name}" \
|| exitcode=$?

az aks delete \
--resource-group "${name}" \
--name "${name}" \
--yes \
|| exitcode=$?

exit "${exitcode}"

0 comments on commit 047b1b7

Please sign in to comment.