-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR addresses the deletion of an EKS cluster from the nuke DAG.
- Loading branch information
1 parent
f1887ee
commit ad9dbb7
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
astronomer/providers/amazon/aws/example_dags/example_delete_eks_cluster_and_nodes.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Check if the region parameter is provided | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <AWS_REGION>" | ||
exit 1 | ||
fi | ||
|
||
AWS_REGION="$1" | ||
|
||
# List all EKS clusters | ||
clusters=$(aws eks list-clusters --region $AWS_REGION | jq -r '.clusters[]') | ||
|
||
# Loop through each EKS cluster | ||
for cluster in $clusters; do | ||
echo "Processing EKS cluster: $cluster" | ||
|
||
# List nodegroups for the cluster | ||
nodegroups=$(aws eks list-nodegroups --cluster-name $cluster --region $AWS_REGION | jq -r '.nodegroups[]') | ||
|
||
# Delete each nodegroup | ||
for nodegroup in $nodegroups; do | ||
echo "Deleting nodegroup '$nodegroup' for cluster '$cluster'" | ||
aws eks delete-nodegroup --cluster-name $cluster --nodegroup-name $nodegroup --region $AWS_REGION | ||
aws eks wait nodegroup-deleted --cluster-name $cluster --nodegroup-name $nodegroup --region $AWS_REGION | ||
done | ||
|
||
|
||
# Delete the EKS cluster | ||
echo "Deleting EKS cluster: $cluster" | ||
aws eks delete-cluster --name $cluster --region $AWS_REGION | ||
|
||
# Wait for the EKS cluster to be deleted | ||
echo "Waiting for EKS cluster '$cluster' to be deleted..." | ||
aws eks wait cluster-deleted --name $cluster --region $AWS_REGION | ||
|
||
done | ||
|
||
echo "Script execution completed." |