use of software.amazon.awssdk.services.secretsmanager.model.CreateSecretRequest 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.CreateSecretRequest 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();
}
use of software.amazon.awssdk.services.secretsmanager.model.CreateSecretRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class AWSVaultServiceImpl method createOrReplace.
@Override
public Uni<Void> createOrReplace(EventBridgeSecret secret) {
CreateSecretRequest createSecretRequest = CreateSecretRequest.builder().name(secret.getId()).secretString(Json.encode(secret.getValues())).build();
return Uni.createFrom().future(asyncClient.createSecret(createSecretRequest)).replaceWithVoid().onFailure(e -> !(e instanceof ResourceExistsException)).retry().withJitter(DEFAULT_JITTER).withBackOff(DEFAULT_BACKOFF).atMost(MAX_RETRIES).onFailure(ResourceExistsException.class).recoverWithUni(() -> replaceSecret(secret)).onFailure().transform(e -> new VaultException("Could not replace secret '%s' in AWS Vault", e)).invoke(() -> {
CACHE.put(secret.getId(), secret);
LOGGER.debug("Secret '{}' created in AWS Vault", secret.getId());
});
}
use of software.amazon.awssdk.services.secretsmanager.model.CreateSecretRequest in project web3signer by ConsenSys.
the class AwsSecretsManagerUtil method createSecret.
public String createSecret(String secretValue) {
secretName = "signers-aws-integration/" + UUID.randomUUID();
final CreateSecretRequest secretRequest = CreateSecretRequest.builder().name(secretName).secretString(secretValue).build();
secretsManagerClient.createSecret(secretRequest);
return secretName;
}
Aggregations