davidmoten / aws-lightweight-client-java

A lightweight java client for the AWS API. Signs requests with AWS Version 4 and offers helpful builders.
Apache License 2.0
29 stars 3 forks source link

Fails to load credentials when SnapStart is activated #191

Open andreaselias opened 5 days ago

andreaselias commented 5 days ago

The following doc states that when SnapStart is activated the AWS credentials should work a little different. When I tried to use the libary as is with the SnapStart activated I got an error "argument cannot be null" which is a result of the checkNotNull method of the Preconditions class.

https://docs.aws.amazon.com/lambda/latest/dg/snapstart-activate.html

When SnapStart is activated, the Lambda runtime automatically uses the container credentials (AWS_CONTAINER_CREDENTIALS_FULL_URI and AWS_CONTAINER_AUTHORIZATION_TOKEN) instead of the access key environment variables. This prevents credentials from expiring before the function is restored.

It would be great if you could make it work with SnapStart. For now, as a workaround I am using without the SnapStart.

davidmoten commented 5 days ago

Thanks for the report, I'll get support for that sorted.

A note for me, a good chunk of the required logic is in https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/auth/BaseCredentialsFetcher.java#L34.

davidmoten commented 23 hours ago

See this PR