Skip to content

SDA Commons Server S3

javadoc

This module provides the S3Bundle, a Dropwizard bundle that is used to perform operations on an object storage.

The bundle provides an S3 client based on the Amazon AWS SDK v2.

Usage

The S3Bundle should be added as a field in the application class instead of being anonymously added in the initialize method like other bundles of this library. Implementations need to refer to the instance to access the client.

The Dropwizard applications configuration class needs to provide a S3Configuration.

The bundle builder requires to define the getter of the S3Configuration as method reference to access the configuration.

Afterward, getClient() is used to access an instance of S3Client that is used to operate on the object storage. See S3BundleTest for a detailed usage example.

Credentials

Usually you can specify AWS credentials in the S3Configuration. But the bundle also supports AWS default credentials provider chain to retrieve credentials. Most prominently you can pass credentials via environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or via system properties aws.accessKeyId and aws.secretAccessKey.

If you want to use anonymous credentials, you can set useAnonymousCredentials to true in the S3Configuration.

Tracing

The bundle comes with OpenTelemetry instrumentation.

Health Check

The bundle supports the creation of both internal and external health checks.

1
2
3
4
5
private final S3Bundle<Config> s3Bundle =
    S3Bundle.builder()
        .withConfigurationProvider(Config::getS3Config)
        .withHealthCheck(Collections.singleton(Config::getS3Bucket))
        .build();

For creation of an external health check, use .withExternalHealthCheck(Iterable<BucketNameProvider<C>>) respectively.