use of software.amazon.awssdk.services.secretsmanager.model.SecretsManagerException in project cu-kfs by CU-CommunityApps.
the class AwsSecretServiceImpl method updateSecretValue.
@Override
public void updateSecretValue(String awsKeyName, boolean useKfsInstanceNamespace, String keyValue) {
createCacheIfNotPresent();
String fullAwsKey = buildFullAwsKeyName(awsKeyName, useKfsInstanceNamespace);
UpdateSecretRequest updateSecretRequest = UpdateSecretRequest.builder().secretId(fullAwsKey).secretString(keyValue).build();
SecretsManagerClient client = buildSecretsManagerClient();
try {
performUpdate(updateSecretRequest, client);
updateCacheValue(fullAwsKey, keyValue);
} catch (SecretsManagerException e) {
LOG.error("updateSecretValue, had an error setting value for secret " + fullAwsKey, e);
throw new RuntimeException(e);
} finally {
client.close();
}
}
use of software.amazon.awssdk.services.secretsmanager.model.SecretsManagerException in project cu-kfs by CU-CommunityApps.
the class AwsSecretServiceImpl method retrieveSecretFromAws.
protected String retrieveSecretFromAws(String fullAwsKey) {
SecretsManagerClient client = buildSecretsManagerClient();
try {
GetSecretValueRequest valueRequest = GetSecretValueRequest.builder().secretId(fullAwsKey).build();
GetSecretValueResponse valueResponse = client.getSecretValue(valueRequest);
return valueResponse.secretString();
} catch (SecretsManagerException e) {
LOG.error("retrieveSecretFromAws, had an error getting value for secret " + fullAwsKey, e);
throw new RuntimeException(e);
} finally {
client.close();
}
}
use of software.amazon.awssdk.services.secretsmanager.model.SecretsManagerException in project radixdlt by radixdlt.
the class AWSSecretManager method createAWSSecret.
public static void createAWSSecret(final Map<String, Object> awsSecret, final String secretName, final AWSSecretsOutputOptions awsSecretsOutputOptions, boolean compress, boolean binarySecret) {
ObjectMapper objectMapper = new ObjectMapper();
try {
String jsonSecret = objectMapper.writeValueAsString(awsSecret);
if (compress) {
byte[] compressedBytes = compressData(jsonSecret);
createBinarySecret(secretName, SdkBytes.fromByteArray(compressedBytes), awsSecretsOutputOptions.getNetworkName());
} else {
if (binarySecret) {
createBinarySecret(secretName, SdkBytes.fromByteArray((byte[]) awsSecret.get("key")), awsSecretsOutputOptions.getNetworkName());
} else {
createSecret(secretName, jsonSecret, awsSecretsOutputOptions.getNetworkName());
}
}
} catch (JsonProcessingException e) {
System.out.println(e);
} catch (SecretsManagerException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
} catch (IOException e) {
System.out.println(e);
System.exit(1);
}
}
use of software.amazon.awssdk.services.secretsmanager.model.SecretsManagerException in project aws-doc-sdk-examples by awsdocs.
the class DeleteSecret method deleteSpecificSecret.
// snippet-start:[secretsmanager.java2.delete_secret.main]
public static void deleteSpecificSecret(SecretsManagerClient secretsClient, String secretName) {
try {
DeleteSecretRequest secretRequest = DeleteSecretRequest.builder().secretId(secretName).build();
secretsClient.deleteSecret(secretRequest);
System.out.println(secretName + " is deleted.");
} catch (SecretsManagerException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.secretsmanager.model.SecretsManagerException in project aws-doc-sdk-examples by awsdocs.
the class ListSecrets method listAllSecrets.
// snippet-start:[secretsmanager.java2.list_secrets.main]
public static void listAllSecrets(SecretsManagerClient secretsClient) {
try {
ListSecretsResponse secretsResponse = secretsClient.listSecrets();
List<SecretListEntry> secrets = secretsResponse.secretList();
for (SecretListEntry secret : secrets) {
System.out.println("The secret name is " + secret.name());
System.out.println("The secret descreiption is " + secret.description());
}
} catch (SecretsManagerException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations