Skip to content

Commit 41e1510

Browse files
committed
JavaScript SDK v3 updates and deprecations
1 parent 54f81e3 commit 41e1510

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
const AWSXRay = require('aws-xray-sdk-core')
2-
const AWS = AWSXRay.captureAWS(require('aws-sdk'))
1+
const AWSXRay = require('aws-xray-sdk-core');
2+
const { LambdaClient, GetAccountSettingsCommand } = require('@aws-sdk/client-lambda');
33

44
// Create client outside of handler to reuse
5-
const lambda = new AWS.Lambda()
5+
const lambda = AWSXRay.captureAWSv3Client(new LambdaClient());
66

77
// Handler
88
exports.handler = async function(event, context) {
9-
event.Records.forEach(record => {
10-
console.log(record.body)
11-
})
12-
console.log('## ENVIRONMENT VARIABLES: ' + serialize(process.env))
13-
console.log('## CONTEXT: ' + serialize(context))
14-
console.log('## EVENT: ' + serialize(event))
15-
16-
return getAccountSettings()
17-
}
9+
event.Records.forEach(record => {
10+
console.log(record.body);
11+
});
12+
13+
console.log('## ENVIRONMENT VARIABLES: ' + serialize(process.env));
14+
console.log('## CONTEXT: ' + serialize(context));
15+
console.log('## EVENT: ' + serialize(event));
16+
17+
return getAccountSettings();
18+
};
1819

1920
// Use SDK client
20-
var getAccountSettings = function(){
21-
return lambda.getAccountSettings().promise()
22-
}
21+
var getAccountSettings = function() {
22+
return lambda.send(new GetAccountSettingsCommand());
23+
};
2324

2425
var serialize = function(object) {
25-
return JSON.stringify(object, null, 2)
26-
}
26+
return JSON.stringify(object, null, 2);
27+
};

sample-apps/blank-nodejs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"jest": "29.7.0"
77
},
88
"dependencies": {
9-
"aws-sdk": "2.1484.0",
10-
"aws-xray-sdk-core": "3.5.3"
9+
"@aws-sdk/client-lambda": "3.582.0",
10+
"aws-xray-sdk-core": "3.6.0"
1111
},
1212
"scripts": {
1313
"test": "jest"

sample-apps/blank-nodejs/template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Resources:
66
Type: AWS::Serverless::Function
77
Properties:
88
Handler: index.handler
9-
Runtime: nodejs18.x
9+
Runtime: nodejs20.x
1010
CodeUri: function/.
1111
Description: Call the AWS Lambda API
1212
Timeout: 10
@@ -25,4 +25,4 @@ Resources:
2525
Description: Dependencies for the blank sample app.
2626
ContentUri: lib/.
2727
CompatibleRuntimes:
28-
- nodejs18.x
28+
- nodejs20.x

0 commit comments

Comments
 (0)