-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cb2-11271): upgrade aws-sdk v2 to v3 (#402)
* chore(cb2-11271): initial pass client exception * chore(cb2-11271): fix int tests * chore(cb2-11271): linting * chore(cb2-11271): fix failing test * chore(cb2-11271): linting * chore(cb2-11271): parsing * chore(cb2-11271): parsing result * chore(cb2-11271): lint fix * chore(cb2-11271): parsing returned result * chore(cb2-11271): parsing attempt * chore(cb2-11271): console logging * chore(cb2-11271): linting * feat(cb2-11271): add logging * chore(cb2-11271): marshall options * chore(cb2-11271): linting * feat(cb2-11271): add console logging * feat(cb2-11271): another log * chore(cb2-11271): more logging * chore(cb2-11271): change parsing * chore(cb2-11271): change lambda service return * chore(cb2-11271): remove logging * chore(cb2-11271): refactor translate config * chore(cb2-11271): down npm version * chore(cb2-11271): npm version * chore(cb2-11271): remove npm from dependencies * chore(cb2-11271): remove npm packages
- Loading branch information
1 parent
4717bcd
commit 061ce09
Showing
9 changed files
with
1,980 additions
and
1,228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,32 @@ | ||
/* tslint:disable */ | ||
/* tslint:enable */ | ||
import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda'; | ||
import { toUint8Array } from '@smithy/util-utf8'; | ||
import { Configuration } from '../utils/Configuration'; | ||
import { validateInvocationResponse } from '../utils/validateInvocationResponse'; | ||
|
||
let AWS: any; | ||
if (process.env._X_AMZN_TRACE_ID) { | ||
AWS = require('aws-xray-sdk').captureAWS(require('aws-sdk')); | ||
} else { | ||
console.log('Serverless Offline detected; skipping AWS X-Ray setup'); | ||
AWS = require('aws-sdk'); | ||
} | ||
|
||
const lambdaInvokeEndpoints = Configuration.getInstance().getEndpoints(); | ||
|
||
/** | ||
* Helper service for interactions with other lambdas | ||
*/ | ||
export class LambdaService { | ||
public static invoke(lambdaName: any, lambdaEvent: any) { | ||
const lambda = new AWS.Lambda(lambdaInvokeEndpoints.params); | ||
public static async invoke(lambdaName: any, lambdaEvent: any) { | ||
const lambdaInvokeEndpoints = Configuration.getInstance().getEndpoints(); | ||
let AWS: any; | ||
if (process.env._X_AMZN_TRACE_ID) { | ||
AWS = require('aws-xray-sdk').captureAWSv3Client( | ||
new LambdaClient(lambdaInvokeEndpoints.params), | ||
); | ||
} else { | ||
console.log('Serverless Offline detected; skipping AWS X-Ray setup'); | ||
AWS = new LambdaClient(lambdaInvokeEndpoints.params); | ||
} | ||
|
||
return lambda | ||
.invoke({ | ||
const returned = await AWS.send( | ||
new InvokeCommand({ | ||
FunctionName: lambdaName, | ||
InvocationType: 'RequestResponse', | ||
Payload: JSON.stringify(lambdaEvent), | ||
}) | ||
.promise() | ||
.then((data: any) => { | ||
const payload = validateInvocationResponse(data); | ||
const body = JSON.parse(payload.body); | ||
return body; | ||
}); | ||
Payload: toUint8Array(JSON.stringify(lambdaEvent)), | ||
}), | ||
); | ||
const payload = validateInvocationResponse(returned); | ||
const body = JSON.parse(payload.body); | ||
return body; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.