Search in sources :

Example 1 with UpdateSecretRequest

use of com.amazonaws.services.secretsmanager.model.UpdateSecretRequest in project datarouter by hotpads.

the class AwsSecretClient method update.

@Override
public final void update(Secret secret) {
    // this can update various stuff (like description and kms key) AND updates the version stage to AWSCURRENT.
    // for rotation, use PutSecretValue, which only updates the version stages and value of a secret explicitly
    var request = new UpdateSecretRequest().withSecretId(secret.getName()).withSecretString(secret.getValue());
    try {
        try (var $ = TracerTool.startSpan("AWSSecretsManager updateSecret", TraceSpanGroupType.CLOUD_STORAGE)) {
            TracerTool.appendToSpanInfo(secret.getName());
            client.updateSecret(request);
        }
    } catch (ResourceExistsException e) {
        throw new SecretExistsException("Requested update already exists.", secret.getName(), e);
    } catch (ResourceNotFoundException e) {
        throw new SecretNotFoundException(secret.getName(), e);
    }
}
Also used : ResourceExistsException(com.amazonaws.services.secretsmanager.model.ResourceExistsException) ResourceNotFoundException(com.amazonaws.services.secretsmanager.model.ResourceNotFoundException) SecretNotFoundException(io.datarouter.secret.exception.SecretNotFoundException) SecretExistsException(io.datarouter.secret.exception.SecretExistsException) UpdateSecretRequest(com.amazonaws.services.secretsmanager.model.UpdateSecretRequest)

Aggregations

ResourceExistsException (com.amazonaws.services.secretsmanager.model.ResourceExistsException)1 ResourceNotFoundException (com.amazonaws.services.secretsmanager.model.ResourceNotFoundException)1 UpdateSecretRequest (com.amazonaws.services.secretsmanager.model.UpdateSecretRequest)1 SecretExistsException (io.datarouter.secret.exception.SecretExistsException)1 SecretNotFoundException (io.datarouter.secret.exception.SecretNotFoundException)1