From c4c63a3040be99ffd75d789d3ee0f64e092c1cb0 Mon Sep 17 00:00:00 2001 From: srh50 Date: Sat, 17 Apr 2021 03:40:35 -0400 Subject: [PATCH] Use AwsCredentialsProvider and AwsRegionProvider interfaces for bean declaration instead of their Chain classes --- .../aws/sdk/v2/CredentialsAndRegionFactory.java | 8 ++++---- .../aws/sdk/v2/service/AwsClientFactory.java | 10 +++++----- .../v2/service/dynamodb/DynamoDbClientFactory.java | 6 +++--- .../aws/sdk/v2/service/s3/S3ClientFactory.java | 6 +++--- .../secretsmanager/SecretsManagerClientFactory.java | 6 +++--- .../aws/sdk/v2/service/ses/SesClientFactory.java | 6 +++--- .../aws/sdk/v2/service/sns/SnsClientFactory.java | 6 +++--- .../aws/sdk/v2/service/sqs/SqsClientFactory.java | 6 +++--- .../aws/sdk/v2/service/ssm/SsmClientFactory.java | 6 +++--- .../v2/EnvironmentAwsCredentialsProviderSpec.groovy | 12 ++++++------ .../aws/sdk/v2/RekognitionClientFactory.java | 6 +++--- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/CredentialsAndRegionFactory.java b/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/CredentialsAndRegionFactory.java index 2a6cac9242..a8f9f711ff 100644 --- a/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/CredentialsAndRegionFactory.java +++ b/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/CredentialsAndRegionFactory.java @@ -15,12 +15,13 @@ */ package io.micronaut.aws.sdk.v2; -import io.micronaut.context.annotation.Bean; import io.micronaut.context.annotation.BootstrapContextCompatible; import io.micronaut.context.annotation.Factory; import io.micronaut.context.env.Environment; +import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; import software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain; import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; +import software.amazon.awssdk.regions.providers.AwsRegionProvider; import software.amazon.awssdk.regions.providers.AwsRegionProviderChain; import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain; @@ -41,9 +42,8 @@ public class CredentialsAndRegionFactory { * @return An {@link AwsCredentialsProviderChain} that attempts to read the values from the Micronaut environment * first, then delegates to {@link DefaultCredentialsProvider}. */ - @Bean(preDestroy = "close") @Singleton - public AwsCredentialsProviderChain awsCredentialsProvider(Environment environment) { + public AwsCredentialsProvider awsCredentialsProvider(Environment environment) { return AwsCredentialsProviderChain.of( EnvironmentAwsCredentialsProvider.create(environment), DefaultCredentialsProvider.create() @@ -56,7 +56,7 @@ public AwsCredentialsProviderChain awsCredentialsProvider(Environment environmen * first, then delegates to {@link DefaultAwsRegionProviderChain}. */ @Singleton - public AwsRegionProviderChain awsRegionProvider(Environment environment) { + public AwsRegionProvider awsRegionProvider(Environment environment) { return new AwsRegionProviderChain( new EnvironmentAwsRegionProvider(environment), new DefaultAwsRegionProviderChain() diff --git a/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/AwsClientFactory.java b/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/AwsClientFactory.java index 88bfbb6311..db2cb26894 100644 --- a/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/AwsClientFactory.java +++ b/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/AwsClientFactory.java @@ -15,14 +15,14 @@ */ package io.micronaut.aws.sdk.v2.service; -import software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain; +import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; import software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; import software.amazon.awssdk.awscore.client.builder.AwsSyncClientBuilder; import software.amazon.awssdk.core.SdkClient; import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.async.SdkAsyncHttpClient; -import software.amazon.awssdk.regions.providers.AwsRegionProviderChain; +import software.amazon.awssdk.regions.providers.AwsRegionProvider; /** * Abstract class that eases creation of AWS client factories. @@ -37,8 +37,8 @@ */ public abstract class AwsClientFactory & AwsClientBuilder, AB extends AwsAsyncClientBuilder & AwsClientBuilder, SC, AC extends SdkClient> { - protected final AwsCredentialsProviderChain credentialsProvider; - protected final AwsRegionProviderChain regionProvider; + protected final AwsCredentialsProvider credentialsProvider; + protected final AwsRegionProvider regionProvider; /** * Constructor. @@ -46,7 +46,7 @@ public abstract class AwsClientFactory & * @param credentialsProvider The credentials provider * @param regionProvider The region provider */ - protected AwsClientFactory(AwsCredentialsProviderChain credentialsProvider, AwsRegionProviderChain regionProvider) { + protected AwsClientFactory(AwsCredentialsProvider credentialsProvider, AwsRegionProvider regionProvider) { this.credentialsProvider = credentialsProvider; this.regionProvider = regionProvider; } diff --git a/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/dynamodb/DynamoDbClientFactory.java b/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/dynamodb/DynamoDbClientFactory.java index 6f01ec585b..ef0b58ea94 100644 --- a/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/dynamodb/DynamoDbClientFactory.java +++ b/aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/service/dynamodb/DynamoDbClientFactory.java @@ -19,10 +19,10 @@ import io.micronaut.context.annotation.Bean; import io.micronaut.context.annotation.Factory; import io.micronaut.context.annotation.Requires; -import software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain; +import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.async.SdkAsyncHttpClient; -import software.amazon.awssdk.regions.providers.AwsRegionProviderChain; +import software.amazon.awssdk.regions.providers.AwsRegionProvider; import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient; import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClientBuilder; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; @@ -45,7 +45,7 @@ public class DynamoDbClientFactory extends AwsClientFactory { - protected RekognitionClientFactory(AwsCredentialsProviderChain credentialsProvider, AwsRegionProviderChain regionProvider) { + protected RekognitionClientFactory(AwsCredentialsProvider credentialsProvider, AwsRegionProvider regionProvider) { super(credentialsProvider, regionProvider); }