[AWS s3 undefined 0.006s 0 retries] headObject({ Bucket: 'mypicturebank', Key: 'testing' }) There was an error creating your album: TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined
@Ken G I'm not sure what language or framework you are using, though I ran across the similar error message The "key" argument must be one of type string, TypedArray, or DataView. Received type undefined
just now.
In my case and for anyone else who stumbles across this, it was because I was providing the PascalCase AWS credentials which are returned from AWS STS.assumeRole, where I needed to provide camelCase AWS credentials keys:
import AWS from 'aws-sdk'
# Bad
const s3 = new AWS.S3({
credentials: {
AccessKeyId: process.env.AWS_ACCESS_KEY,
SecretAccessKey: process.env.AWS_SECRET_KEY,
},
...
})
# Good
const s3 = new AWS.S3({
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_KEY,
},
...
})
I am using the aws-sdk for JavaScript on macOS with Node v10.16.2, with the goal of using s3.createPresignedPost.
Possibly related, on an AWS Lambda instance running node 10.x I was seeing a different error message for the same code: Key must be a buffer
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With