[rush-lib] Improve support for S3 storage for the buildCache #2614
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Improve support for S3 storage when enabling the build cache (feature added as part of conversation in #2393).
Details
When an S3 bucket is created outside the default region, the URL generated for presigning includes a region suffix (for example,
mybucket.s3-us-west-1.amazonaws.com
). If this isn't taken into account, the signed request will not be valid and the request will return a403
.When the user's credentials are temporary credentials (generated by assuming a role or using an assigned IAM Profile), you need three pieces of information and not 2: the key, the secret, and the session token. The user needs a way to give this information and the signing logic needs to include it in the appropriate places.
RUSH_BUILD_CACHE_WRITE_CREDENTIAL
to the valueKEY:SECRET:TOKEN
, with three fields, instead of just two. I believe this is considered just a string outside this context and doesn't require changes elsewhere.x-amz-security-token
header needs to be included in 3 places: in the request body used to generate a signature, in the list of headers inside the same request body, and as a header on the actual request (passed to fetch).How it was tested
"It works on my machine."
(I wouldn't mind adding some new unit tests for this functionality, but I think at minimum they'd require mocking
node-fetch
, and I don't see a lot of mocking going on in this area of the codebase. Any advice on usual patterns to use here are appreciated.)