Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to setup provisioner infrastructure with Terraform Cloud #177

Closed
wants to merge 9 commits into from

Conversation

mvgijssel
Copy link
Member

@mvgijssel mvgijssel commented Mar 23, 2023

ref #176

Tried a couple of modules/providers to setup a SSH tunnel to the Kubernetes cluster from Terraform Cloud but no luck so far.

Terraform provider jumphost does not work because of jaysonsantos/terraform-provider-jumphost#7, the provider is killed and takes the ssh connection with it. Does not work locally and Terraform Cloud.

The https://registry.terraform.io/modules/flaupretre/tunnel/ssh/latest module does not work because it always tries to authenticate with password instead of using the actual passed in identity file. Works with local execution.

The https://registry.terraform.io/providers/AndrewChubatiuk/ssh/latest/docs/data-sources/tunnel provider establishes a SSH connection but directly afterwards disconnects. This is also described in this issue AndrewChubatiuk/terraform-provider-ssh#10, but even the fork https://registry.terraform.io/providers/thecadams/ssh/latest does not work. Works with local execution.

@mvgijssel
Copy link
Member Author

mvgijssel commented Mar 23, 2023

Configured the Terraform Cloud provisioner workspace with a working directory of stacks/provisioner to make sure everything in infrastructure/* gets uploaded as well.

@mvgijssel
Copy link
Member Author

Disabled Unifi SSH access and enabled port forwarding to the provisioner SSH.

@mvgijssel
Copy link
Member Author

Seemed the https://registry.terraform.io/modules/flaupretre/tunnel/ssh/latest module failed due to an invalid private key used! Generating a new one using

ssh-keygen -t rsa -m PEM

uploading that to Terraform Cloud and updating the provisioner authorized_keys resulted in a working deploy!

@mvgijssel
Copy link
Member Author

Also tried a different key with https://registry.terraform.io/providers/thecadams/ssh/latest but unfortunately that did not work. Currently only https://registry.terraform.io/modules/flaupretre/tunnel/ssh/latest is working in Terraform Cloud remote execution.

@mvgijssel
Copy link
Member Author

Let's create our own module ssh_tunnel using https://registry.terraform.io/modules/Invicton-Labs/shell-resource/external/latest which basically does:

  1. Run SSH in the background and capture stdout / stderr in a file
  2. Sleep for 5 seconds
  3. Check if PID is still running
  4. If running then echo log file and exit 0
  5. If not running then echo log file and exit 1

@mvgijssel mvgijssel changed the title try ssh tunnel Try to setup provisioner infrastructure with Terraform Cloud Mar 29, 2023
@mvgijssel
Copy link
Member Author

Going to try a different route with Pulumi.

@mvgijssel mvgijssel closed this Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant