use of software.amazon.awssdk.services.secretsmanager.model.CreateSecretResponse in project aws-doc-sdk-examples by awsdocs.
the class CreateSecret method createNewSecret.
// snippet-start:[secretsmanager.java2.create_secret.main]
public static String createNewSecret(SecretsManagerClient secretsClient, String secretName, String secretValue) {
try {
CreateSecretRequest secretRequest = CreateSecretRequest.builder().name(secretName).description("This secret was created by the AWS Secret Manager Java API").secretString(secretValue).build();
CreateSecretResponse secretResponse = secretsClient.createSecret(secretRequest);
return secretResponse.arn();
} catch (SecretsManagerException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return "";
}
use of software.amazon.awssdk.services.secretsmanager.model.CreateSecretResponse in project radixdlt by radixdlt.
the class AWSSecretManager method createNewSecret.
private static String createNewSecret(SecretsManagerClient secretsClient, String secretName, Object secretValue, String network, boolean binarySecret) {
List<Tag> tagList = buildTags(network, secretName);
CreateSecretRequest secretRequest;
if (binarySecret) {
secretRequest = CreateSecretRequest.builder().name(secretName).description("Validator keys").secretBinary((SdkBytes) secretValue).tags(tagList).build();
} else {
secretRequest = CreateSecretRequest.builder().name(secretName).description("Validator keys").secretString((String) secretValue).tags(tagList).build();
}
CreateSecretResponse secretResponse = secretsClient.createSecret(secretRequest);
return secretResponse.arn();
}
Aggregations