Skip to content

Instantly share code, notes, and snippets.

@diegolirio
Created June 19, 2020 01:16
Show Gist options
  • Select an option

  • Save diegolirio/eaeb492dc9be7d1bc5b575eb5b0cbf2b to your computer and use it in GitHub Desktop.

Select an option

Save diegolirio/eaeb492dc9be7d1bc5b575eb5b0cbf2b to your computer and use it in GitHub Desktop.
@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