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

Allow using LocalStackContainer with AWS SDK v2 #1442 #2579

Merged
merged 5 commits into from Apr 23, 2020

Conversation

musketyr
Copy link
Contributor

This PR exposes the generated URI from the getEndpointConfiguration(Service) method
so it can be used by AWS SDK v2 methods.

It also exposes the default access key, secret key and region which is also required by the clients.

AWS SDK v2 users will be able to use the container without additional changes as follows:

S3Client s3 = S3Client
             .builder()
             .endpointOverride(localstack.getEndpointOverride(LocalStackContainer.Service.S3))
             .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(
                localstack.getDefaultAccessKey(), localstack.getDefaultSecretKey()
             )))
             .region(Region.of(localstack.getDefaultRegion()))
             .build()

@musketyr musketyr requested a review from bsideup April 16, 2020 08:28
@bsideup bsideup added this to the next milestone Apr 16, 2020
@bsideup
Copy link
Member

bsideup commented Apr 16, 2020

@musketyr do you know if AWS SDK 1 and 2 can co-exist on the same classpath?
If so, could you please add a test (and maybe use it to add "Usage example with AWS SDK 2" docs section via the code include block)?

@musketyr
Copy link
Contributor Author

@bsideup test and docs added. I've kept the copy-pasted as it was before. see ba3a73c

final software.amazon.awssdk.services.s3.model.Bucket bucket = buckets.get(0);

assertEquals("The created bucket has the right name", "foo", bucket.name());
assertEquals("The created bucket has the right name", "foo", bucket.name());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertEquals("The created bucket has the right name", "foo", bucket.name());
assertEquals("The created bucket has the right name", "foo", bucket.name());

duplicate

@@ -85,6 +92,34 @@ public void s3TestOverBridgeNetwork() throws IOException {
assertEquals("The object can be retrieved", "baz", content);
}

@Test
public void s3TestOverBridgeNetworkV2() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I think test's name is a bit too specific
  2. could you please reduce the test to the minimum, so that it only tests that SDK v2 works fine?

@musketyr musketyr requested a review from bsideup April 23, 2020 07:01
@rnorth
Copy link
Member

rnorth commented Apr 23, 2020

LGTM - will merge. Thanks for the contribution @musketyr!

@rnorth rnorth changed the title Minimal changes to allow using LocalStackContainer with AWS SDK v2 #1442 Allow using LocalStackContainer with AWS SDK v2 #1442 Apr 23, 2020
@rnorth rnorth merged commit 12de2b4 into testcontainers:master Apr 23, 2020
quincy pushed a commit to quincy/testcontainers-java that referenced this pull request May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants