use of software.amazon.awssdk.services.secretsmanager.model.InvalidRequestException in project tessera by ConsenSys.
the class AWSKeyVaultService method getSecret.
@Override
public String getSecret(Map<String, String> getSecretData) {
final String secretName = getSecretData.get(SECRET_NAME_KEY);
GetSecretValueRequest getSecretValueRequest = GetSecretValueRequest.builder().secretId(secretName).build();
GetSecretValueResponse secretValueResponse;
try {
secretValueResponse = secretsManager.getSecretValue(getSecretValueRequest);
} catch (ResourceNotFoundException e) {
throw new VaultSecretNotFoundException("The requested secret '" + secretName + "' was not found in AWS Secrets Manager");
} catch (InvalidRequestException | InvalidParameterException e) {
throw new AWSSecretsManagerException(e);
}
if (secretValueResponse != null && secretValueResponse.secretString() != null) {
return secretValueResponse.secretString();
}
throw new VaultSecretNotFoundException("The requested secret '" + secretName + "' was not found in AWS Secrets Manager");
}
Aggregations