use of com.amazonaws.services.secretsmanager.model.CreateSecretRequest in project datarouter by hotpads.
the class AwsSecretClient method create.
@Override
public final void create(Secret secret) {
var request = new CreateSecretRequest().withName(secret.getName()).withSecretString(secret.getValue());
try {
try (var $ = TracerTool.startSpan("AWSSecretsManager createSecret", TraceSpanGroupType.CLOUD_STORAGE)) {
TracerTool.appendToSpanInfo(secret.getName());
client.createSecret(request);
}
} catch (ResourceExistsException e) {
throw new SecretExistsException(secret.getName(), e);
}
}
use of com.amazonaws.services.secretsmanager.model.CreateSecretRequest in project JAQU-CAZ-Payments-API by InformedSolutions.
the class SecretsManagerInitialisation method createSecret.
@SneakyThrows
public void createSecret(String secretName, String apiKey, String... cleanAirZoneId) {
Map<String, String> apiKeysMap = Arrays.asList(cleanAirZoneId).stream().map(cazId -> cazId.replace("-", "")).collect(Collectors.toMap(Function.identity(), string -> apiKey));
String secretString = objectMapper.writeValueAsString(apiKeysMap);
try {
CreateSecretRequest createSecretRequest = new CreateSecretRequest().withName(secretName).withSecretString(secretString);
secretsManager.createSecret(createSecretRequest);
} catch (ResourceExistsException e) {
PutSecretValueRequest putSecretValueRequest = new PutSecretValueRequest();
putSecretValueRequest.withSecretId(secretName).withSecretString(secretString);
secretsManager.putSecretValue(putSecretValueRequest);
}
}
Aggregations