public class LocalStackContainer
extends org.junit.rules.ExternalResource
Container for Atlassian Labs Localstack, 'A fully functional local AWS cloud stack'.
withServices(Service...)
should be used to select which services
are to be launched. See LocalStackContainer.Service
for available choices. It is advised that
getEndpointConfiguration(Service)
and
getDefaultCredentialsProvider()
be used to obtain compatible endpoint configuration and credentials, respectively.
Modifier and Type | Class and Description |
---|---|
static class |
LocalStackContainer.Service |
Constructor and Description |
---|
LocalStackContainer() |
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
before() |
com.amazonaws.auth.AWSCredentialsProvider |
getDefaultCredentialsProvider()
Provides a
AWSCredentialsProvider that is preconfigured to communicate with a given simulated service. |
com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration |
getEndpointConfiguration(LocalStackContainer.Service service)
Provides an endpoint configuration that is preconfigured to communicate with a given simulated service.
|
LocalStackContainer |
withServices(LocalStackContainer.Service... services)
Declare a set of simulated AWS services that should be launched by this container.
|
protected void before() throws java.lang.Throwable
before
in class org.junit.rules.ExternalResource
java.lang.Throwable
protected void after()
after
in class org.junit.rules.ExternalResource
public LocalStackContainer withServices(LocalStackContainer.Service... services)
services
- one or more service namespublic com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration getEndpointConfiguration(LocalStackContainer.Service service)
AmazonS3 s3 = AmazonS3ClientBuilder
.standard()
.withEndpointConfiguration(localstack.getEndpointConfiguration(S3))
.withCredentials(localstack.getDefaultCredentialsProvider())
.build();
service
- the service that is to be accessedAwsClientBuilder.EndpointConfiguration
public com.amazonaws.auth.AWSCredentialsProvider getDefaultCredentialsProvider()
AWSCredentialsProvider
that is preconfigured to communicate with a given simulated service.
The credentials provider should be set in the AWS Java SDK when building a client, e.g.:
AmazonS3 s3 = AmazonS3ClientBuilder
.standard()
.withEndpointConfiguration(localstack.getEndpointConfiguration(S3))
.withCredentials(localstack.getDefaultCredentialsProvider())
.build();
AWSCredentialsProvider