Closed PB1899 closed 1 year ago
HTTP GET to URL http://"hello-world-example-64083979.eu-west-2.elb.amazonaws.com" returned an error: Get "http://"hello-world-example-64083979.eu-west-2.elb.amazonaws.com"": dial tcp: lookup "hello-world-example-64083979.eu-west-2.elb.amazonaws.com": no such host. Sleeping for 10s and will try again.
Those double quotes look wrong. What version of Terraform and Terratest are you using?
Hi, I pinned the Terratest version to v0.15.9 as per the book and Terraform is 0.14.9.
Terraform is 0.14.9.
That's the problem. As is written in every README (example) and mentioned multiple times in the book, the code samples in the book were tested with Terraform 0.12. Each new version of Terraform introduces backwards incompatible changes; for example, 0.14 changed the format of the terraform output
command, which is why you're seeing double quotes in weird places, and the test is not working.
In the future, I'll update all the examples to the latest version of Terraform: hopefully, when 1.0 comes out, and they begin to maintain backwards compatibility. But for now, if you want to run the examples as-is, you'll need to use Terraform 0.12.
To make the code work with Terraform v1.05 I had to add the strings
package and change the url
variable like so:
url := fmt.Sprintf("http://%s", strings.Trim(albDnsName, "\""))
That get's rid of the double quotes
url := fmt.Sprintf("http://%s", strings.Trim(albDnsName, "\""))
Thank you.
when creating the example of hello world app, if manually executing
terraform apply
, and then accessing the DNS of the ELB, the output is as expected:Hello, World
DB address: mock-mysql-address
DB port: 12345
however, if executing the unit test from the go/src/ directory, the test fails:
--- FAIL: TestHelloWorldAppExample (367.96s) FAIL exit status 1 FAIL terraform-up-and-running 367.966s
in the test outputs I can see the following: HTTP GET to URL http://"hello-world-example-64083979.eu-west-2.elb.amazonaws.com" returned an error: Get "http://\"hello-world-example-64083979.eu-west-2.elb.amazonaws.com\"": dial tcp: lookup "hello-world-example-64083979.eu-west-2.elb.amazonaws.com": no such host. Sleeping for 10s and will try again.
I have tried setting the time between retries to 30 sec but stil the same result.