java.lang.Object
io.jooby.awssdkv2.AwsModule
- All Implemented Interfaces:
Extension
Aws module for aws-java-sdk 2.x. This module:
- Integrates AWS credentials within application properties.
- Register AWS services as application services (so they can be used by require calls or DI).
- Add graceful shutdown to any SdkAutoCloseable instance.
Usage:
{
install(
new AwsModule()
.setup(credentials -> {
var s3 = S3Client.builder().region(Region.US_EAST_1).build();
var s3transfer = S3TransferManager.builder().s3Client(s3).build()
return Stream.of(s3, s3transfer);
})
);
}
Previous example register AmazonS3Client and TransferManager services
NOTE: You need to add the service dependencies to your project.
- Since:
- 3.3.1
- Author:
- edgar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic software.amazon.awssdk.auth.credentials.AwsCredentialsProvidernewCredentialsProvider(com.typesafe.config.Config config) Creates a credentials provider, exactly likeDefaultCredentialsProvider.create()appending the application properties provider.Setup a new AWS service.
-
Constructor Details
-
AwsModule
public AwsModule(@NonNull software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider) -
AwsModule
public AwsModule()
-
-
Method Details
-
setup
@NonNull public AwsModule setup(@NonNull Function<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider, Object> provider) Setup a new AWS service. Supported outputs are:- Single amazon service - Stream of amazon services - Collection of amazon services
Each of the services returned by this function are added to the application service registry and shutdown at application shutdown time.
- Parameters:
provider- Service provider/factory.- Returns:
- AWS service.
-
install
-
newCredentialsProvider
@NonNull public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider newCredentialsProvider(@NonNull com.typesafe.config.Config config) Creates a credentials provider, exactly likeDefaultCredentialsProvider.create()appending the application properties provider.- Parameters:
config- Application properties.- Returns:
- Credentials provider.
-