I love amazon aws cloud service. I love how it allows me to experiment with things without upfront payment for infrastructure and also the fact that the pay-per-use price is a fraction of what a infrastructure investment would’ve been. With this love, I started tinkering with it and started doing a lot of setups. But every time I need some basic information about my aws instances(like dhcp ip & run status), I need to open the aws console in browser and navigate to AWS console & EC2 Dashboard.
If you are like me, you probably don’t like this browser business while showing your commandline-fu either! So I decided to create a small script to run on command line to help me with this chore and here is how it works when I type lsaws (short form for List AWS instances) in linux terminal,…
As you can see, there are no login prompts and it usually takes a second or two to complete. It can list ec2 instances in your aws account in a tabular form along with ip addresses and running state. Purpose of this is to get the details that you usually need frequently (like ip and state) with out logging in to aws console every time. please read on to find out more on how to install this tool in your system.
Note : all these instructions are tested on ubuntu 16.04 but they should work for other flavors of linux without no significant changes. But if you want to set this up on windows, the js code should work as it is but the
- Prerequisite Steps
- Install git client
- configure aws credentials in ~/.aws/credentials file
- Clone this project in to your home directory , build & configure
Note : Type below commands in a linux terminal & dont forget to replace “your_region” with your actual aws region Ex: us-east-1
cd ~ mkdir git cd git git clone https://github.com/udaygin/aws_scripts.git cd aws_scripts npm install #Update your ~/.bashrc to run it as a command from any directory and reload it echo "alias lsaws='node ~/git/aws_scripts/lsaws.js'" >> ~/.bashrc source ~/.bashrc #Update aws region(replace your_region with your actual region in below command ) sed -i 's/us-east-1/your_region/g' ~/git/aws_scripts/lsaws.js
lsaws“ (with out quotes 😛 )
As usual, please feel to get in touch with me if you notice any issues or if you need any help.