To fix AWS missing credentials when trying send something to S3 Bucket in Node.js, we call the config.update
method.
For instance, we write
AWS.config.update({
accessKeyId: "YOURKEY",
secretAccessKey: "YOURSECRET",
region: "sa-east-1",
});
const s3 = new AWS.S3();
const params = {
Bucket: "makersquest",
Key: "mykey.txt",
Body: "HelloWorld",
};
s3.putObject(params, (err, res) => {
if (err) {
console.log("Error uploading data: ", err);
} else {
console.log("Successfully uploaded data to myBucket/myKey");
}
});
to call update
to update access key and secret key to connect to AWS.