Skip to content

Commit

Permalink
test: bump AWS::Serverless::Function runtime to nodejs18.x (#6196)
Browse files Browse the repository at this point in the history
* test: bump AWS::Serverless::Function runtime to nodejs18.x

* chore: remove import of aws-sdk where not needed

* chore: replace SQS clients from JS SDK v2 to v3

* chore: replace DynamoDB clients from JS SDK v2 to v3

* chore: replace EventBridge clients from JS SDK v2 to v3

---------

Co-authored-by: Mohamed Elasmar <[email protected]>
  • Loading branch information
trivikr and moelasmar authored Nov 8, 2023
1 parent eb47e4a commit 7d39ecb
Show file tree
Hide file tree
Showing 46 changed files with 106 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Resources:
return response;
};
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
Events:
ImplicitGet:
Type: Api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Resources:
return response;
};
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
Events:
ImplicitGet:
Type: Api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Resources:
Properties:
CodeUri: s3://bucket/key
Handler: app.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
Events:
CognitoUserPoolPreSignup:
Type: Cognito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ Resources:
MyServerlessFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand All @@ -58,11 +57,10 @@ Resources:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt MyRole.Arn
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
Code:
ZipFile: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ Resources:
MyServerlessFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand All @@ -31,11 +30,10 @@ Resources:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt MyRole.Arn
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
Code:
ZipFile: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Resources:
return "Hello World"
}
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x

AppSyncApi:
Type: AWS::AppSync::GraphQLApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ Resources:
Function:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log("function")
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ Resources:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt MyRole.Arn
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
Code:
ZipFile: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand All @@ -30,10 +29,9 @@ Resources:
MyServerlessFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ Resources:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt MyRole.Arn
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
Code:
ZipFile: |
const AWS = require('aws-sdk');
const { DynamoDBDocument } = require('@aws-sdk/lib-dynamodb');
const { DynamoDB } = require('@aws-sdk/client-dynamodb');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
const docClient = new AWS.DynamoDB.DocumentClient();
await docClient.scan({ TableName: process.env.TABLE_NAME, }).promise();
const docClient = DynamoDBDocument.from(new DynamoDB());
await docClient.scan({ TableName: process.env.TABLE_NAME, });
};
Environment:
Variables:
Expand All @@ -32,14 +34,16 @@ Resources:
MyServerlessFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
const { DynamoDBDocument } = require('@aws-sdk/lib-dynamodb');
const { DynamoDB } = require('@aws-sdk/client-dynamodb');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
const docClient = new AWS.DynamoDB.DocumentClient();
await docClient.scan({ TableName: process.env.TABLE_NAME, }).promise();
const docClient = DynamoDBDocument.from(new DynamoDB());
await docClient.scan({ TableName: process.env.TABLE_NAME, });
};
Environment:
Variables:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ Resources:
TriggerFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
Timeout: 10 # in case eb has delay
InlineCode: |
const AWS = require('aws-sdk');
const { EventBridge } = require('@aws-sdk/client-eventbridge');
const { SQS } = require('@aws-sdk/client-sqs');
exports.handler = async (event) => {
const eb = new AWS.EventBridge();
const eb = new EventBridge();
const response = await eb.putEvents({
Entries: [{
Source: process.env.EVENT_SOURCE,
Detail: "{}",
DetailType: "Test",
}]
}).promise();
});
const sqs = new AWS.SQS();
const sqs = new SQS();
const data = await sqs.getQueueAttributes({
QueueUrl: process.env.QUEUE_URL,
AttributeNames: ['ApproximateNumberOfMessages']
}).promise();
});
if (data.Attributes.ApproximateNumberOfMessages < 2) {
throw 'Not enough messages in the queue!';
Expand Down Expand Up @@ -54,17 +55,17 @@ Resources:
Function:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
const { SQS } = require('@aws-sdk/client-sqs');
exports.handler = async (event) => {
const sqs = new AWS.SQS();
const sqs = new SQS();
await sqs.sendMessage({
QueueUrl: process.env.QUEUE_URL,
MessageBody: "test"
}).promise();
});
};
Environment:
Variables:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
exports.handler = async (event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ Resources:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt MyRole.Arn
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
Code:
ZipFile: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ Resources:
TriggerFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
Timeout: 10 # in case eb has delay
InlineCode: |
const AWS = require('aws-sdk');
const { SQS } = require('@aws-sdk/client-sqs');
exports.handler = async (event) => {
var params = {
QueueUrl: process.env.QUEUE_URL,
MessageBody: "test queue"
};
var sqs = new AWS.SQS();
await sqs.sendMessage(params).promise();
var sqs = new SQS();
await sqs.sendMessage(params);
const data = await sqs.receiveMessage({
QueueUrl: process.env.VERIFICATION_QUEUE_URL,
WaitTimeSeconds: 5,
}).promise();
});
if (data.Messages.length == 0) {
throw 'No messages in the queue!';
}
Expand All @@ -39,16 +40,17 @@ Resources:
InvokedFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
const { SQS } = require('@aws-sdk/client-sqs');
exports.handler = async (event) => {
const sqs = new AWS.SQS();
const sqs = new SQS();
await sqs.sendMessage({
QueueUrl: process.env.VERIFICATION_QUEUE_URL,
MessageBody: "test"
}).promise();
});
};
Environment:
Variables:
Expand Down
Loading

0 comments on commit 7d39ecb

Please sign in to comment.