Search in sources :

Example 11 with SecretsManagerClient

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project aws-doc-sdk-examples by awsdocs.

the class UpdateSecret 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 that is updated. \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();
    updateMySecret(secretsClient, secretName, secretValue);
    secretsClient.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)

Example 12 with SecretsManagerClient

use of software.amazon.awssdk.services.secretsmanager.SecretsManagerClient in project spring-cloud-aws by awspring.

the class SecretsManagerConfigDataLoader method load.

@Override
@Nullable
public ConfigData load(ConfigDataLoaderContext context, SecretsManagerConfigDataResource resource) {
    try {
        SecretsManagerClient sm = context.getBootstrapContext().get(SecretsManagerClient.class);
        SecretsManagerPropertySource propertySource = resource.getPropertySources().createPropertySource(resource.getContext(), resource.isOptional(), sm);
        if (propertySource != null) {
            return new ConfigData(Collections.singletonList(propertySource));
        } else {
            return null;
        }
    } catch (Exception e) {
        throw new ConfigDataResourceNotFoundException(resource, e);
    }
}
Also used : ConfigData(org.springframework.boot.context.config.ConfigData) SecretsManagerPropertySource(io.awspring.cloud.secretsmanager.SecretsManagerPropertySource) ConfigDataResourceNotFoundException(org.springframework.boot.context.config.ConfigDataResourceNotFoundException) SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient) ConfigDataResourceNotFoundException(org.springframework.boot.context.config.ConfigDataResourceNotFoundException) Nullable(org.springframework.lang.Nullable)

Example 13 with SecretsManagerClient

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

the class AWSSecretManager method updateSecret.

public static void updateSecret(String secretName, String secretValue, Region region) {
    removeBouncyCastleSecurityProvider();
    SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
    updateMySecret(secretsClient, secretName, secretValue);
    secretsClient.close();
}
Also used : SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)

Example 14 with SecretsManagerClient

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

the class AWSSecretManager method updateBinarySecret.

public static void updateBinarySecret(String secretName, SdkBytes secretValue, Region region) {
    removeBouncyCastleSecurityProvider();
    SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
    updateMyBinarySecret(secretsClient, secretName, secretValue);
    secretsClient.close();
}
Also used : SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)

Example 15 with SecretsManagerClient

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

the class AWSSecretManager method downloadPrivateKey.

public static void downloadPrivateKey(String secretName, String destFile, Region region) throws IOException {
    System.out.format("About to download private key for %s %n", secretName);
    removeBouncyCastleSecurityProvider();
    SecretsManagerClient secretsClient = SecretsManagerClient.builder().region(region).build();
    SdkBytes secret = getBinaryValue(secretsClient, secretName);
    secretsClient.close();
    uncompressData(secret, destFile);
}
Also used : SdkBytes(software.amazon.awssdk.core.SdkBytes) SecretsManagerClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient)

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