From e48af04c0b483d705d99c97a1f7bf8c6cd8e71c6 Mon Sep 17 00:00:00 2001 From: Abdu <91062205+Abdu03@users.noreply.github.com> Date: Fri, 29 Sep 2023 10:34:09 +0100 Subject: [PATCH] feat(synthetics): CloudWatch Synthetics NodeJS Pupeteer 6.0 Runtime with NodeJS 18 (#27339) Added `syn-nodejs-puppeteer-6.0` version to avaiable synthetic runtimes. This version runs on Node 18 allowing users to move away from node 16 (which is now at EOL). Changed an exisiting test to refrence the latest runtime and also updated the examples in the readme to refrence the latest runtime. Closes #27337. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk-lib/aws-synthetics/README.md | 14 +++++++------- .../aws-cdk-lib/aws-synthetics/lib/runtime.ts | 15 +++++++++++++++ .../aws-synthetics/test/canary.test.ts | 6 +++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/README.md b/packages/aws-cdk-lib/aws-synthetics/README.md index 1220cf1042a39..c5369eeee4b14 100644 --- a/packages/aws-cdk-lib/aws-synthetics/README.md +++ b/packages/aws-cdk-lib/aws-synthetics/README.md @@ -20,7 +20,7 @@ const canary = new synthetics.Canary(this, 'MyCanary', { code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), handler: 'index.handler', }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, environmentVariables: { stage: 'prod', }, @@ -110,7 +110,7 @@ const canary = new synthetics.Canary(this, 'Canary', { code: synthetics.Code.fromInline('/* Synthetics handler code'), }), cleanup: synthetics.Cleanup.LAMBDA, - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, }); ``` @@ -136,7 +136,7 @@ new synthetics.Canary(this, 'Inline Canary', { code: synthetics.Code.fromInline('/* Synthetics handler code */'), handler: 'index.handler', // must be 'index.handler' }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, }); // To supply the code from your local filesystem: @@ -145,7 +145,7 @@ new synthetics.Canary(this, 'Asset Canary', { code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), handler: 'index.handler', // must end with '.handler' }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, }); // To supply the code from a S3 bucket: @@ -156,7 +156,7 @@ new synthetics.Canary(this, 'Bucket Canary', { code: synthetics.Code.fromBucket(bucket, 'canary.zip'), handler: 'index.handler', // must end with '.handler' }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, }); ``` @@ -195,7 +195,7 @@ new synthetics.Canary(this, 'Vpc Canary', { code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), handler: 'index.handler', }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, vpc, }); ``` @@ -242,7 +242,7 @@ const canary = new synthetics.Canary(this, 'MyCanary', { code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), handler: 'index.handler', }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, artifactsBucketLifecycleRules: [{ expiration: Duration.days(30), }], diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts b/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts index 587d0ae40cf56..2c5c2c849f19f 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts @@ -122,6 +122,21 @@ export class Runtime { */ public static readonly SYNTHETICS_NODEJS_PUPPETEER_5_1 = new Runtime('syn-nodejs-puppeteer-5.1', RuntimeFamily.NODEJS); + /** + * `syn-nodejs-puppeteer-6.0` includes the following: + * - Lambda runtime Node.js 18.x + * - Puppeteer-core version 19.7.0 + * - Chromium version 111.0.5563.146 + * + * New Features: + * - **Dependency upgrade**: The Node.js dependency is upgraded to 18.x. + * Bug fixes: + * - **Bug fix**: Clean up core dump generated when Chromium crashes during a canary run. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-6.0 + */ + public static readonly SYNTHETICS_NODEJS_PUPPETEER_6_0 = new Runtime('syn-nodejs-puppeteer-6.0', RuntimeFamily.NODEJS); + /** * `syn-python-selenium-1.0` includes the following: * - Lambda runtime Python 3.8 diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 4923d252fa215..b9bdb4e10e224 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -749,7 +749,7 @@ describe('handler validation', () => { handler: 'invalidHandler', code: synthetics.Code.fromAsset(path.join(__dirname, 'canaries')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, }); }).toThrow(/Canary Handler must be specified either as 'fileName.handler', 'fileName.functionName', or 'folder\/fileName.functionName'/); @@ -759,7 +759,7 @@ describe('handler validation', () => { handler: 'canary.functionName', code: synthetics.Code.fromAsset(path.join(__dirname, 'canaries')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, }); }).not.toThrow(); @@ -769,7 +769,7 @@ describe('handler validation', () => { handler: 'folder/canary.functionName', code: synthetics.Code.fromAsset(path.join(__dirname, 'canaries')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_0, }); }).not.toThrow(); });