Search in sources :

Example 1 with ParameterNotFoundException

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;
    }
}
Also used : GetParameterRequest(software.amazon.awssdk.services.ssm.model.GetParameterRequest) GetParameterResponse(software.amazon.awssdk.services.ssm.model.GetParameterResponse) ParameterNotFoundException(software.amazon.awssdk.services.ssm.model.ParameterNotFoundException) SsmClient(software.amazon.awssdk.services.ssm.SsmClient)

Aggregations

SsmClient (software.amazon.awssdk.services.ssm.SsmClient)1 GetParameterRequest (software.amazon.awssdk.services.ssm.model.GetParameterRequest)1 GetParameterResponse (software.amazon.awssdk.services.ssm.model.GetParameterResponse)1 ParameterNotFoundException (software.amazon.awssdk.services.ssm.model.ParameterNotFoundException)1