Aws / Delete Eks Cluster 1608
Delete Eks Cluster 1608
Deletes an existing EKS cluster.
aws eks delete-cluster --name <cluster_name> aws eks delete-cluster --name <cluster_name> #!/bin/bash
# Delete Eks Cluster 1608
aws eks delete-cluster --name {{cluster_name}} import subprocess
# Delete Eks Cluster 1608
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"aws",
"eks",
"delete-cluster",
"--name",
"<cluster_name>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: aws not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
When decommissioning a project or redeploying a new environment in the same VPC.
Pro Tip
Ensure all services (e.g., workloads, node groups) are properly terminated to avoid resource conflicts.
Warning
Destructive operation. Confirm the target path and keep a backup before executing.
Command Builder
Tune the command before you copy it
aws eks delete-cluster --name <cluster_name> Terminal Output
Expected runtime feedback
$ aws eks delete-cluster --name eks-cluster-1608
{
"cluster": {
"name": "eks-cluster-1608",
"status": "DELETING"
}
}
$ aws eks describe-cluster --name eks-cluster-1608
An error occurred (ResourceNotFoundException) when calling the DescribeCluster operation: Cluster_eks-cluster-1608 not found. Anatomy of Output
Understanding the result
Deleting Cluster: my-cluster Cluster Action Indicates the initiation of cluster deletion.
Cluster Status: DELETING Current Status Current operational status of the cluster during deletion.
Termination in progress... Deletion Progress Cluster components are being destroyed.
Troubleshooting
Common pitfalls
An error occurred (Resource_in_use) when calling the DeleteCluster operation: Cluster is not empty.
Solution: Ensure all associated resources are cleaned up before deletion.
An error occurred (AccessDeniedException) when calling the DeleteCluster operation: User is not authorized to perform eks:DeleteCluster.
Solution: Verify IAM policies to ensure deletion permissions are granted.
An error occurred (ClusterNotFoundException) when calling the DeleteCluster operation: Cluster not found.
Solution: Confirm that the cluster name entered is correct.
Command Breakdown
What each part is doing
-
aws - Base Command
- The executable that performs this operation. Here it runs Aws before the shell applies any redirect operators.
-
<cluster_name> - cluster name
- The value supplied for cluster name.
-
--name - Command Option
- Tool-specific option used by this command invocation.
How To Run
Execution path
- Step 1
Run the command: aws eks delete-cluster --name eks-cluster-1608
- Step 2
Verify the deletion status with: aws eks describe-cluster --name eks-cluster-1608
Alternative Approaches
Comparable commands in other tools
Alternative cloud infrastructure tools for the same job.