Search in sources :

Example 16 with SecretsManagerClient

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project radixdlt by radixdlt.

the class AWSSecretManager method getSecret.

public static String getSecret(String secretName, Region region) {
    removeBouncyCastleSecurityProvider();
    SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
    String secret = getValue(secretsClient, secretName);
    secretsClient.close();
    return secret;
}
Also used : SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)

Example 17 with SecretsManagerClient

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient 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)

Example 18 with SecretsManagerClient

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project signers by ConsenSys.

the class AwsSecretsManager method createAwsSecretsManager.

static AwsSecretsManager createAwsSecretsManager(final String accessKeyId, final String secretAccessKey, final String region) {
    final AwsBasicCredentials awsBasicCredentials = AwsBasicCredentials.create(accessKeyId, secretAccessKey);
    final StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(awsBasicCredentials);
    final SecretsManagerClient secretsManagerClient = SecretsManagerClient.builder().credentialsProvider(credentialsProvider).region(Region.of(region)).build();
    return new AwsSecretsManager(secretsManagerClient);
}
Also used : StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials)

Aggregations

SecretsManagerClient (software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)18 Region (software.amazon.awssdk.regions.Region)7 GetSecretValueRequest (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest)3 GetSecretValueResponse (software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse)2 SecretsManagerException (software.amazon.awssdk.services.secretsmanager.model.SecretsManagerException)2 SecretsManagerPropertySource (io.awspring.cloud.secretsmanager.SecretsManagerPropertySource)1 Test (org.junit.jupiter.api.Test)1 SpringApplication (org.springframework.boot.SpringApplication)1 ConfigData (org.springframework.boot.context.config.ConfigData)1 ConfigDataResourceNotFoundException (org.springframework.boot.context.config.ConfigDataResourceNotFoundException)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 Nullable (org.springframework.lang.Nullable)1 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)1 StaticCredentialsProvider (software.amazon.awssdk.auth.credentials.StaticCredentialsProvider)1 SdkBytes (software.amazon.awssdk.core.SdkBytes)1 SecretsManagerClientBuilder (software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder)1 UpdateSecretRequest (software.amazon.awssdk.services.secretsmanager.model.UpdateSecretRequest)1