use of software.amazon.awssdk.services.ssm.model.ParameterNotFoundException in project hippo by NHS-digital-website.
the class AwsRemoteSecrets method getRemoteValue.
@Override
public String getRemoteValue(String key) {
AwsCredentialsProviderChain provider = AwsCredentialsProviderChain.of(StaticCredentialsProvider.create(AwsBasicCredentials.create(properties.getProperty("accessKey"), properties.getProperty("secretKey"))), // used by localhost
EnvironmentVariableCredentialsProvider.create());
try (SsmClient ssmClient = SsmClient.builder().credentialsProvider(provider).region(this.region).build()) {
GetParameterRequest parameterRequest = GetParameterRequest.builder().name(key).withDecryption(true).build();
GetParameterResponse parameterResponse = ssmClient.getParameter(parameterRequest);
return parameterResponse.parameter().value();
} catch (ParameterNotFoundException e) {
log.warn(format("The remote parameter '%s' was not found", key));
return null;
}
}
Aggregations