Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate AWS Secret Manager with Spring Boot Application

I have a requirement to retrieve credentials from AWS Secret Manager, and I found that I need to add the gradle dependency for the following starter

spring-cloud-starter-aws-secrets-manager-config

Also, i found that I need to add the following settings in Bootstrap.yml

Property Configurations

I'm unclear how secret key could be accessed in my Spring Boot Application if someone could chime in much appreciated.

like image 213
pubudut Avatar asked May 17 '19 23:05

pubudut


2 Answers

If you are using springboot 2.4+ the bootstrap method has been deprecated. The new way of integrate aws secret manager is this:

  1. Add the following dependency to your app:

     <dependency>
         <groupId>io.awspring.cloud</groupId>
         <artifactId>spring-cloud-starter-aws-secrets-manager-config</artifactId>
         <version>${version}</version>
     </dependency>
    
  2. Add the following configuration:

    spring.config.import: aws-secretsmanager:<your secret name in aws>

That's it!

like image 182
Doraemoe Avatar answered Oct 06 '22 09:10

Doraemoe


The answer above maybe wrong. The configuration store in secret manager should be: key: /secret/application value: {"username":"test"}

like image 42
chuang chen Avatar answered Oct 06 '22 07:10

chuang chen