Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Conversation

@ttddyy
Copy link

@ttddyy ttddyy commented Dec 7, 2012

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 <aws_key> -s <aws_secret> -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

print out ec2 instances as ssh-config or hosts file format.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant