ec2-ls-hosts

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2019 License: MIT Imports: 8 Imported by: 0

README

ec2-ls-hosts: an alternative tool for list ec2 instances

ls-hosts is a simple cli-tool for describing ec2 instances. This tool will simplify the operation to describe instances. You can integrate this tool with unix tools (eg: awk, ssh, peco, and so on.)

Usage

$ ls-hosts
i-00000001 10.0.0.1 app01 running
i-00000002 10.0.0.2 app02 running
i-00000003 10.0.0.3 app03 running

CLI Options

with options

-filters

ec2 filter (Docs)

-filters=key1:value1,key2:value2...

-tags

tag filter

-tags=key1:value1,key2:value2...

-fields

support fields

  • instance-id
  • private-ip
  • public-ip
  • tag:*
-fields=c1,c2,c3,...

-region

AWS region

-creds

support credentials

  • env
  • shared
  • ec2

-noheader

Not Display field headers, if set true.

with config file
  1. ~/.ls-hosts
  2. /etc/ls-hosts.conf
[options]
creds    = shared
profile  = default
region   = ap-northeast-1
tags     = Role:app,Env:production
fields   = instance-id,tag:Name,public-ip,private-ip
noheader = true

Integration with zsh and peco

  • With this integration, you can ssh login with interactive host selector

Dependencies

function peco-ec2-ls-hosts () {
  BUFFER=$(
    /path/to/ls-hosts -fields instance-id,tag:Role,tag:Name | \
    peco --prompt "EC2 >" --query "$LBUFFER" | \
    awk '{printf "echo \"Login:%s"; ssh %s\n", $3,$2}'
  )
  CURSOR=$#BUFFER
  zle accept-line
  zle clear-screen
}
zle -N peco-ec2-ls-hosts
bindkey '^oo' peco-ec2-ls-hosts

Build

$ make build (-B)

Dependencies

Contribution

  • Fork (https://github.com/ReSTARTR/ec2-ls-hosts/fork)
  • Create a feature branch
  • Commit your changes
  • Rebase your local changes against the master branch
  • Run test suite with the make test command and confirm that it passes
  • Create a new Pull Request

Author

ReSTARTR

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL