use of software.amazon.awssdk.services.secretsmanager.model.ResourceExistsException 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());
});
}
Aggregations