in FlywayLambdaService/src/main/java/com/geekoosh/flyway/request/ValueManager.java [49:77]
public static String latestSecret(String secretName) throws ResourceNotFoundException, InvalidRequestException, InvalidParameterException {
GetSecretValueRequest getSecretValueRequest = new GetSecretValueRequest()
.withSecretId(secretName).withVersionStage("AWSCURRENT");
GetSecretValueResult getSecretValueResult = null;
try {
getSecretValueResult = getClient().getSecretValue(getSecretValueRequest);
} catch(ResourceNotFoundException e) {
logger.error("The requested secret " + secretName + " was not found", e);
throw e;
} catch (InvalidRequestException e) {
logger.error("The request was invalid due to", e);
throw e;
} catch (InvalidParameterException e) {
logger.error("The request had invalid params", e);
throw e;
}
if(getSecretValueResult == null) {
return null;
}
// Depending on whether the secret was a string or binary, one of these fields will be populated
if(getSecretValueResult.getSecretString() != null) {
return getSecretValueResult.getSecretString();
}
else {
return getSecretValueResult.getSecretBinary().toString();
}
}