When you are working with AWS Cloud infrastructure and when you have 100s of instances to manage in multiple accounts.
You might know how hard it is to get the private IP or the public IP info or any other details of a particular EC2 instance
Let's say your entire tech stack is on AWS and you have various applications hosted with many Auto Scaling Groups and they make 100s of Ec2 instances.
Now. you want to find a particular EC2 instance that you need to SSH in.
How do you search for an EC2 instance with the name quickly from the command line and get its details like Private IP for you to log in.
I am doing it every single day. It's not easy to just update the AWS CLI command and execute it all the time.
and it is not recommended to login to AWS web console every time and 2FA too.
Would it be not nice to have some CLI command like this?
ec2search <instance_name> <prod_profile> or ec2search <instance_name> <dev_profile>
Some CLI tool that helps you to search EC2 instance using the AWS CLI profiles, I have in my local and search EC2 instance by their name
That's exactly what I have come up with and named it ec2search
What is ec2search
ec2search is an easy-to-install single binary tool for Linux, Windows and Mac which uses AWS CLI installed and configured.
It acts as a wrapper for the AWS CLI and helps you to search EC2 instances by their name.
I have built this on the Go language and made it open source.
When you want to search any EC2 instance by its name across multiple AWS-named profiles. EC2 search is your tool.
This is a keep it handy tool for all SREs and DevOps Engineers who work with AWS every single day.
Here is a quick screenshot of what ec2search is capable of
Prerequisites
- AWS CLI installed and configured
- Sufficient Authentication to list Ec2 instances using AWS CLI
If you are new to AWS CLI, refer this article before continuing
AWS EC2 CLI List Examples – Describe instances | Devops Junction
How to download and use it
Clone of Github project or download the right binaries from ec2search github repo
Once you have downloaded the binaries.
Rename your binary name from ec2search-<os-name>-<archname>
to just ec2search
Move this binary to the /usr/local/bin
or add to your PATH
variable so that you dont have to give full path all the time.
For example: If you have downloaded a binary for your mac and we presume it is available on ~/Downloads
directory
Just execute these commands on your terminal
$ cd ~/Downloads $ mv ec2search-darwin-amd64 ec2search $ sudo mv ec2search /usr/local/bin
that's all. installation is complete.
Now just type, to search your current default profile
ec2search <searchstring>
If you want to search the server in specific AWS CLI named profiles,
ec2search <searchstring> <profilename>
you would see the list of instances matching your search string.
Remember the searchstring is case sensitive.
Web
would match onlyWeb
notweb
orwEb
In our next version will try to add search support for case insensitive.
Github link to Fork/Download
You can downlaod the Source code of this EC2 search or the binaries from the following github repo link
https://github.com/AKSarav/EC2Search
Try SQSCLI - Freemium SQS browser
Like this tool, we have recently published a freemium and pro tool named SQSCLI. Its ia browser to peek into SQS messages on transit.
Take a look. you might find it helpful
Conclusion
Hope this tool helps, if you have any custom requirement or problem where you need an automated solution. please do reach out to us at [email protected]
Thanks
Sarav AK
Follow me on Linkedin My Profile Follow DevopsJunction onFacebook orTwitter For more practical videos and tutorials. Subscribe to our channel
Signup for Exclusive "Subscriber-only" Content