Lambda function being invoked but payload not being sent

Viewed 154

I have a function in an api that calls a lambda function to send an email.

However although the response is returning 200, i'm never getting the email. A previous implementation of this function using an older version of the aws-sdk has worked, so i have no reason to believe it is the lambda function itself, but rather the implementation of invoking the lambda.

export const DispathResetPasswordEmail = async (user: any, token: string) => {
    const payload = {
        to: user.email,
        subject: "Password Reset Requested",
        templateName: "reset-password",
        templateObject: {
            name: user.display_name,
            link: `some_link.com/${token}`,
        },
    };

    const client = new LambdaClient({ region: Config.aws.region });

    const params: InvokeCommandInput = {
        FunctionName: (Config.aws.email_service as string) || "",
        InvocationType: InvocationType.RequestResponse,
        Payload: Buffer.from(JSON.stringify(payload)),
    };
    const command = new InvokeCommand(params);

    try {
        const response = await client.send(command);
        return [response, null];
    } catch (err) {
        return [null, err];
    }
};

One thing i am unsure about is the payload Payload:Buffer.from(JSON.stringify(payload)) i'm not sure it is correct?

console.log of params

  {
      FunctionName: 'email-service-dev-main',
      InvocationType: 'RequestResponse',
      Payload: <Buffer 7b 22 74 6f 22 3a 22 6b 61 79 40 67 65 65 69 71 2e 63 6f 6d 22 2c 22 73 75 62 6a 65 63 74 22 3a 22 47 45 45 49 51 20 2d 20 50 61 73 73 77 6f 72 64 20 ... 108 more bytes>
    }

0 Answers
Related