[communicator] add proxy_command
support to connection block
#36643
+383
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have a Terraform use-case where I am using an AWS EC2 Instance Connect Endpoint to access instances in different AWS accounts that do not have direct network access from the network location in which Terraform runs so that SSH connections can be established for use on
remote-exec
provisioner blocks. AWS's connection guide offers a few different methods:aws ec2-instance-connect open-tunnel
via anssh -o ProxyCommand=
argument.aws ec2-instance-connect open-tunnel --local-port
as a background process to be used as a TCP proxy.aws ec2-instance-connect ssh
to open an interactive ssh session.Of these, using an out-of-the-box Terraform I attempted to get number 2 to work. It was hacky, using
terraform_data
withlocal-exec
provisioners to control starting and stopping of the process in a detached tmux. I had some success with it but am running into issues with handling Terraform resource provisioners leaving the processes hanging. It would simply be much cleaner to implement the ability to use a ProxyCommand-like attribute on the Terraform ssh connections.This PR implements a
proxy_command
attribute on theconnection
block that will pipe SSH communication through an exec'd process. This enables the ability to useaws ec2-instance-connect
as described in number 1. No workarounds are then required to use Terraform with instances that are only reachable through EC2 Instance Connect or potentially any number of other proxy methods.Target Release
1.12.x
CHANGELOG entry