Skip to content

JavaScript SDK v3 updates #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions sample-apps/blank-nodejs/function/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
const AWSXRay = require('aws-xray-sdk-core')
const AWS = AWSXRay.captureAWS(require('aws-sdk'))
const AWSXRay = require('aws-xray-sdk-core');
const { LambdaClient, GetAccountSettingsCommand } = require('@aws-sdk/client-lambda');

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

// Handler
exports.handler = async function(event, context) {
event.Records.forEach(record => {
console.log(record.body)
})
console.log('## ENVIRONMENT VARIABLES: ' + serialize(process.env))
console.log('## CONTEXT: ' + serialize(context))
console.log('## EVENT: ' + serialize(event))

return getAccountSettings()
}
event.Records.forEach(record => {
console.log(record.body);
});

console.log('## ENVIRONMENT VARIABLES: ' + serialize(process.env));
console.log('## CONTEXT: ' + serialize(context));
console.log('## EVENT: ' + serialize(event));

return getAccountSettings();
};

// Use SDK client
var getAccountSettings = function(){
return lambda.getAccountSettings().promise()
}
var getAccountSettings = function() {
return lambda.send(new GetAccountSettingsCommand());
};

var serialize = function(object) {
return JSON.stringify(object, null, 2)
}
return JSON.stringify(object, null, 2);
};
4 changes: 2 additions & 2 deletions sample-apps/blank-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"jest": "29.7.0"
},
"dependencies": {
"aws-sdk": "2.1484.0",
"aws-xray-sdk-core": "3.5.3"
"@aws-sdk/client-lambda": "3.582.0",
"aws-xray-sdk-core": "3.6.0"
},
"scripts": {
"test": "jest"
Expand Down
4 changes: 2 additions & 2 deletions sample-apps/blank-nodejs/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs18.x
Runtime: nodejs20.x
CodeUri: function/.
Description: Call the AWS Lambda API
Timeout: 10
Expand All @@ -25,4 +25,4 @@ Resources:
Description: Dependencies for the blank sample app.
ContentUri: lib/.
CompatibleRuntimes:
- nodejs18.x
- nodejs20.x