1

My java microservice (developed in Spring boot) loads S3 bucket from an application properties file. S3 bucket names for 4 different AWS regions are different (bucker-east-1, bucker-west-2 etc) hence how do I load AWS region-specific properties from application properties? For example, for us-west-2 region, bucker-us-west-2 property should be loaded, etc. is there any existing support for this type of feature in SPring boot?

obaid
  • 361
  • 3
  • 10

1 Answers1

0

There's at least a couple of ways you could handle this.

  1. Use environment variables: Using env variable in Spring Boot's application.properties

Feasibly you could structure the names to be something like bucket.name=<bucket-prefix>-${AWS_REGION}

  1. Use Spring profiles. You can create separate properties files for each region.

For example, you'd have application-us_east_1.properties, application-us_east_2.properties. You then can add the appropriate spring profile upon deployment by passing in the JVM parameter, -Dspring.profiles.active=us_east_1 to activate us_east_1. Alternatively, you can use the SPRING_PROFILES_ACTIVE environment variable similarly.