Trying to trigger AppSync query via lambda function. V4 signer.addauthorization not working. Error message: "Data must be a string or a buffer"
See original GitHub issueError Message
2018-11-23T14:37:03.533Z 3e0ff525-ef2d-11e8-8328-89b33f69a07f TypeError: Data must be a string or a buffer at Hmac.update (crypto.js:99:16) at Object.hmac (/var/task/node_modules/aws-sdk/lib/util.js:399:50) at Object.getSigningKey (/var/task/node_modules/aws-sdk/lib/signers/v4_credentials.js:74:35) at V4.signature (/var/task/node_modules/aws-sdk/lib/signers/v4.js:98:36) at V4.authorization (/var/task/node_modules/aws-sdk/lib/signers/v4.js:93:36) at V4.addAuthorization (/var/task/node_modules/aws-sdk/lib/signers/v4.js:35:12) at AWS.config.credentials.get.err (/var/task/index.js:52:10) at Credentials.get (/var/task/node_modules/aws-sdk/lib/credentials.js:126:7) at exports.handler (/var/task/index.js:42:25) END RequestId: 3e0ff525-ef2d-11e8-8328-89b33f69a07f REPORT RequestId: 3e0ff525-ef2d-11e8-8328-89b33f69a07f Duration: 103.19 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 60 MB RequestId: 3e0ff525-ef2d-11e8-8328-89b33f69a07f Process exited before completing request
Expected result The V4 signing should complete successfully.
Current result
it currently fails with the error message above. I did some digging, in the hmac
function in util.js
, and realized that it gets called 3 times while the lambda function runs.
I only call signer.addAuthorization(cred, date)
once.
the first 2 times hmac
gets called, it has a correct string
parameter, which allows the successful creation of a buffer used in the function to create a new hmac, and return it.
the third time, this string
parameter is false. Thus, the Buffer isn’t created, and the hmac.update(string)
function fails with the error indicated above.
any help? Could this be a result of something I’m doing wrong?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:11 (3 by maintainers)
Top GitHub Comments
In case it helps somebody…I had the same problem and the origin of it was that the region environment variable was empty ( I was typing env.REGION when mine was defined in lowercase: env.region)
lambda runtime Node 8.10