Skip to content

fix:Removing env var credentials provider as default. #1161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class Constants {
public static final String LAMBDA_FUNCTION_NAME_ENV = "AWS_LAMBDA_FUNCTION_NAME";
public static final String AWS_REGION_ENV = "AWS_REGION";
public static final String IDEMPOTENCY_DISABLED_ENV = "POWERTOOLS_IDEMPOTENCY_DISABLED";
public static final String AWS_LAMBDA_INITIALIZATION_TYPE = "AWS_LAMBDA_INITIALIZATION_TYPE";
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ private DynamoDBPersistenceStore(String tableName,
String idempotencyDisabledEnv = System.getenv().get(Constants.IDEMPOTENCY_DISABLED_ENV);
if (idempotencyDisabledEnv == null || idempotencyDisabledEnv.equalsIgnoreCase("false")) {
DynamoDbClientBuilder ddbBuilder = DynamoDbClient.builder()
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.httpClient(UrlConnectionHttpClient.builder().build())
.region(Region.of(System.getenv(AWS_REGION_ENV)));

// AWS_LAMBDA_INITIALIZATION_TYPE has two values on-demand and snap-start
// when using snap-start mode, the env var creds provider isn't used and causes a fatal error
// fall back to the default provider chain if the mode is anything other than on-demand.
String initializationType = System.getenv().get(Constants.AWS_LAMBDA_INITIALIZATION_TYPE);
if (initializationType != null && initializationType.equals("on-demand")) {
ddbBuilder.credentialsProvider(EnvironmentVariableCredentialsProvider.create());
}

this.dynamoDbClient = ddbBuilder.build();
} else {
// we do not want to create a DynamoDbClient if idempotency is disabled
Expand Down