'InvalidSignatureException: while invoking lambda function

InvalidSignatureException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method.

I believe, I am getting this error probably because of different time zones at the AWS server and client-side. (I can call this function from another lambda function without any error because the timezone is the same).

How can I get rid of this? I am new to using AWS services, please help. enter image description here

const lambda = new AWS.Lambda({
      apiVersion: "version",
      region: "region",
      accessKeyId: "key",
      secretAccessKey: "secret",
      signatureVersion: "s4",
    });


await lambda
      .invoke(params, function (err, data) {
        if (err) {
          console.log(err, err.stack);
        } else {
          console.log(data);
        }
      })
      .promise();

I can invoke a lambda function the same way another lambda function. I am facing this issue when I invoke the function from react-native.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source