question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set HOSTNAME_EXTERNAL env variable for localstack test container

See original GitHub issue

Right now localstack container does not override hostname property that leads to issues with aws responses that contains url. All works when container could be reached by localhost (127.0.0.1) but fails when running in docker env with another IP address resolved.

val sqsEndpoint = localstack.getEndpointConfiguration(SQS)
val sqsClient = AmazonSQSAsyncClient.asyncBuilder().withEndpointConfiguration(sqsEndpoint)
                .withCredentials(localstack.defaultCredentialsProvider).build()
val queueUrl = sqsClient.createQueue("aQueue").queueUrl

println(sqsEndpoint.serviceEndpoint)
println(queueUrl)

This would print something like

http://127.0.0.1.nip.io:33161
http://localhost:33161/queue/aQueue

As you can see if service endpoint would be resolved to another IP it would break

Current workaround - extract host/port from serviceEndpoint info and use it in queueUrl, but as localstack can be configured to adjust host, I believe it could be done on testcontainers side

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
clslrnscommented, Jun 20, 2019

I believe the fix by @CauchyPeano should be merged. Spent half of the day trying to figure out whats wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - LocalStack Docs
Environment variables which affect LocalStack. ... Needs to be set to the network the LocalStack container is connected to if not default bridge...
Read more >
localstack trying to connect to localhost:4566 when we ...
It is known issue. You need to add in docker-compose lockalstack image next properties. HOSTNAME_EXTERNAL. hostname: localstack.
Read more >
LocalStack Module - Testcontainers for Java
Testcontainers will inform Localstack of the best hostname automatically, using the HOSTNAME_EXTERNAL environment variable: when running the Localstack ...
Read more >
Up and Running with LocalStack and Docker Compose
LocalStack is a “fully functional local AWS cloud stack” which lets ... and set an HOSTNAME_EXTERNAL environment variable if you need to:.
Read more >
Dockercompose: How To Access Localstack Resources Both ...
LocalStack provides an easytouse test/mocking framework for developing Cloud ... In this dockercompose.yml we set the environment variable SERVICES to the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found