-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fs-aws): add credential config for public and requester pays (#1409
) #### Motivation Requester pays and public buckets are pretty common ways of accessing s3 locations, access needs to be configured so that a bucket can be accessed with either: - "assume this role then use requester pays" - "use the current role but as requester pays" or as a public bucket with no credentials. #### Modification allow credentials to be defined as requester pays or public
- Loading branch information
Showing
4 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
import { AwsS3CredentialProvider, getPublicS3 } from '../credentials.js'; | ||
import { AwsCredentialConfig } from '../types.js'; | ||
|
||
describe('AwsS3CredentialProvider', () => { | ||
const baseConfig: AwsCredentialConfig = { type: 's3', prefix: 's3://' }; | ||
it('should set requester pays', () => { | ||
const creds = new AwsS3CredentialProvider(); | ||
|
||
const fs = creds.createFileSystem({ ...baseConfig, access: 'public' }); | ||
assert.ok(fs.s3 === getPublicS3()); | ||
assert.ok(fs.requestPayer === 'public'); | ||
}); | ||
|
||
it('should support requester pays', () => { | ||
const creds = new AwsS3CredentialProvider(); | ||
|
||
const fs = creds.createFileSystem({ ...baseConfig, roleArn: 'arn:...', access: 'requesterPays' }); | ||
assert.ok(fs.s3 !== getPublicS3()); | ||
assert.ok(fs.requestPayer === 'requester'); | ||
}); | ||
|
||
it('should support requester pays from the current role', () => { | ||
const creds = new AwsS3CredentialProvider(); | ||
|
||
const fs = creds.createFileSystem({ ...baseConfig, roleArn: undefined, access: 'requesterPays' }); | ||
assert.ok(fs.s3 !== getPublicS3()); | ||
assert.ok(fs.requestPayer === 'requester'); | ||
}); | ||
|
||
it('should require a roleArn', () => { | ||
const creds = new AwsS3CredentialProvider(); | ||
assert.throws(() => creds.createFileSystem({ ...baseConfig })); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters