Skip to content
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

Enable sessionToken to be unset in S3Client #16817

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nicksrandall
Copy link

@nicksrandall nicksrandall commented Jan 27, 2025

What does this PR do?

Fixes #16810

This PR enables users to opt out of using the AWS_SESSION_TOKEN environment variable when using the S3Client. This is useful for users who are using Bun in an environment where the AWS_SESSION_TOKEN environment variable is set, but they do not want to use it (eg AWS Lambda functions, or session token is being used for another purpose).

WIth this change, users can opt out of using the AWS_SESSION_TOKEN (and S3_SESSION_TOKEN) by passing null to the sessionToken property in constructor.

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

  • I need some guidance on how to test this change.

Copy link
Member

@cirospaciari cirospaciari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one comment, will manually test and check how we can test this using CI

@nicksrandall nicksrandall force-pushed the nick/s3-session-token branch from acb28d6 to 8d3403a Compare January 29, 2025 01:57
@cirospaciari cirospaciari self-requested a review January 29, 2025 01:58
Copy link
Member

@cirospaciari cirospaciari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the test In test/js/bun/s3/s3.test.ts we should be able to start a process passing the credentials and a invalid sessionToken in the env, using Bun.spawn, and write/read to the bucket cleaning the sessionToken parameter, check bunExe, bunEnv and allCredentials, we can exit 1 for a error and exit 0 if everything is right, and check the exitCode

@nicksrandall
Copy link
Author

@cirospaciari I tried to write a test but I actually couldn't figure out how to get it to work. I might need some help finishing this PR.

@cirospaciari
Copy link
Member

@cirospaciari I tried to write a test but I actually couldn't figure out how to get it to work. I might need some help finishing this PR.

Sure will help you with that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

S3Client.write fails with S3Error: X-Amz-Security-Token and code: InvalidArgument when run in an AWS Lambda
2 participants