Created
June 19, 2020 01:16
-
-
Save diegolirio/eaeb492dc9be7d1bc5b575eb5b0cbf2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Profile("aws") | |
| @Configuration | |
| public class AWSSecretsManagerConfig { | |
| @Value("${aws.secretsManager.secretName}") | |
| private String secretName; | |
| @Value("${aws.secretsManager.region}") | |
| private String region; | |
| @Bean("awsSecretRedisAuth") | |
| public String getSecret() throws JsonProcessingException { | |
| AWSSecretsManager client = AWSSecretsManagerClientBuilder.standard() | |
| .withRegion(region) | |
| .build(); | |
| GetSecretValueRequest getSecretValueRequest = new GetSecretValueRequest().withSecretId(secretName); | |
| GetSecretValueResult getSecretValueResult = client.getSecretValue(getSecretValueRequest); | |
| String secret = getSecretValueResult.getSecretString(); | |
| RedisAuth redisAuth = new ObjectMapper().readValue(secret, RedisAuth.class); | |
| return redisAuth.getRedisAuth(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment