If the credentials provider is not specified when creating a new AwsClient with an AwsClientBuilder, the AWS SDK
will execute some logic to identify it automatically.
While it will probably identify the correct one, this extra logic will slow down startup time, already known to be a hotspot.
You should therefore always define the logic to set the credentials provider yourself. This is typically done by retrieving it from the Lambda
provided environment variable.
This will make the code more explicit and spare initialization time.
This rule reports an issue when the credentials provider is not set when creating an AwsClient.
Noncompliant code example
S3Client.builder()
.region(Region.of(System.getenv(SdkSystemSetting.AWS_REGION.environmentVariable())))
.build();
Compliant solution
S3Client.builder()
.region(Region.of(System.getenv(SdkSystemSetting.AWS_REGION.environmentVariable()))
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();