Build Status

Spring S3 Property Loader

S3 Property Loader has the aim of allowing loading of Spring property files from S3 bucket, in order to guarantee stateless machine configuration.

Spring PropertyConfigurer uses PropertiesFactoryBean to load property files from AWS S3 bucket.

Install

Gradle:

repositories {  
   jcenter()  
}
compile "com.spring.loader:s3-loader:2.2.2"

Maven:

<dependency>
  <groupId>com.spring.loader</groupId>
  <artifactId>s3-loader</artifactId>
  <version>2.2.2</version>
  <type>pom</type>
</dependency>

How to use

Refreshing properties in runtime

You can force your application to load properties from S3 again without restart. S3 Properties Loader uses a Spring Cloud feature that allows the spring beans annotated with @RefreshScope to reload properties. To work, it is only necessary to inject the S3PropertiesContext bean and call refresh() method. After this, S3 Properties Loader will get properties again from s3 bucket defined previously and refresh your beans annotated with @RefreshScope.

tip: You can create a endpoint that calls this class and refresh your application via endpoint or create a @Scheduled class which updates from time to time.

Example:

@RestController
public SomeController {

   @Autowired
   private S3PropertiesContext s3PropertiesContext;
    
   @PostMapping("/refresh-properties")
   public void refresh() {
       s3PropertiesContext.refresh();
   }
}

Requisites

Official spring aws sdk lib.

Problems and Issues

Found some bug? Have some enhancement ? Open a Issue here