I have had a Lambda node.js function up and running for about 6 months without any issue. The function simply takes a object and copies it from one bucket to another.
Today, I have started getting:
"SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method."
The code I am using is pretty simple, any suggestions on how I could fix this?
var aws = require('aws-sdk'); var s3 = new aws.S3({apiVersion: '2006-03-01'}); exports.handler = function(event, context) { var to_bucket = 'my_to_bucket/test'; var from_bucket = event.Records[0].s3.bucket.name; var key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " ")); var size = Math.floor(event.Records[0].s3.object.size / 1024); s3.getObject({Bucket: from_bucket, Key: key}, function(err, data) { if (err) { // send a webhook } else { s3.putObject({Bucket: to_bucket, Key: key, Body: data.Body, ContentType: data.ContentType}, function(err, data) { if (err) { // send a webhook } else { // send a webhook } }); } // end else }); // end getobject };
UPDATE: I have discovered that if sending to a bucket, it works fine. If I sent to any subfolder of the same bucket, it fails. I do send to a subfolder and simplified the code above initially, but I've updated it to show a subfolder in the to_bucket.