wash
wash copied to clipboard
Allow SSH to instances using private IP address
Use Case
I would like to be able to use wash to interact with compute instances (specifically on AWS) using the private IP address. I have an established VPN connection to my VPC and none of my instances have public IPs or hostnames.
Describe the Solution You Would Like
I would like to see a configuration option that allows me to override the default behavior of attempting to SSH to an instance using the public IP or hostname. When this configuration option is set, it will only attempt to connect to the instance via the configured metadata value (whether PrivateIpAddress, PublicIpAddress, etc.)
Describe Alternatives You've Considered
I'm unable to assign public IPs or hostnames to my instances, so I have no other alternative at present.
Thanks for opening your first issue here! We will follow up as soon as we can.
This seems pretty straight-forward. https://github.com/puppetlabs/wash/blob/0.9.0/plugin/aws/ec2Instance.go#L262-L269 handles selecting what connection information to use. If there's no public IP address/DNS hostname we could fall back to private IP address.
Making it configurable to only use a specific metadata seems useful. That's a little more effort to add, as it needs to be passed down from plugin initialization at https://github.com/puppetlabs/wash/blob/0.9.0/plugin/aws/root.go#L64 to profile
-> resourcesDir
-> ec2Dir
-> ec2InstancesDir
-> ec2Instance
. This suggests to me it'd be helpful to have a way to transparently pass config to other places in the plugin (something also requested in #349. In this case attaching config to every context we pass to plugin operations might be simple and cover most cases.
I'm going to be out on parental leave the next couple weeks, so may not get to it immediately. Do you have any interest in trying to add either the private IP fallback, or a config option?