Category : aws-lambda

I’m using a simple api call that needs Digest Auth: const { default: AxiosDigestAuth } = require(‘@mhoc/axios-digest-auth’); exports.handler = async () => { const digestAuth = new AxiosDigestAuth({ username: user, password: pass, }); await digestAuth.request({ headers: { ‘Content-Type’: ‘application/json’, Connection: ‘keep-alive’, Accept: ‘application/json’, }, method: ‘POST’, url: ‘https://sms.voxbone.com:4443/sms/v1/’, data, }); }; I thought the issue ..

Read more

After declaring two variables param01 and param02 I go ahead and check if the incoming event.pathParameters is not undefined: let param01, param02; if (event.pathParameters!=undefined) { if (event.pathParameters.param01!=undefined) { param01 = event.pathParameters.param01; } if (event.pathParameters.param02!=undefined) { param02 = event.pathParameters.param02; } } While it works fine, it takes 10 lines of code. I wonder if there is ..

Read more

I’m looking for a solution whereby I can safely (and nearly reliably) emit CW metrics (putMetricData) within synchronous code. My use case is as follows: // Lambda Main Handler export const handler = async () => { await step1Aync(); step2Sync(); step3Sync(); return {}; } async function step1Aync() { await doSomething(); await doSomething(); // could await ..

Read more

I’m working on a lambda function in AWS that is supposed to get information from a DynamoDB and then make a post request if a flag is active. My first and successful attempt to implement this used callbacks only: handler = function (event,context) { documentClient.get(tableParameters, function(err, data) { if (err) { console.log(err); context.fail(err); } else ..

Read more