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

[Enhancement] LocalstackContainer API enhancement #701

Closed
lbroudoux opened this issue Jan 3, 2024 · 4 comments
Closed

[Enhancement] LocalstackContainer API enhancement #701

lbroudoux opened this issue Jan 3, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@lbroudoux
Copy link

Hello,

Thanks for the great work out there!

I've used the recently released LocalstackContainer in the Microcks.io testcontainers module and it works like a charm. However, as a user of the Java version, I found the module API less easy to use if you're not an experienced user and know the internals of Localstack.

Typically, the below functions/methods are very convenient in the Java version:

  • withServices() method to select AWS services,
  • getRegion() method to get the default Localstack region,
  • getAccessKey() / getSecretKey() method to get the default credentials,
  • getEndpointOverride(service) to get the service-specific endpoint URL.

It would be awesome to have a similar interface with those methods in the Node/Typescript world!
What do you think?

@cristianrgreco
Copy link
Collaborator

Hi @lbroudoux, thanks for the kind words, and yes sounds great to me!

@cristianrgreco cristianrgreco added the enhancement New feature or request label Jan 3, 2024
@lbroudoux
Copy link
Author

Hi! I reviewed the code this morning to see if I can submit a PR.

If my understanding is ok, it looks like we're missing a way to retrieve env vars from a StartedTestContainer. GenericContainer.createOpts.Env is not transferred to the started container, and inspectResult is not directly usable.

I think we'd need to add a public getEnvironment(): Record<string, string> method to the StartedTestContainer interface so that we'll be able to retrieve region, access key and secret key - for this localstack use-case. I've made the addition, and it works well.

As this change is not local to localstack use-case, would you like to have a specific issue + PR on this?

@lbroudoux
Copy link
Author

Reading the Localstack doc thoroughly, I can see that setting the list of services is no longer required, as services are now all available on the same exposed port. So you don't need to replicate the withServices() and getEndpointOverride(service) methods!

lbroudoux added a commit to lbroudoux/testcontainers-node that referenced this issue Jan 5, 2024
…- Add environment variables retrieval after container startup

Signed-off-by: Laurent Broudoux <[email protected]>
@eddumelendez
Copy link
Member

my 2 cents here, withServices() is not really needed because the SERVICES env var can be used directly. SERVICES env var was required until LocalStack 0.13, after that services are lazy loaded. Same with getEndpointOverride(service), until LocalStack 0.11 returns a endpoint with different port by service but that's not the case anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants