Class AwsModule

java.lang.Object
io.jooby.awssdkv2.AwsModule
All Implemented Interfaces:
Extension

public class AwsModule extends Object implements 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
    Constructor
    Description
     
    AwsModule(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    install(Jooby application)
     
    static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
    newCredentialsProvider(com.typesafe.config.Config config)
    Creates a credentials provider, exactly like DefaultCredentialsProvider.create() appending the application properties provider.
    setup(Function<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider,Object> provider)
    Setup a new AWS service.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.jooby.Extension

    lateinit
  • 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

      public void install(@NonNull Jooby application) throws Exception
      Specified by:
      install in interface Extension
      Throws:
      Exception
    • newCredentialsProvider

      @NonNull public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider newCredentialsProvider(@NonNull com.typesafe.config.Config config)
      Creates a credentials provider, exactly like DefaultCredentialsProvider.create() appending the application properties provider.
      Parameters:
      config - Application properties.
      Returns:
      Credentials provider.