use of software.amazon.awssdk.services.ssm.model.GetParameterRequest in project aws-doc-sdk-examples by awsdocs.
the class GetParameter method getParaValue.
// snippet-start:[ssm.Java2.get_para_value.main]
public static void getParaValue(SsmClient ssmClient, String paraName) {
try {
GetParameterRequest parameterRequest = GetParameterRequest.builder().name(paraName).build();
GetParameterResponse parameterResponse = ssmClient.getParameter(parameterRequest);
System.out.println("The parameter value is " + parameterResponse.parameter().value());
} catch (SsmException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.ssm.model.GetParameterRequest 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