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

Crash when using ssh connection over HTTP proxy #30982

Closed
alisdair opened this issue May 3, 2022 · 3 comments · Fixed by #30984
Closed

Crash when using ssh connection over HTTP proxy #30982

alisdair opened this issue May 3, 2022 · 3 comments · Fixed by #30984
Assignees
Labels
new new issue not yet triaged provisioner/file v1.2 Issues (primarily bugs) reported against v1.2 releases

Comments

@alisdair
Copy link
Member

alisdair commented May 3, 2022

Thanks for working on this feature. I was doing some testing last days and I found some issues during the provisioning of files. I was not sure if opening a new bug or continuing with the conversation here, so let me know if I need to move to a new one.

Terraform version

  • Terraform v1.3.0-dev on windows_amd64.
  • Terraform v1.3.0-dev on linux_amd64.

Debug Output

aws_instance.test: Provisioning with 'file'...
2022-05-03T08:59:29.827+0800 [INFO]  using private key for authentication
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x1f545d8]

goroutine 167 [running]:
github.com/hashicorp/terraform/internal/communicator/ssh.(*Communicator).Connect(0xc002ff7240, {0x0, 0x0})
        C:/Users/test/Desktop/terraform/internal/communicator/ssh/communicator.go:176 +0x658
github.com/hashicorp/terraform/internal/builtin/provisioners/file.copyFiles.func1()
        C:/Users/test/Desktop/terraform/internal/builtin/provisioners/file/resource_provisioner.go:159 +0x26
github.com/hashicorp/terraform/internal/communicator.Retry.func1()
        C:/Users/test/Desktop/terraform/internal/communicator/communicator.go:112 +0x1d8
created by github.com/hashicorp/terraform/internal/communicator.Retry
        C:/Users/test/Desktop/terraform/internal/communicator/communicator.go:95 +0x10f

Expected Behavior

The file provisioner should copy the file to the remote system during the deployment.

Actual Behavior

If the proxy is configured on the connection level, the provisioning of the file is crashing the terraform binary.
This behavior is happening both in Windows and Linux with the terraform binary compiled from clean sources (git clone && go build).

If the proxy configuration is removed from the connection block the file is copied successfully to the remote system. If the provisioner block is removed the execution finish without crashing using the proxy as intended.

Steps to Reproduce

  1. Create a basic deployment tf file for AWS:
provider "aws" {
  region = "eu-central-1"
}

resource "aws_instance" "test" {
    instance_type                       = "t2.micro"
    ami                                       = "ami-0006ba1ba3732dd33"
    key_name                             = "test"
    vpc_security_group_ids        = ["allowSSH-sg"]
    associate_public_ip_address = "true"
    availability_zone                   = "eu-central-1a"    
	
	connection {
	  host = self.public_ip
	  type = "ssh"
	  user = "ec2-user"
	  private_key = file("test")
	  timeout = "5m"
	  proxy_scheme = "http"
	  proxy_host   = "myproxy.com"
	  proxy_port   = 8000	  
	}

	# Copies the file
	provisioner "file" {
		source      = "files/test.sh"
		destination = "/tmp/test.sh"
	}
	
	provisioner "remote-exec" {
		inline = [
		  "echo finished"
		]
	}
}
  1. run terraform apply and the execution should crash during the provisioning of the file.

Originally posted by @s0rtega in #30274 (comment)

@alisdair
Copy link
Member Author

alisdair commented May 3, 2022

@s0rtega Thanks for reporting this! I've just merged a fix which will be included in the upcoming 1.2.0-rc1 release.

@s0rtega
Copy link

s0rtega commented May 4, 2022

@alisdair I can confirm that now is working as intended. Thanks for the quick fix and the work here.

@github-actions
Copy link

github-actions bot commented Jun 4, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new new issue not yet triaged provisioner/file v1.2 Issues (primarily bugs) reported against v1.2 releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants