Skip to content

Instantly share code, notes, and snippets.

@remino
Created November 22, 2012 05:12
Show Gist options
  • Save remino/4129507 to your computer and use it in GitHub Desktop.
Save remino/4129507 to your computer and use it in GitHub Desktop.
EC2 API Tools: Get the ID of an instance from its name
#!/bin/bash
ec2iid() {
ec2-get-instance-id-from-name "$@"
}
ec2-get-instance-id-from-name() {
ec2-describe-instances | grep TAG | grep Name | grep "$@" | \
while read type thing id label value; do
[ "$value" == "$@" ] && echo $id && break
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment