From 169be60d8c8c1351fb387f6c5f0d0bcb673b4477 Mon Sep 17 00:00:00 2001 From: Vladimir Orany Date: Mon, 7 Jun 2021 12:17:54 +0200 Subject: [PATCH] reverted static credentials usage --- .../libs/awssdk/util/AwsClientUtil.groovy | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy b/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy index 778e3ae..56bd9ba 100644 --- a/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy +++ b/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy @@ -2,25 +2,18 @@ package agorapulse.libs.awssdk.util import com.amazonaws.ClientConfiguration import com.amazonaws.Protocol -import com.amazonaws.SdkClientException -import com.amazonaws.auth.AWSCredentials import com.amazonaws.auth.AWSCredentialsProvider import com.amazonaws.auth.AWSStaticCredentialsProvider -import com.amazonaws.auth.AnonymousAWSCredentials import com.amazonaws.auth.BasicAWSCredentials import com.amazonaws.auth.DefaultAWSCredentialsProviderChain import com.amazonaws.client.builder.AwsSyncClientBuilder import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration import com.amazonaws.regions.Region import com.amazonaws.regions.RegionUtils -import org.slf4j.Logger -import org.slf4j.LoggerFactory @SuppressWarnings(['FactoryMethodName']) class AwsClientUtil { - private static final Logger LOGGER = LoggerFactory.getLogger(AwsClientUtil) - static final String DEFAULT_REGION = 'us-east-1' static > B configure(B builder, String serviceName, config, serviceConfig) { @@ -166,15 +159,7 @@ class AwsClientUtil { } if (!config.accessKey || !config.secretKey) { - try { - // only fetch the credentials once when inititalized - AWSCredentials credentials = new DefaultAWSCredentialsProviderChain().getCredentials() - return new AWSStaticCredentialsProvider(credentials) - } catch(SdkClientException e) { - LOGGER.warn('Failed to obtain credentials from the chain. ' + - 'Please, configure grails.plugin.awssdk.accessKey and grails.plugin.awssdk.secretKey ', e) - return new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()) - } + new DefaultAWSCredentialsProviderChain() } else { new AWSStaticCredentialsProvider(new BasicAWSCredentials(config.accessKey, config.secretKey)) }