Last active
May 20, 2025 10:39
-
-
Save turboBasic/02cf7612109d6d1434364bb7bf2d3ac6 to your computer and use it in GitHub Desktop.
Helpers for AWS CLI #aws #zsh
This file contains hidden or 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
# List running EC2 instances filtered by `Name` tag | |
# | |
# params: | |
# $1 - optional string. Filters output by instances with `Name` tag containing the string | |
function aws-ec2() { | |
aws ec2 describe-instances \ | |
--filter "Name=instance-state-name,Values=running" \ | |
--filter "Name=tag:Name,Values=*$1*" \ | |
--query "Reservations[].Instances[].{ | |
id: InstanceId, | |
name: Tags[?Key=='Name'].Value | join(' ', @) | |
}" \ | |
| jq "map({(.name): .id}) | add" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment