From bed1b7c971f0f87891133151035a1d6960c2cf6b Mon Sep 17 00:00:00 2001 From: James Gregory Date: Mon, 13 Apr 2020 11:14:57 +1000 Subject: [PATCH] fix(lambda): invoke lambda with actual AWS SDK version --- src/services/lambda.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services/lambda.ts b/src/services/lambda.ts index 8e3a0f39..9aa47a8a 100644 --- a/src/services/lambda.ts +++ b/src/services/lambda.ts @@ -1,8 +1,15 @@ import { CognitoUserPoolEvent } from "aws-lambda"; import * as AWS from "aws-sdk"; import { InvocationResponse } from "aws-sdk/clients/lambda"; +import * as fs from "fs"; import { UnexpectedLambdaExceptionError } from "../errors"; +const awsSdkPackageJson = fs.readFileSync( + require.resolve("aws-sdk/package.json"), + "utf-8" +); +const awsSdkVersion = JSON.parse(awsSdkPackageJson).version; + interface UserMigrationEvent { userPoolId: string; clientId: string; @@ -61,7 +68,7 @@ export const createLambda: CreateLambda = (config, lambdaClient) => ({ version: 0, // TODO: how do we know what this is? userName: event.username, callerContext: { - awsSdkVersion: "2.656.0", // TODO: this isn't correct + awsSdkVersion, clientId: event.clientId, }, region: "local", // TODO: pull from above,