Search in sources :

Example 1 with SecretsManagerClientBuilder

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder in project tessera by ConsenSys.

the class AWSKeyVaultServiceFactory method getAwsSecretsManager.

private SecretsManagerClient getAwsSecretsManager(KeyVaultConfig keyVaultConfig) {
    SecretsManagerClientBuilder secretsManagerClient = SecretsManagerClient.builder();
    Optional<String> endpoint = keyVaultConfig.getProperty("endpoint");
    endpoint.ifPresent(s -> {
        final URI uri;
        try {
            uri = new URI(s);
        } catch (URISyntaxException e) {
            throw new ConfigException(new RuntimeException("Invalid AWS endpoint URL provided"));
        }
        if (Objects.isNull(uri.getScheme())) {
            throw new ConfigException(new RuntimeException("Invalid AWS endpoint URL provided - no scheme"));
        }
        secretsManagerClient.endpointOverride(uri);
    });
    return secretsManagerClient.build();
}
Also used : SecretsManagerClientBuilder(software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with SecretsManagerClientBuilder

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder in project secrets-manager by bancolombia.

the class AWSSecretManagerConnector method buildClient.

private SecretsManagerClient buildClient() {
    SecretsManagerClientBuilder clientBuilder = SecretsManagerClient.builder().credentialsProvider(getProviderChain()).region(region);
    endpoint.ifPresent(clientBuilder::endpointOverride);
    return clientBuilder.build();
}
Also used : SecretsManagerClientBuilder(software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder)

Example 3 with SecretsManagerClientBuilder

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder in project secrets-manager by bancolombia.

the class AWSSecretManagerConnectorTest method prepareClient.

private void prepareClient(String data) {
    SecretsManagerClientBuilder clientBuilderMock = Mockito.mock(SecretsManagerClientBuilder.class);
    SecretsManagerClient clientMock = Mockito.mock(SecretsManagerClient.class);
    GetSecretValueResponse responseMock = GetSecretValueResponse.builder().secretString(data).build();
    PowerMockito.mockStatic(SecretsManagerClient.class);
    when(SecretsManagerClient.builder()).thenReturn(clientBuilderMock);
    when(clientBuilderMock.credentialsProvider(any())).thenReturn(clientBuilderMock);
    when(clientBuilderMock.region(any())).thenReturn(clientBuilderMock);
    when(clientBuilderMock.build()).thenReturn(clientMock);
    when(clientMock.getSecretValue(any(GetSecretValueRequest.class))).thenReturn(responseMock);
}
Also used : SecretsManagerClientBuilder(software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder) GetSecretValueRequest(software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest) GetSecretValueResponse(software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse) SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)

Aggregations

SecretsManagerClientBuilder (software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder)3 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 SecretsManagerClient (software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)1 GetSecretValueRequest (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest)1 GetSecretValueResponse (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse)1