Skip to content

Solved: Issue found in end-to-end-testing golang error: dial tcp: lookup "<ip>": no such host #215

Open
@heriberto-mb

Description

Is there an existing issue for this?

  • I have searched the existing issues

Example Name

https://github.com/Azure/terraform/blob/master/samples/end-to-end-testing/src/test/end2end_test.go#L78

Terraform Version

1.3.8

Current Behavior

@jcorioland
There is an issue when the code generates the connection to the public ip.
In the following line, it tries to connect to the public ip address:

https://github.com/Azure/terraform/blob/master/samples/end-to-end-testing/src/test/end2end_test.go#L78

After several days of troubleshooting the code, I found that it fails because the variable not only contains the ip address, but it also includes double quotes around the ip address, this makes it fail.

Expected Behavior

Finally fixed it by using the following change:

//sshConnection, err := ssh.Dial("tcp", fmt.Sprintf("%s:22", vmLinux1PublicIPAddress), sshConfig)
sshConnection, err := ssh.Dial("tcp", fmt.Sprintf("%s:22", strings.Trim(vmLinux1PublicIPAddress, "\"")), sshConfig)

Once that adjustment was done, the code worked!

Steps To Reproduce

cd /c/git/terraform/samples/end-to-end-testing/src/test
az login --use-device-code
az account set --subscription Playground
cd ~/.ssh
ssh-keygen.exe #This is in test, not definitive yet: -m PEM
make sure id_rsa and id_rsa.pub were created
ls -l /.ssh/id_rsa*
export TEST_SSH_KEY_PATH="
/.ssh/id_rsa"
cd /c/git/terraform/samples/end-to-end-testing/src/test
go mod download github.com/gruntwork-io/terratest
go mod download github.com/Azure/go-autorest/autorest
go mod tidy -e
go test -v ./ -timeout 10m

Anything else?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexample

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions