Skip to content

Commit

Permalink
chore: update Lambda Node.js to 20.x
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed May 30, 2024
1 parent 0ead7ea commit e920f79
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion go/codepipeline-build-deploy/codepipeline-build-deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func NewCodePipelineBuildDeployStack(scope constructs.Construct, id string, prop
Architecture: lambda.Architecture_ARM_64(),
Code: lambda.AssetCode_FromAsset(jsii.String("./lambda/"), nil),
Handler: jsii.String("trigger-build.handler"),
Runtime: lambda.Runtime_NODEJS_18_X(),
Runtime: lambda.Runtime_NODEJS_20_X(),
Environment: &map[string]*string{
"REGION": jsii.String(os.Getenv("CDK_DEFAULT_REGION")),
"CODEBUILD_PROJECT_NAME": jsii.String(*buildImage.ProjectName()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
architecture=lambda_.Architecture.ARM_64,
code=lambda_.Code.from_asset("lambda"),
handler="trigger-build.handler",
runtime=lambda_.Runtime.NODEJS_18_X,
runtime=lambda_.Runtime.NODEJS_20_X,
environment={
"CODEBUILD_PROJECT_NAME": build_image.project_name,
"REGION": os.getenv('CDK_DEFAULT_REGION') or ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class GatewayLambdaAuth extends cdk.Stack {
*/
private getOperationalFunction(): cdk.aws_lambda.IFunction {
return new cdk.aws_lambda_nodejs.NodejsFunction(this, "operational-lambda", {
runtime: cdk.aws_lambda.Runtime.NODEJS_18_X,
runtime: cdk.aws_lambda.Runtime.NODEJS_20_X,
handler: "index.handler",
bundling: {
sourceMap: true,
Expand All @@ -76,7 +76,7 @@ export class GatewayLambdaAuth extends cdk.Stack {
*/
private getLambdaAuthFunction(): cdk.aws_lambda.IFunction {
return new cdk.aws_lambda_nodejs.NodejsFunction(this, "authentication-lambda", {
runtime: cdk.aws_lambda.Runtime.NODEJS_18_X,
runtime: cdk.aws_lambda.Runtime.NODEJS_20_X,
handler: "index.handler",
bundling: {
sourceMap: true,
Expand Down
4 changes: 2 additions & 2 deletions typescript/api-gateway-parallel-step-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ApiGatewayParallelStepFunctionsStack extends cdk.Stack {
const { vpc: vpcLambda } = new VpcNestedStack(this, 'nested-stack-lambda');

const lambdaFunction1 = new lambda.Function(this, 'lambda-function-1', {
runtime: lambda.Runtime.NODEJS_18_X,
runtime: lambda.Runtime.NODEJS_20_X,
vpc: vpcLambda,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
Expand All @@ -32,7 +32,7 @@ export class ApiGatewayParallelStepFunctionsStack extends cdk.Stack {
})

const lambdaFunction2 = new lambda.Function(this, 'lambda-function-2', {
runtime: lambda.Runtime.NODEJS_18_X,
runtime: lambda.Runtime.NODEJS_20_X,
vpc: vpcLambda,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
Expand Down
2 changes: 1 addition & 1 deletion typescript/aspects/lib/sample-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class SampleLambdaConstruct extends Construct {
const lambdaProps: lambda.FunctionProps = {
handler: 'index.handler',
code: lambda.Code.fromInline('export function handler(event, context){}'),
runtime: lambda.Runtime.NODEJS_18_X,
runtime: lambda.Runtime.NODEJS_20_X,
}

new lambda.Function(this, 'StandardFunction', lambdaProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ export class CodepipelineBuildDeployStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

// modify gitignore file to remove unneeded files from the codecommit copy
// modify gitignore file to remove unneeded files from the codecommit copy
let gitignore = fs.readFileSync('.gitignore').toString().split(/\r?\n/);
gitignore.push('.git/');
gitignore = gitignore.filter(g => g != 'node_modules/');
gitignore.push('/node_modules/');

const codeAsset = new Asset(this, 'SourceAsset', {
path: path.join(__dirname, "../"),
ignoreMode: IgnoreMode.GIT,
exclude: gitignore,
});

const codeRepo = new codecommit.Repository(this, "repo", {
repositoryName: "simple-code-repo",
// Copies files from codepipeline-build-deploy directory to the repo as the initial commit
code: Code.fromAsset(codeAsset, 'main'),
});

// Creates an Elastic Container Registry (ECR) image repository
const imageRepo = new ecr.Repository(this, "imageRepo");

Expand Down Expand Up @@ -72,13 +72,13 @@ export class CodepipelineBuildDeployStack extends cdk.Stack {
},
},
});

// CodeBuild project that builds the Docker image
const buildTest = new codebuild.Project(this, "BuildTest", {
buildSpec: codebuild.BuildSpec.fromSourceFilename("buildspec.yaml"),
source: codebuild.Source.codeCommit({ repository: codeRepo }),
environment: {
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_4,
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_4,
}
});

Expand All @@ -90,7 +90,7 @@ export class CodepipelineBuildDeployStack extends cdk.Stack {
architecture: lambda.Architecture.ARM_64,
code: lambda.Code.fromAsset("./lambda"),
handler: "trigger-build.handler",
runtime: lambda.Runtime.NODEJS_18_X,
runtime: lambda.Runtime.NODEJS_20_X,
environment: {
REGION: process.env.CDK_DEFAULT_REGION!,
CODEBUILD_PROJECT_NAME: buildImage.projectName,
Expand Down Expand Up @@ -233,7 +233,7 @@ export class CodepipelineBuildDeployStack extends cdk.Stack {
],
};

// Run jest test and send result to CodeBuild
// Run jest test and send result to CodeBuild
const testStage = {
stageName: "Test",
actions: [
Expand Down
8 changes: 4 additions & 4 deletions typescript/cognito-api-lambda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class CognitoProtectedApi extends Stack {
const helloWorldFunction = new Function(this, 'helloWorldFunction', {
code: new AssetCode('src'),
handler: 'helloworld.handler',
runtime: Runtime.NODEJS_18_X
runtime: Runtime.NODEJS_20_X
});

// Rest API backed by the helloWorldFunction
Expand All @@ -38,7 +38,7 @@ export class CognitoProtectedApi extends Stack {
providerArns: [userPool.userPoolArn],
})

// Hello Resource API for the REST API.
// Hello Resource API for the REST API.
const hello = helloWorldLambdaRestApi.root.addResource('HELLO');

// GET method for the HELLO API resource. It uses Cognito for
Expand All @@ -48,9 +48,9 @@ export class CognitoProtectedApi extends Stack {
authorizer: {
authorizerId: authorizer.ref
}

})

}
}

Expand Down
8 changes: 4 additions & 4 deletions typescript/inspector2/lib/inspector2-monitoring-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
import { Construct } from 'constructs';

/** A Custom Resource construct for monitoring Amazon Inspector scan results.
*
*
* Deploys a Lambda to handle initial scan results and another Lambda to handle Inspector2 Findings.
*
*
* For more details see https://docs.aws.amazon.com/inspector/latest/user/findings-managing-automating-responses.html
*/
export class Inspector2MonitoringResource extends cdk.Resource {
Expand Down Expand Up @@ -42,13 +42,13 @@ export class Inspector2MonitoringResource extends cdk.Resource {

const inspector2InitialScanHandler = new lambda_nodejs.NodejsFunction(scope, 'Inspector2InitialScanHandler', {
timeout: cdk.Duration.minutes(15),
runtime: lambda.Runtime.NODEJS_18_X,
runtime: lambda.Runtime.NODEJS_20_X,
logRetention: logs.RetentionDays.ONE_DAY,
});

const inspector2FindingHandler = new lambda_nodejs.NodejsFunction(scope, 'Inspector2FindingHandler', {
timeout: cdk.Duration.minutes(15),
runtime: lambda.Runtime.NODEJS_18_X,
runtime: lambda.Runtime.NODEJS_20_X,
logRetention: logs.RetentionDays.ONE_DAY,
});

Expand Down
2 changes: 1 addition & 1 deletion typescript/lambda-api-ci/lib/lambda-api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class CDKExampleLambdaApiStack extends Stack {
this.lambdaFunction = new Function(this, props.functionName, {
functionName: props.functionName,
handler: "handler.handler",
runtime: Runtime.NODEJS_18_X,
runtime: Runtime.NODEJS_20_X,
code: new AssetCode(`./src`),
memorySize: 512,
timeout: Duration.seconds(10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class SharedStack extends cdk.Stack {
this.bucketName = bucket.bucketName;

const fn = new lambda.Function(this, 'S3EventNotificationsLambda', {
runtime: lambda.Runtime.NODEJS_18_X,
runtime: lambda.Runtime.NODEJS_20_X,
functionName: 'S3EventNotificationsManager',
handler: 'manage-s3-event-notifications.handler',
code: lambda.Code.fromAsset(path.join(__dirname, '../lambda')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class LambdaPCScalingScheduleStack extends Stack {
this.lambdaFunction = new NodejsFunction(this, 'LambdaFunction', {
functionName: this.lambdaFunctionName,
entry: `./lambda/lambda-handler.ts`,
runtime: Runtime.NODEJS_18_X,
runtime: Runtime.NODEJS_20_X,
memorySize: 512,
timeout: Duration.seconds(6),
});
Expand All @@ -45,13 +45,13 @@ export class LambdaPCScalingScheduleStack extends Stack {
})
// Scaling out every weekday (Monday through Friday) at 11:00 AM(UTC+0),
asg.scaleOnSchedule(`${this.lambdaFunctionName}ScheduleScaleOut`, {
schedule: Schedule.expression('cron(0 11 ? * MON-FRI *))'),
schedule: Schedule.expression('cron(0 11 ? * MON-FRI *))'),
minCapacity: 1,
maxCapacity: 1
})
// Scaling in every weekday (Monday through Friday) at 12:00 AM(UTC+0),
asg.scaleOnSchedule(`${this.lambdaFunctionName}ScheduleScaleIn`, {
schedule: Schedule.expression('cron(0 12 ? * MON-FRI *))'),
schedule: Schedule.expression('cron(0 12 ? * MON-FRI *))'),
minCapacity: 0,
maxCapacity: 0
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LambdaPCScalingTargetStack extends Stack {
this.lambdaFunction = new NodejsFunction(this, 'LambdaFunction', {
functionName: this.lambdaFunctionName,
entry: `./lambda/lambda-handler.ts`,
runtime: Runtime.NODEJS_18_X,
runtime: Runtime.NODEJS_20_X,
memorySize: 512,
timeout: Duration.seconds(6),
});
Expand All @@ -36,7 +36,7 @@ export class LambdaPCScalingTargetStack extends Stack {
version: this.lambdaFunction.currentVersion,
provisionedConcurrentExecutions: 1,
});
// Create Metric of Lambda Provisioned Concurrency
// Create Metric of Lambda Provisioned Concurrency
const metrics = new Metric({
metricName: 'ProvisionedConcurrencyUtilization',
namespace: 'AWS/Lambda',
Expand Down

0 comments on commit e920f79

Please sign in to comment.