Small utility module that exports AmazonWebServiceClient services.
It also give you access to aws credentials (access and secret keys).
- One ore more
AmazonWebServiceClient, likeAmazonS3Client,AmazonSimpleEmailServiceClient, etc...
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-aws</artifactId>
<version>1.0.3</version>
</dependency>application.conf:
aws.accessKey = AKIAIOSFODNN7EXAMPLE
aws.secretKey = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY{
use(new Aws()
.with(creds -> new AmazonS3Client(creds))
.with(creds -> new AmazonSimpleEmailServiceClient(creds))
);
get("/", req -> {
AmazonS3 s3 = require(AmazonS3.class);
// work with s3
});
}Keep in mind, you will need the s3 (ses, sqs,sns, etc..) jar in your classpath.
This module is small and simple. All it does is bind AmazonWebServiceClient instances in
Guice. It also helps to bind utility classes like TransferManager
{
use(new Aws()
.with(creds -> new AmazonS3Client(creds))
.doWith((AmazonS3Client s3) -> new TransferManager(s3))
);
post("/", req -> {
TransferMananger tm = require(TransferManager.class);
});
}Keys are defined in .conf file. It is possible to use global or per service keys.
aws.accessKey = AKIAIOSFODNN7EXAMPLE
aws.secretKey = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
aws.s3.accessKey = S3IOSFODNN7S3EXAMPLE
aws.s3.secretKey = s3alrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY{
use(new Aws()
.with(creds -> new AmazonS3Client(creds)) // use aws.s3 keys
.with(creds -> new AmazonSimpleEmailServiceClient(creds)) // use global keys
);
It uses the AmazonWebServiceClient#getServiceName() method in order to find per service
keys.