List view of aws ec2 instances
$ brew install goldeneggg/tap/lsec2
Note:
If you have already installed an old version's lsec2 using brew tap goldenegg/lsec2
command and brew install lsec2
command, please uninstall old version.
# uninstall old tap version
$ brew uninstall lsec2
$ brew untap goldeneggg/lsec2
# and install new tap version
$ brew install goldeneggg/tap/lsec2
$ go get -u github.com/goldeneggg/lsec2
Download from latest release
2 variables are required
$ export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
Write your credential information in ~/.aws/credentials
file
- Write a
[default]
section - Write
aws_access_key_id
in[default]
section - Write
aws_secret_access_key
in[default]
section
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
More information: session - Amazon Web Services - Go SDK
# print all instances info by list view
$ lsec2
Result contains informations of instances as follows
- instance id
- private ip address
- public ip address
- instance type
- instance state
- tags
Show more detail information by typing lsec2 -h
You can use 3 patterns
- assign by
--region
option (top priority)
$ lsec2 --region ap-northeast-1
- set
AWS_REGION
environment
$ export AWS_REGION=ap-northeast-1
- set
AWS_SDK_LOAD_CONFIG
environment, and writeregion
key in~/.aws/config
file
$ export AWS_SDK_LOAD_CONFIG=true
$ vi ~/.aws/config
[default]
region = ap-northeast-1
Show more information from public AWS documents
# filterd by a tag key-value separated by "="
$ lsec2 TagName1=tagvalue1
# filterd by some tags
$ lsec2 TagName1=tagvalue1 TagNameN=tagvalueN
# filterd by a tag multiple values separated by comma
$ lsec2 TagName1=tagvalue11,tagvalue12,tagvalue1N
# with header
$ lsec2 -H
# filter state
$ lsec2 -s running
$ lsec2 -s stopped
$ lsec2 -s OTHER_STATE
# print only private IP address
$ lsec2 -p
# print state with color
# ("running" is green, "stopped" is red, and others are yellow)
$ lsec2 -c
peco is a very useful interactive filtering tool.
- Example: print instances => select instance => SSH to selected instance
# add function to your .bashrc or .bash_profile or other shell dotfile
$ vi YOUR_DOTFILE
lssh () {
IP=$(lsec2 $@ | peco | awk -F "\t" '{print $2}')
if [ $? -eq 0 -a "${IP}" != "" ]
then
ssh ${IP}
fi
}
# load dotfile
$ source YOUR_DOTFILE
# shortcut "lsec2 OPTIONS TAG_FILTERS" => "ssh PRIVATE_IP"
$ lssh TagName1=tagvalue1
gat is a file posting tool to various services like cat
command.
- Example: print instances => share your slack
# shortcut "lsec2 OPTIONS TAG_FILTERS" => copy this results to your slack channel
$ lsec2 TagName1=tagvalue1 | gat slack
Please follow Contributor's Guide
Bugs: issues
CHANGELOG file for details.
LICENSE file for details.