Instagram/ec2-ssh — pull request #13 by ttddyy (2012-12-07 05:09:39+00:00)
Title: ec2-printconfig script

print out ec2 instances as ssh-config or hosts file format.

Inspired by "ec2-host" command, I wrote a script that prints out instance_name and ip_address as ssh-config or hosts file format since I use ".ssh/config" or "/etc/hosts" to manage ec2 instances.

Hopefully, this script would help others who manage ec2 instances similar to how I do.

Thanks,

command example:
```
# display entries as ssh-config file format
./ec2-printconfig -k -s -r us-west-2

# display entries as hosts file format
./ec2-printconfig --format hosts

# add prefix "my-" to instance name. (ex: my-foo, my-bar, ...)
./ec2-printconfig --prefix my-

# add domain "mydomain.com" to instance name. (ex: foo.mydomain.com, bar.mydomain.com, ...)
./ec2-printconfig --domain mydomain.com

# use elastic IP instead of private IP
./ec2-printconfig --use-elastic-ip

# filter instances. (ex: only running and monitored instances. )
./ec2-printconfig --filter monitoring-state=enabled --filter instance-state-name=running

# specify tag for instance name. (ex: assume there is alias tag)
./ec2-printconfig -t alias
```