-
Notifications
You must be signed in to change notification settings - Fork 90
Initialization of SDK client in DynamoDBPersistenceStore
leads to an error when used with SnapStart under certain conditions
#1302
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
Comments
I've created a proof-of-concept and updated the original issue. |
DynamoDBPersistenceStore
may lead to an error when used with SnapStartDynamoDBPersistenceStore
leads to an error when used with SnapStart under certain conditions
Hey @roamingthings thanks for the detailed analysis and reproduction! |
As a workaround anyone who hits this should be able to pass a client to the builder configured with the default credentials chain - here an example for idempotency/DynamoDB but the same pattern should be usable with the other modules that customize the credentials chain by default: // Create a DDB client for use with the DynamoDbPersistenceStore builder
DynamoDbClient createClient() {
return DynamoDbClient.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.region(Region.of(System.getenv(SdkSystemSetting.AWS_REGION.environmentVariable()))) Lines 415 to 418 in c185cb0
|
Yesterday one of my Lambda Function that is deployed using SnapStart ran into a problem that has been caused by
code that has been derived from this repository.
powertools-lambda-java/powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/persistence/DynamoDBPersistenceStore.java
Line 100 in c185cb0
An SDK client that has been initialized like that may fail to retrieve the credentials after an invocation has been timed out and the runtime is reused by subsequent invocations.
Also the error has been visible in my code, the code in this library may also be affected.
Expected Behavior
The client initialized in
DynamoDBPersistenceStore
will be able to retrieve its credentials after an previous invocation of the same runtime timed out.Current Behavior
DynamoDBPersistenceStore
fails when a previous invocation timed out.Possible Solution
Always use the default credentials provider chain by removing the code shown above. This has also been the suggested solution provided by AWS support.
Steps to Reproduce (for bugs)
I've created a proof-of-concept project to reproduce the issue:
https://github.com/roamingthings/sdk-client-snapstart-error-poc
What probably happens is the following:
AWS_LAMBDA_INITIALIZATION_TYPE
issnap-start
AWS_LAMBDA_INITIALIZATION_TYPE
ison-demand
Environment
The text was updated successfully, but these errors were encountered: