in src/main/java/com/aws/logaggregator/security/AWSSecretManagerParam.java [56:93]
private String getSecrets(String secretName, String region, String key) {
Map<String, String> secretsMap = null;
String secret;
AWSSecretsManager client = AWSSecretsManagerClientBuilder.standard()
.withRegion(region)
.build();
GetSecretValueRequest getSecretValueRequest = new GetSecretValueRequest()
.withSecretId(secretName);
GetSecretValueResult getSecretValueResult = null;
try {
getSecretValueResult = client.getSecretValue(getSecretValueRequest);
if (getSecretValueResult.getSecretString() != null) {
secret = getSecretValueResult.getSecretString();
} else {
secret = new String(Base64.getDecoder().decode(getSecretValueResult.getSecretBinary()).array());
}
ObjectMapper mapper = new ObjectMapper();
secretsMap = mapper.readValue(secret, Map.class);
} catch (DecryptionFailureException | InternalServiceErrorException | InvalidParameterException | InvalidRequestException | ResourceNotFoundException e) {
logger.error("exception thron from secret manager", e);
throw e;
} catch (JsonParseException | JsonMappingException e) {
logger.error("exception thron from secret manager", e);
} catch (IOException e) {
logger.error("exception thron from secret manager", e);
} catch (Exception e) {
logger.error("exception thron from secret manager", e);
}
return secretsMap.get(key);
}