Remove AWS.config.update
jdrydn opened this issue · 2 comments
Please remove the aws.config.update
line from the constructor, it's a very destructive operation affecting all other AWS services instantiated after the fact:
s3-browser-direct-upload/src/lib/index.coffee
Lines 9 to 19 in 1d92cca
I've had issues running with this module under an ECS Fargate instance, with an IAM role underneath, because this module calls AWS.config.update
which unsets the IAM role assigned to the process & instead replaces the global config with temporary credentials, which eventually times out.
To get around it I've manually copied index.js to my application, commented out the AWS.config.update(...)
line, and now it runs perfectly fine, not interfering with any other AWS services run afterwards.
Hate your job? Sprinkle AWS.config.update's throughout the codebase and watch as your team pulls their hair out.
aws/aws-sdk-js#1276 (comment)
Agreed ^
@jssuttles FYI due to inactivity in this repo, I ended up replacing my modified index.js
file with s3.createPresignedPost
. It produces the same result & allows further control over the upload (e.g. specifying contentType
for the file in question):
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
s3.createPresignedPost({
Bucket: 'example-bucket',
Fields: {
key: 'path/to/file.png',
'Content-Type': 'image/png',
acl: 'public-read',
Etag: 'someimportantmd5value',
'x-amz-meta-user': 'jdrydn@github.io'
}
}, (err, data) {
if (err) {
throw err;
} else {
const { url, fields } = data;
console.log({ url, fields });
// { url: 'https://s3.amazonaws.com/example-bucket',
// fields: {
// key: 'path/to/file.png',
// ... (policy, signature, data, all other relevant upload fields) } }
}
});
Further AWS documentation on presigned posts.
Hope this helps!