LocalStack Module
Testcontainers module for LocalStack, 'a fully functional local AWS cloud stack', to develop and test your cloud and serverless apps without actually using the cloud.
Usage example
You can start a LocalStack container instance from any Java application by using:
LocalStackContainer localstack = new LocalStackContainer(LocalstackTestImages.LOCALSTACK_IMAGE)
.withServices("s3")
Creating a client using AWS SDK
S3Client s3 = S3Client
.builder()
.endpointOverride(localstack.getEndpoint())
.credentialsProvider(
StaticCredentialsProvider.create(
AwsBasicCredentials.create(localstack.getAccessKey(), localstack.getSecretKey())
)
)
.region(Region.of(localstack.getRegion()))
.build();
Environment variables listed in Localstack's README may be used to customize Localstack's configuration.
Use the .withEnv(key, value) method on LocalStackContainer to apply configuration settings.
Adding this module to your project dependencies
Add the following dependency to your pom.xml/build.gradle file:
testImplementation "org.testcontainers:testcontainers-localstack:2.0.1"
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-localstack</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>