42ed07057804e16788aca1a2871efd65f5855292
- Author
- TheEdgeOfRage <git@theedgeofrage.com>
- Committer
- TheEdgeOfRage <git@theedgeofrage.com>
- Date
Message
Add ec2_terminate zsh function
Diff
1diff --git a/dot_config/zsh/functions/ec2_terminate b/dot_config/zsh/functions/ec2_terminate
2new file mode 100644
3index 0000000000000000000000000000000000000000..5cd3e486af280e50965f4151a11033d4b9be2558
4--- /dev/null
5+++ b/dot_config/zsh/functions/ec2_terminate
6@@ -0,0 +1,7 @@
7+# vim: ft=zsh
8+# Terminate an AWS EC2 instance by its EKS name
9+
10+[ -z "$1" ] && echo "Usage: terminate [instance-name]" && return
11+INSTANCE_ID=$(aws ec2 describe-instances --filter "Name=private-dns-name,Values=$1" | jq -r '.Reservations[0].Instances[0].InstanceId')
12+[ "$INSTANCE_ID" == "null" ] && echo "Instance $1 not found" && return
13+aws ec2 terminate-instances --instance-id="$INSTANCE_ID"