tus-node-server
tus-node-server copied to clipboard
S3Store: Add other strategies on passing credentials when initializing a S3Store
We are planning to use and run this library using AWS Fargate.
In AWS there are multiple ways to pass a credentials to aws-sdk
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html
Here is what we want
4. Credentials loaded from the ECS credentials provider (if applicable)
But the current implementation of the library is forcing us to provide the accessKeyId
and secretAccessKey
because of the assertion on the constructor of S3Store
class.
https://github.com/tus/tus-node-server/blob/master/lib/stores/S3Store.js#L58
assert.ok(options.accessKeyId, '[S3Store] `accessKeyId` must be set');
assert.ok(options.secretAccessKey, '[S3Store] `secretAccessKey` must be set');`
What we want to achieve is to make those properties optional and add another new property credentials
So that we can initialize it like this
server.datastore = new tus.S3Store({
path: '/',
bucket: 'my-bucket',
credentials: new AWS.ECSCredentials({
httpOptions: { timeout: 5000 },
maxRetries: 10,
retryDelayOptions: { base: 200 },
}),
region: 'use-east-1',
partSize: 8 * 1024 * 1024,
});
Hi, I'm open to this idea. I see this should also automatically work as we pass all options into new aws.S3()
. However, we should make sure we create proper TypeScript types that make sure that either credentials
or accessKeyId
/secretAccessKey
are set.
Are you willing to reopen your PR for this with the added types?
Any plan on merging that PR? We're interested in a similar use case (running in EKS cluster). Thanks.
I can merge it and do a 0.x release
Released: https://github.com/tus/tus-node-server/releases/tag/v0.9.0
That was super fast, thank you!