use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project aws-doc-sdk-examples by awsdocs.
the class CreateSecret method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <secretName> <secretValue> \n\n" + "Where:\n" + " secretName - the name of the secret (for example, tutorials/MyFirstSecret). \n" + " secretValue - the secret value. \n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String secretName = args[0];
String secretValue = args[1];
Region region = Region.US_EAST_1;
SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
String secretARN = createNewSecret(secretsClient, secretName, secretValue);
System.out.println("The secret ARN is " + secretARN);
secretsClient.close();
}
use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project aws-doc-sdk-examples by awsdocs.
the class ListSecrets method main.
public static void main(String[] args) {
Region region = Region.US_EAST_1;
SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
listAllSecrets(secretsClient);
secretsClient.close();
}
use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project aws-doc-sdk-examples by awsdocs.
the class DeleteSecret method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <secretName> \n\n" + "Where:\n" + " secretName - the name of the secret (for example, tutorials/MyFirstSecret). \n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String secretName = args[0];
Region region = Region.US_EAST_1;
SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
deleteSpecificSecret(secretsClient, secretName);
secretsClient.close();
}
use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project aws-doc-sdk-examples by awsdocs.
the class GetSecretValue method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <secretName> \n\n" + "Where:\n" + " secretName - the name of the secret (for example, tutorials/MyFirstSecret). \n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String secretName = args[0];
Region region = Region.US_EAST_1;
SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
getValue(secretsClient, secretName);
secretsClient.close();
}
use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project spring-cloud-aws by awspring.
the class SecretsManagerConfigDataLoaderIntegrationTests method secretsManagerClientCanBeOverwrittenInBootstrapConfig.
@Test
void secretsManagerClientCanBeOverwrittenInBootstrapConfig() {
SecretsManagerClient mockClient = mock(SecretsManagerClient.class);
when(mockClient.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(GetSecretValueResponse.builder().name("secrets").secretString("{\"message\":\"value from mock\"}").build());
SpringApplication application = new SpringApplication(App.class);
application.setWebApplicationType(WebApplicationType.NONE);
application.addBootstrapRegistryInitializer(registry -> {
registry.register(SecretsManagerClient.class, ctx -> mockClient);
});
try (ConfigurableApplicationContext context = runApplication(application, "aws-secretsmanager:/config/spring")) {
SecretsManagerClient clientFromContext = context.getBean(SecretsManagerClient.class);
assertThat(clientFromContext).isEqualTo(mockClient);
assertThat(context.getEnvironment().getProperty("message")).isEqualTo("value from mock");
}
}
Aggregations