Class AwsModule

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

public class AwsModule extends Object implements io.jooby.Extension
Aws module for aws-java-sdk 1.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 AWS services.

Usage:


 {
     install(
         new AwsModule()
             .setup(credentials -> {
               return TransferManagerBuilder.standard()
                   .withS3Client(
                       AmazonS3ClientBuilder.standard()
                           .withRegion(Regions.US_EAST_1)
                           .withCredentials(credentials)
                           .build()
                   ).build();
             })
     );
 }
 

Previous example register AmazonS3Client and TransferManager services

NOTE: You need to add the required service dependency to your project.

Author:
edgar
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    install(io.jooby.Jooby application)
     
    static com.amazonaws.auth.AWSCredentialsProvider
    newCredentialsProvider(com.typesafe.config.Config config)
    Creates a credentials provider, exactly like DefaultAWSCredentialsProviderChain appending the application properties provider.
    setup(Function<com.amazonaws.auth.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()
  • Method Details

    • setup

      @NonNull public AwsModule setup(@NonNull Function<com.amazonaws.auth.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 io.jooby.Jooby application) throws Exception
      Specified by:
      install in interface io.jooby.Extension
      Throws:
      Exception
    • newCredentialsProvider

      @NonNull public static com.amazonaws.auth.AWSCredentialsProvider newCredentialsProvider(@NonNull com.typesafe.config.Config config)
      Creates a credentials provider, exactly like DefaultAWSCredentialsProviderChain appending the application properties provider.
      Parameters:
      config - Application properties.
      Returns:
      Credentials provider.