From 72aef8eebef8d70aba8cc48eee6290acb47f7fb9 Mon Sep 17 00:00:00 2001 From: SankyRed Date: Tue, 24 Jan 2023 16:18:06 -0600 Subject: [PATCH 1/4] Adding DeleteLambdaResourcesOnCanaryDeletion to the canary L2 --- .../@aws-cdk/aws-synthetics/lib/canary.ts | 10 ++ .../@aws-cdk/aws-synthetics/lib/runtime.ts | 54 ++++++++- .../aws-synthetics/test/canary.test.ts | 20 ++++ .../canary-one.assets.json | 6 +- .../canary-one.template.json | 15 +-- .../test/integ.canary.js.snapshot/cdk.out | 2 +- .../test/integ.canary.js.snapshot/integ.json | 2 +- .../integ.canary.js.snapshot/manifest.json | 16 +-- .../test/integ.canary.js.snapshot/tree.json | 103 +++++++++++++++--- .../aws-synthetics/test/integ.canary.ts | 13 ++- .../canary-vpc.assets.json | 6 +- .../canary-vpc.template.json | 2 +- .../test/integ.vpc.js.snapshot/cdk.out | 2 +- .../test/integ.vpc.js.snapshot/integ.json | 2 +- .../test/integ.vpc.js.snapshot/manifest.json | 16 +-- .../test/integ.vpc.js.snapshot/tree.json | 68 ++++++++---- .../@aws-cdk/aws-synthetics/test/integ.vpc.ts | 2 +- 17 files changed, 260 insertions(+), 79 deletions(-) diff --git a/packages/@aws-cdk/aws-synthetics/lib/canary.ts b/packages/@aws-cdk/aws-synthetics/lib/canary.ts index 717bfcbe6082d..43e450e7bb5ee 100644 --- a/packages/@aws-cdk/aws-synthetics/lib/canary.ts +++ b/packages/@aws-cdk/aws-synthetics/lib/canary.ts @@ -204,6 +204,15 @@ export interface CanaryProps { * not specified a dedicated security group will be created for this canary. */ readonly securityGroups?: ec2.ISecurityGroup[]; + + /** + * Whether or not the lambda resources are to be deleted when the canary is deleted + * + * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-deletelambdaresourcesoncanarydeletion + * + * @default false + */ + readonly deleteLambdaResourcesOnCanaryDeletion?: boolean; } /** @@ -281,6 +290,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { code: this.createCode(props), runConfig: this.createRunConfig(props), vpcConfig: this.createVpcConfig(props), + deleteLambdaResourcesOnCanaryDeletion: props.deleteLambdaResourcesOnCanaryDeletion, }); this.canaryId = resource.attrId; diff --git a/packages/@aws-cdk/aws-synthetics/lib/runtime.ts b/packages/@aws-cdk/aws-synthetics/lib/runtime.ts index 5e37368d2f80c..bab3b26d1e9a5 100644 --- a/packages/@aws-cdk/aws-synthetics/lib/runtime.ts +++ b/packages/@aws-cdk/aws-synthetics/lib/runtime.ts @@ -75,6 +75,8 @@ export class Runtime { public static readonly SYNTHETICS_NODEJS_2_2 = new Runtime('syn-nodejs-2.2', RuntimeFamily.NODEJS); /** + * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** + * * `syn-nodejs-puppeteer-3.0` includes the following: * - Lambda runtime Node.js 12.x * - Puppeteer-core version 5.5.0 @@ -85,6 +87,8 @@ export class Runtime { public static readonly SYNTHETICS_NODEJS_PUPPETEER_3_0 = new Runtime('syn-nodejs-puppeteer-3.0', RuntimeFamily.NODEJS); /** + * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** + * * `syn-nodejs-puppeteer-3.1` includes the following: * - Lambda runtime Node.js 12.x * - Puppeteer-core version 5.5.0 @@ -95,6 +99,8 @@ export class Runtime { public static readonly SYNTHETICS_NODEJS_PUPPETEER_3_1 = new Runtime('syn-nodejs-puppeteer-3.1', RuntimeFamily.NODEJS); /** + * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** + * * `syn-nodejs-puppeteer-3.2` includes the following: * - Lambda runtime Node.js 12.x * - Puppeteer-core version 5.5.0 @@ -106,6 +112,8 @@ export class Runtime { /** * `syn-nodejs-puppeteer-3.3` includes the following: + * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** + * * - Lambda runtime Node.js 12.x * - Puppeteer-core version 5.5.0 * - Chromium version 88.0.4298.0 @@ -115,6 +123,8 @@ export class Runtime { public static readonly SYNTHETICS_NODEJS_PUPPETEER_3_3 = new Runtime('syn-nodejs-puppeteer-3.3', RuntimeFamily.NODEJS); /** + * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** + * * `syn-nodejs-puppeteer-3.4` includes the following: * - Lambda runtime Node.js 12.x * - Puppeteer-core version 5.5.0 @@ -177,10 +187,52 @@ export class Runtime { * - Selenium version 3.141.0 * - Chromium version 83.0.4103.0 * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.0 */ public static readonly SYNTHETICS_PYTHON_SELENIUM_1_0 = new Runtime('syn-python-selenium-1.0', RuntimeFamily.PYTHON); + /** + * `syn-python-selenium-1.1` includes the following: + * - Lambda runtime Python 3.8 + * - Selenium version 3.141.0 + * - Chromium version 83.0.4103.0 + * + * New Features: + * - **Custom handler function**: You can now use a custom handler function for your canary scripts. + * - **Configuration options for adding metrics and step failure configurations**: These options were already available in runtimes for Node.js canaries. + * - **Custom arguments in Chrome**: You can now open a browser in incognito mode or pass in proxy server configuration. + * - **Cross-Region artifact buckets**: A canary can store its artifacts in an Amazon S3 bucket in a different Region. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.1 + */ + public static readonly SYNTHETICS_PYTHON_SELENIUM_1_1 = new Runtime('syn-python-selenium-1.1', RuntimeFamily.PYTHON); + + /** + * `syn-python-selenium-1.2` includes the following: + * - Lambda runtime Python 3.8 + * - Selenium version 3.141.0 + * - Chromium version 92.0.4512.0 + * + * New Features: + * - **Updated dependencies**: The only new features in this runtime are the updated dependencies. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.2 + */ + public static readonly SYNTHETICS_PYTHON_SELENIUM_1_2 = new Runtime('syn-python-selenium-1.2', RuntimeFamily.PYTHON); + + /** + * `syn-python-selenium-1.3` includes the following: + * - Lambda runtime Python 3.8 + * - Selenium version 3.141.0 + * - Chromium version 92.0.4512.0 + * + * New Features: + * - **More precise timestamps**: The start time and stop time of canary runs are now precise to the millisecond. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_python_selenium.html#CloudWatch_Synthetics_runtimeversion-syn-python-selenium-1.3 + */ + public static readonly SYNTHETICS_PYTHON_SELENIUM_1_3 = new Runtime('syn-python-selenium-1.3', RuntimeFamily.PYTHON); + /** * @param name The name of the runtime version * @param family The Lambda runtime family diff --git a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts index aee1ba78cd134..1fc860af3bbfb 100644 --- a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts +++ b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts @@ -34,6 +34,26 @@ test('Basic canary properties work', () => { }); }); +test('Canary deletion leads to lambda resource deletion property is set', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + new synthetics.Canary(stack, 'Canary', { + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code'), + }), + deleteLambdaResourcesOnCanaryDeletion: true, + runtime: synthetics.Runtime.SYNTHETICS_1_0, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Synthetics::Canary', { + DeleteLambdaResourcesOnCanaryDeletion: true, + }); +}); + test('Canary can have generated name', () => { // GIVEN const stack = new Stack(); diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.assets.json b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.assets.json index 63cb882a1205c..644bfda946bca 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.assets.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.assets.json @@ -1,5 +1,5 @@ { - "version": "21.0.0", + "version": "29.0.0", "files": { "9d00e437db1f5f8788ce938a3f00a9a1b946820e78c9b4c36207c8475db882bb": { "source": { @@ -27,7 +27,7 @@ } } }, - "32cb6cc1550e67ae5e77eb85a64192d2aa44c328b778079b139e3965fb042575": { + "4c74166545778fe2f895f948e7d6aec9c5427ffedc8ba02dcb70d5c2ea975967": { "source": { "path": "canary-one.template.json", "packaging": "file" @@ -35,7 +35,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "32cb6cc1550e67ae5e77eb85a64192d2aa44c328b778079b139e3965fb042575.json", + "objectKey": "4c74166545778fe2f895f948e7d6aec9c5427ffedc8ba02dcb70d5c2ea975967.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.template.json b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.template.json index 04fff7008b44f..482192cdc7a4b 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.template.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/canary-one.template.json @@ -129,7 +129,7 @@ ] }, "Name": "canary-integ", - "RuntimeVersion": "syn-nodejs-puppeteer-3.2", + "RuntimeVersion": "syn-nodejs-puppeteer-3.8", "Schedule": { "DurationInSeconds": "0", "Expression": "rate(1 minute)" @@ -326,12 +326,13 @@ ] }, "Name": "assetcanary-one", - "RuntimeVersion": "syn-nodejs-puppeteer-3.2", + "RuntimeVersion": "syn-nodejs-puppeteer-3.8", "Schedule": { "DurationInSeconds": "0", "Expression": "rate(5 minutes)" }, - "StartCanaryAfterCreation": true + "StartCanaryAfterCreation": true, + "DeleteLambdaResourcesOnCanaryDeletion": true } }, "MyCanaryTwoArtifactsBucket79B179B6": { @@ -523,7 +524,7 @@ ] }, "Name": "assetcanary-two", - "RuntimeVersion": "syn-nodejs-puppeteer-3.2", + "RuntimeVersion": "syn-nodejs-puppeteer-3.8", "Schedule": { "DurationInSeconds": "0", "Expression": "rate(5 minutes)" @@ -720,7 +721,7 @@ ] }, "Name": "assetcanary-three", - "RuntimeVersion": "syn-nodejs-puppeteer-3.3", + "RuntimeVersion": "syn-nodejs-puppeteer-3.8", "Schedule": { "DurationInSeconds": "0", "Expression": "rate(5 minutes)" @@ -917,7 +918,7 @@ ] }, "Name": "assetcanary-four", - "RuntimeVersion": "syn-nodejs-puppeteer-3.7", + "RuntimeVersion": "syn-nodejs-puppeteer-3.8", "Schedule": { "DurationInSeconds": "0", "Expression": "rate(5 minutes)" @@ -1311,7 +1312,7 @@ ] }, "Name": "py-canary-integ", - "RuntimeVersion": "syn-python-selenium-1.0", + "RuntimeVersion": "syn-python-selenium-1.3", "Schedule": { "DurationInSeconds": "0", "Expression": "rate(5 minutes)" diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/cdk.out b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/cdk.out index 8ecc185e9dbee..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"21.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/integ.json b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/integ.json index c8afc51228754..3f7c328bc7c87 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "21.0.0", + "version": "29.0.0", "testCases": { "integ.canary": { "stacks": [ diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/manifest.json b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/manifest.json index 1046b3ff32e7a..9227c8561fcef 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "21.0.0", + "version": "29.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "canary-one.assets": { "type": "cdk:asset-manifest", "properties": { @@ -23,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/32cb6cc1550e67ae5e77eb85a64192d2aa44c328b778079b139e3965fb042575.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/4c74166545778fe2f895f948e7d6aec9c5427ffedc8ba02dcb70d5c2ea975967.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -215,6 +209,12 @@ ] }, "displayName": "canary-one" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/tree.json b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/tree.json index cb9fa9d58d965..7a0cc4a4fb6a2 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.133" - } - }, "canary-one": { "id": "canary-one", "path": "canary-one", @@ -46,6 +38,14 @@ "id": "ServiceRole", "path": "canary-one/MyCanary/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-one/MyCanary/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-one/MyCanary/ServiceRole/Resource", @@ -187,7 +187,7 @@ ] }, "name": "canary-integ", - "runtimeVersion": "syn-nodejs-puppeteer-3.2", + "runtimeVersion": "syn-nodejs-puppeteer-3.8", "schedule": { "durationInSeconds": "0", "expression": "rate(1 minute)" @@ -311,6 +311,14 @@ "id": "ServiceRole", "path": "canary-one/MyCanaryOne/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-one/MyCanaryOne/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-one/MyCanaryOne/ServiceRole/Resource", @@ -480,12 +488,13 @@ ] }, "name": "assetcanary-one", - "runtimeVersion": "syn-nodejs-puppeteer-3.2", + "runtimeVersion": "syn-nodejs-puppeteer-3.8", "schedule": { "durationInSeconds": "0", "expression": "rate(5 minutes)" }, - "startCanaryAfterCreation": true + "startCanaryAfterCreation": true, + "deleteLambdaResourcesOnCanaryDeletion": true } }, "constructInfo": { @@ -604,6 +613,14 @@ "id": "ServiceRole", "path": "canary-one/MyCanaryTwo/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-one/MyCanaryTwo/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-one/MyCanaryTwo/ServiceRole/Resource", @@ -773,7 +790,7 @@ ] }, "name": "assetcanary-two", - "runtimeVersion": "syn-nodejs-puppeteer-3.2", + "runtimeVersion": "syn-nodejs-puppeteer-3.8", "schedule": { "durationInSeconds": "0", "expression": "rate(5 minutes)" @@ -897,6 +914,14 @@ "id": "ServiceRole", "path": "canary-one/MyCanaryThree/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-one/MyCanaryThree/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-one/MyCanaryThree/ServiceRole/Resource", @@ -1066,7 +1091,7 @@ ] }, "name": "assetcanary-three", - "runtimeVersion": "syn-nodejs-puppeteer-3.3", + "runtimeVersion": "syn-nodejs-puppeteer-3.8", "schedule": { "durationInSeconds": "0", "expression": "rate(5 minutes)" @@ -1190,6 +1215,14 @@ "id": "ServiceRole", "path": "canary-one/MyCanaryFour/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-one/MyCanaryFour/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-one/MyCanaryFour/ServiceRole/Resource", @@ -1359,7 +1392,7 @@ ] }, "name": "assetcanary-four", - "runtimeVersion": "syn-nodejs-puppeteer-3.7", + "runtimeVersion": "syn-nodejs-puppeteer-3.8", "schedule": { "durationInSeconds": "0", "expression": "rate(5 minutes)" @@ -1483,6 +1516,14 @@ "id": "ServiceRole", "path": "canary-one/MyCanaryRuntime38/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-one/MyCanaryRuntime38/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-one/MyCanaryRuntime38/ServiceRole/Resource", @@ -1776,6 +1817,14 @@ "id": "ServiceRole", "path": "canary-one/MyPythonCanary/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-one/MyPythonCanary/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-one/MyPythonCanary/ServiceRole/Resource", @@ -1945,7 +1994,7 @@ ] }, "name": "py-canary-integ", - "runtimeVersion": "syn-python-selenium-1.0", + "runtimeVersion": "syn-python-selenium-1.3", "schedule": { "durationInSeconds": "0", "expression": "rate(5 minutes)" @@ -1963,12 +2012,36 @@ "fqn": "@aws-cdk/aws-synthetics.Canary", "version": "0.0.0" } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "canary-one/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "canary-one/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } } }, "constructInfo": { "fqn": "@aws-cdk/core.Stack", "version": "0.0.0" } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.228" + } } }, "constructInfo": { diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts b/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts index bd5963acf77e6..41b08320d7a92 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts @@ -31,7 +31,7 @@ new synthetics.Canary(stack, 'MyCanary', { }), schedule: synthetics.Schedule.rate(cdk.Duration.minutes(1)), artifactsBucketLocation: { bucket, prefix }, - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); new synthetics.Canary(stack, 'MyCanaryOne', { @@ -40,7 +40,8 @@ new synthetics.Canary(stack, 'MyCanaryOne', { handler: 'canary.handler', code: synthetics.Code.fromAsset(path.join(__dirname, 'canaries')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, + deleteLambdaResourcesOnCanaryDeletion: true, }); new synthetics.Canary(stack, 'MyCanaryTwo', { @@ -49,7 +50,7 @@ new synthetics.Canary(stack, 'MyCanaryTwo', { handler: 'canary.handler', code: synthetics.Code.fromAsset(path.join(__dirname, 'canary.zip')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); new synthetics.Canary(stack, 'MyCanaryThree', { @@ -58,7 +59,7 @@ new synthetics.Canary(stack, 'MyCanaryThree', { handler: 'canary.handler', code: synthetics.Code.fromAsset(path.join(__dirname, 'canary.zip')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); new synthetics.Canary(stack, 'MyCanaryFour', { @@ -67,7 +68,7 @@ new synthetics.Canary(stack, 'MyCanaryFour', { handler: 'canary.handler', code: synthetics.Code.fromAsset(path.join(__dirname, 'canary.zip')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_7, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); new synthetics.Canary(stack, 'MyCanaryRuntime38', { @@ -85,7 +86,7 @@ new synthetics.Canary(stack, 'MyPythonCanary', { handler: 'canary.handler', code: synthetics.Code.fromAsset(path.join(__dirname, 'canaries')), }), - runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_1_0, + runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_1_3, }); app.synth(); diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.assets.json b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.assets.json index 8104e2eede73a..c051e5d4c08d3 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.assets.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.assets.json @@ -1,5 +1,5 @@ { - "version": "20.0.0", + "version": "29.0.0", "files": { "b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820": { "source": { @@ -14,7 +14,7 @@ } } }, - "896d92dcee7313e0e8795ccdf9dd8889e9bccf2acedeba42fefd3baea40ac43f": { + "23ae46d38257adb81b3c7df8b60995e221cb3db62f1042bb3d23df9ecbef0511": { "source": { "path": "canary-vpc.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "896d92dcee7313e0e8795ccdf9dd8889e9bccf2acedeba42fefd3baea40ac43f.json", + "objectKey": "23ae46d38257adb81b3c7df8b60995e221cb3db62f1042bb3d23df9ecbef0511.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.template.json b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.template.json index e904004bb4f39..d0124da724464 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.template.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.template.json @@ -610,7 +610,7 @@ ] }, "Name": "canary-vpc", - "RuntimeVersion": "syn-nodejs-puppeteer-3.3", + "RuntimeVersion": "syn-nodejs-puppeteer-3.8", "Schedule": { "DurationInSeconds": "0", "Expression": "rate(5 minutes)" diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/cdk.out b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/cdk.out index 588d7b269d34f..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"20.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/integ.json b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/integ.json index 630998e9b1b46..52cc3944c7f58 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "20.0.0", + "version": "29.0.0", "testCases": { "integ.vpc": { "stacks": [ diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/manifest.json b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/manifest.json index 55c71082ee3b2..9d34dcff3ea6c 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/manifest.json @@ -1,12 +1,6 @@ { - "version": "20.0.0", + "version": "29.0.0", "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, "canary-vpc.assets": { "type": "cdk:asset-manifest", "properties": { @@ -23,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/896d92dcee7313e0e8795ccdf9dd8889e9bccf2acedeba42fefd3baea40ac43f.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/23ae46d38257adb81b3c7df8b60995e221cb3db62f1042bb3d23df9ecbef0511.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -221,6 +215,12 @@ ] }, "displayName": "canary-vpc" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/tree.json b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/tree.json index a266c69b0bfb9..485c5796bc915 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.js.snapshot/tree.json @@ -4,14 +4,6 @@ "id": "App", "path": "", "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" - } - }, "canary-vpc": { "id": "canary-vpc", "path": "canary-vpc", @@ -91,8 +83,8 @@ "id": "Acl", "path": "canary-vpc/MyVpc/PublicSubnet1/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -258,8 +250,8 @@ "id": "Acl", "path": "canary-vpc/MyVpc/PublicSubnet2/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -425,8 +417,8 @@ "id": "Acl", "path": "canary-vpc/MyVpc/PrivateSubnet1/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -544,8 +536,8 @@ "id": "Acl", "path": "canary-vpc/MyVpc/PrivateSubnet2/Acl", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" } }, "RouteTable": { @@ -764,6 +756,14 @@ "id": "ServiceRole", "path": "canary-vpc/MyVpcCanary/ServiceRole", "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "canary-vpc/MyVpcCanary/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", "path": "canary-vpc/MyVpcCanary/ServiceRole/Resource", @@ -898,8 +898,8 @@ "id": "Stage", "path": "canary-vpc/MyVpcCanary/Code/Stage", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.AssetStaging", + "version": "0.0.0" } }, "AssetBucket": { @@ -981,7 +981,7 @@ ] }, "name": "canary-vpc", - "runtimeVersion": "syn-nodejs-puppeteer-3.3", + "runtimeVersion": "syn-nodejs-puppeteer-3.8", "schedule": { "durationInSeconds": "0", "expression": "rate(5 minutes)" @@ -1020,17 +1020,41 @@ "fqn": "@aws-cdk/aws-synthetics.Canary", "version": "0.0.0" } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "canary-vpc/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "canary-vpc/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } } }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.85" + "version": "10.1.228" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.1.85" + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.ts b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.ts index e31f75817e68b..2d2d57aaae2f4 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.vpc.ts +++ b/packages/@aws-cdk/aws-synthetics/test/integ.vpc.ts @@ -22,7 +22,7 @@ new synthetics.Canary(stack, 'MyVpcCanary', { handler: 'canary.handler', code: synthetics.Code.fromAsset(path.join(__dirname, 'canary.zip')), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, vpc, }); From 24f070f78236f63f4b9a784ccafde2bebf82f64a Mon Sep 17 00:00:00 2001 From: SankyRed Date: Wed, 25 Jan 2023 11:18:38 -0600 Subject: [PATCH 2/4] Updating the readme and updating the runtime versions to latest available --- packages/@aws-cdk/aws-synthetics/README.md | 21 +++++++ .../@aws-cdk/aws-synthetics/lib/canary.ts | 2 +- .../aws-synthetics/test/canary.test.ts | 60 +++++++++---------- .../@aws-cdk/aws-synthetics/test/code.test.ts | 8 +-- .../aws-synthetics/test/metric.test.ts | 4 +- 5 files changed, 58 insertions(+), 37 deletions(-) diff --git a/packages/@aws-cdk/aws-synthetics/README.md b/packages/@aws-cdk/aws-synthetics/README.md index 09c771a1e5215..045f03c4feda7 100644 --- a/packages/@aws-cdk/aws-synthetics/README.md +++ b/packages/@aws-cdk/aws-synthetics/README.md @@ -110,6 +110,27 @@ const schedule = synthetics.Schedule.cron({ If you want the canary to run just once upon deployment, you can use `Schedule.once()`. + +### Canary DeleteLambdaResourcesOnCanaryDeletion + +You can specify whether the AWS CloudFormation is to also delete the Lambda functions and layers used by this canary, when the canary is deleted. + +This can be provisioned by setting the `DeleteLambdaResourcesOnCanaryDeletion` property to `true` when we define the canary. + +```ts +const canary = new synthetics.Canary(stack, 'Canary', { + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code'), + }), + deleteLambdaResourcesOnCanaryDeletion: true, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, +}); +``` + +Even when set to `true` there are resources such as S3 buckets/logs that do NOT get deleted and are to be deleted manually. + + ### Configuring the Canary Script To configure the script the canary executes, use the `test` property. The `test` property accepts a `Test` instance that can be initialized by the `Test` class static methods. Currently, the only implemented method is `Test.custom()`, which allows you to bring your own code. In the future, other methods will be added. `Test.custom()` accepts `code` and `handler` properties -- both are required by Synthetics to create a lambda function on your behalf. diff --git a/packages/@aws-cdk/aws-synthetics/lib/canary.ts b/packages/@aws-cdk/aws-synthetics/lib/canary.ts index 43e450e7bb5ee..99060c1a885bc 100644 --- a/packages/@aws-cdk/aws-synthetics/lib/canary.ts +++ b/packages/@aws-cdk/aws-synthetics/lib/canary.ts @@ -206,7 +206,7 @@ export interface CanaryProps { readonly securityGroups?: ec2.ISecurityGroup[]; /** - * Whether or not the lambda resources are to be deleted when the canary is deleted + * Whether or not to delete the lambda resources when the canary is deleted * * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-deletelambdaresourcesoncanarydeletion * diff --git a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts index 1fc860af3bbfb..c283318296617 100644 --- a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts +++ b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts @@ -20,7 +20,7 @@ test('Basic canary properties work', () => { failureRetentionPeriod: Duration.days(10), startAfterCreation: false, timeToLive: Duration.minutes(30), - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -30,11 +30,11 @@ test('Basic canary properties work', () => { FailureRetentionPeriod: 10, StartCanaryAfterCreation: false, Schedule: Match.objectLike({ DurationInSeconds: '1800' }), - RuntimeVersion: 'syn-1.0', + RuntimeVersion: 'syn-nodejs-puppeteer-3.8', }); }); -test('Canary deletion leads to lambda resource deletion property is set', () => { +test('Can set `DeleteLambdaResourceOnCanaryDeletion`', () => { // GIVEN const stack = new Stack(); @@ -45,7 +45,7 @@ test('Canary deletion leads to lambda resource deletion property is set', () => code: synthetics.Code.fromInline('/* Synthetics handler code'), }), deleteLambdaResourcesOnCanaryDeletion: true, - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -64,7 +64,7 @@ test('Canary can have generated name', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_1, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -84,7 +84,7 @@ test('Name validation does not fail when using Tokens', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN: no exception @@ -102,7 +102,7 @@ test('Throws when name is specified incorrectly', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, })) .toThrowError('Canary name must be lowercase, numbers, hyphens, or underscores (got "My Canary")'); }); @@ -118,7 +118,7 @@ test('Throws when name has more than 21 characters', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, })) .toThrowError(`Canary name is too large, must be between 1 and 21 characters, but is 22 (got "${'a'.repeat(22)}")`); }); @@ -140,7 +140,7 @@ test('An existing role can be specified instead of auto-created', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -162,7 +162,7 @@ test('An existing bucket and prefix can be specified instead of auto-created', ( handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -177,7 +177,7 @@ test('Runtime can be specified', () => { // WHEN new synthetics.Canary(stack, 'Canary', { - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, test: synthetics.Test.custom({ handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), @@ -186,7 +186,7 @@ test('Runtime can be specified', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Synthetics::Canary', { - RuntimeVersion: 'syn-1.0', + RuntimeVersion: 'syn-nodejs-puppeteer-3.8', }); }); @@ -196,7 +196,7 @@ test('Python runtime can be specified', () => { // WHEN new synthetics.Canary(stack, 'Canary', { - runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_1_0, + runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_1_3, test: synthetics.Test.custom({ handler: 'index.handler', code: synthetics.Code.fromInline('# Synthetics handler code'), @@ -205,7 +205,7 @@ test('Python runtime can be specified', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Synthetics::Canary', { - RuntimeVersion: 'syn-python-selenium-1.0', + RuntimeVersion: 'syn-python-selenium-1.3', }); }); @@ -219,7 +219,7 @@ test('environment variables can be specified', () => { // WHEN new synthetics.Canary(stack, 'Canary', { - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, test: synthetics.Test.custom({ handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), @@ -241,7 +241,7 @@ test('environment variables are skipped if not provided', () => { // WHEN new synthetics.Canary(stack, 'Canary', { - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, test: synthetics.Test.custom({ handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), @@ -284,7 +284,7 @@ test('Schedule can be set with Rate', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_1_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -304,7 +304,7 @@ test('Schedule can be set to 1 minute', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -324,7 +324,7 @@ test('Schedule can be set with Cron', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -345,7 +345,7 @@ test('Schedule can be set with Expression', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -365,7 +365,7 @@ test('Schedule can be set to run once', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -385,7 +385,7 @@ test('Throws when rate above 60 minutes', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, })) .toThrowError('Schedule duration must be between 1 and 60 minutes'); }); @@ -401,7 +401,7 @@ test('Throws when rate above is not a whole number of minutes', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, })) .toThrowError('\'59 seconds\' cannot be converted into a whole number of minutes.'); }); @@ -417,7 +417,7 @@ test('Can share artifacts bucket between canaries', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); const canary2 = new synthetics.Canary(stack, 'Canary2', { @@ -427,7 +427,7 @@ test('Can share artifacts bucket between canaries', () => { code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), artifactsBucketLocation: { bucket: canary1.artifactsBucket }, - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -447,7 +447,7 @@ test('can specify custom test', () => { console.log(\'hello world\'); };`), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -477,7 +477,7 @@ describe('canary in a vpc', () => { console.log(\'hello world\'); };`), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, vpc, }); @@ -512,7 +512,7 @@ describe('canary in a vpc', () => { console.log(\'hello world\'); };`), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, vpc, }); @@ -550,7 +550,7 @@ describe('canary in a vpc', () => { console.log(\'hello world\'); };`), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, vpc, securityGroups: [sg], }); @@ -590,7 +590,7 @@ test('Role policy generated as expected', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code */'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN diff --git a/packages/@aws-cdk/aws-synthetics/test/code.test.ts b/packages/@aws-cdk/aws-synthetics/test/code.test.ts index eb5e7d71ac330..316ae6dc5ccfc 100644 --- a/packages/@aws-cdk/aws-synthetics/test/code.test.ts +++ b/packages/@aws-cdk/aws-synthetics/test/code.test.ts @@ -51,7 +51,7 @@ describe(synthetics.Code.fromAsset, () => { handler: 'canary.handler', code: directoryAsset, }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN @@ -75,7 +75,7 @@ describe(synthetics.Code.fromAsset, () => { handler: 'canary.handler', code: directoryAsset, }), - runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_1_0, + runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_1_3, }); // THEN @@ -104,7 +104,7 @@ describe(synthetics.Code.fromAsset, () => { handler: 'canary.handler', code: directoryAsset, }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); new synthetics.Canary(stack, 'Canary2', { @@ -112,7 +112,7 @@ describe(synthetics.Code.fromAsset, () => { handler: 'canary.handler', code: directoryAsset, }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // THEN diff --git a/packages/@aws-cdk/aws-synthetics/test/metric.test.ts b/packages/@aws-cdk/aws-synthetics/test/metric.test.ts index 6b15dd156babd..767ab484e56f9 100644 --- a/packages/@aws-cdk/aws-synthetics/test/metric.test.ts +++ b/packages/@aws-cdk/aws-synthetics/test/metric.test.ts @@ -10,7 +10,7 @@ test('.metricXxx() methods can be used to obtain Metrics for the canary', () => handler: 'index.handler', code: synthetics.Code.fromInline('foo'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // WHEN @@ -50,7 +50,7 @@ test('Metric can specify statistic', () => { handler: 'index.handler', code: synthetics.Code.fromInline('foo'), }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_2_0, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); // WHEN From 1759976e3426279f379d1f16f70acf50e09e31a3 Mon Sep 17 00:00:00 2001 From: SankyRed Date: Wed, 25 Jan 2023 14:17:29 -0600 Subject: [PATCH 3/4] Fixing up the codebuild issue related to jsii-rosetta --- packages/@aws-cdk/aws-synthetics/README.md | 2 ++ packages/@aws-cdk/aws-synthetics/lib/canary.ts | 4 ++-- packages/@aws-cdk/aws-synthetics/test/canary.test.ts | 2 +- packages/@aws-cdk/aws-synthetics/test/integ.canary.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-synthetics/README.md b/packages/@aws-cdk/aws-synthetics/README.md index 045f03c4feda7..753b205aad8de 100644 --- a/packages/@aws-cdk/aws-synthetics/README.md +++ b/packages/@aws-cdk/aws-synthetics/README.md @@ -118,6 +118,8 @@ You can specify whether the AWS CloudFormation is to also delete the Lambda func This can be provisioned by setting the `DeleteLambdaResourcesOnCanaryDeletion` property to `true` when we define the canary. ```ts +const stack = new Stack(); + const canary = new synthetics.Canary(stack, 'Canary', { test: synthetics.Test.custom({ handler: 'index.handler', diff --git a/packages/@aws-cdk/aws-synthetics/lib/canary.ts b/packages/@aws-cdk/aws-synthetics/lib/canary.ts index 99060c1a885bc..cb5a043eb2858 100644 --- a/packages/@aws-cdk/aws-synthetics/lib/canary.ts +++ b/packages/@aws-cdk/aws-synthetics/lib/canary.ts @@ -212,7 +212,7 @@ export interface CanaryProps { * * @default false */ - readonly deleteLambdaResourcesOnCanaryDeletion?: boolean; + readonly enableAutoDeleteLambdas?: boolean; } /** @@ -290,7 +290,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { code: this.createCode(props), runConfig: this.createRunConfig(props), vpcConfig: this.createVpcConfig(props), - deleteLambdaResourcesOnCanaryDeletion: props.deleteLambdaResourcesOnCanaryDeletion, + deleteLambdaResourcesOnCanaryDeletion: props.enableAutoDeleteLambdas, }); this.canaryId = resource.attrId; diff --git a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts index c283318296617..891aee2a40baf 100644 --- a/packages/@aws-cdk/aws-synthetics/test/canary.test.ts +++ b/packages/@aws-cdk/aws-synthetics/test/canary.test.ts @@ -44,7 +44,7 @@ test('Can set `DeleteLambdaResourceOnCanaryDeletion`', () => { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code'), }), - deleteLambdaResourcesOnCanaryDeletion: true, + enableAutoDeleteLambdas: true, runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); diff --git a/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts b/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts index 41b08320d7a92..515aafabad993 100644 --- a/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts +++ b/packages/@aws-cdk/aws-synthetics/test/integ.canary.ts @@ -41,7 +41,7 @@ new synthetics.Canary(stack, 'MyCanaryOne', { code: synthetics.Code.fromAsset(path.join(__dirname, 'canaries')), }), runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, - deleteLambdaResourcesOnCanaryDeletion: true, + enableAutoDeleteLambdas: true, }); new synthetics.Canary(stack, 'MyCanaryTwo', { From 6732e58cc6ce68c789b1cf84163323e9dbce1539 Mon Sep 17 00:00:00 2001 From: SankyRed Date: Wed, 25 Jan 2023 15:00:58 -0600 Subject: [PATCH 4/4] Cleaning out the readme --- packages/@aws-cdk/aws-synthetics/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-synthetics/README.md b/packages/@aws-cdk/aws-synthetics/README.md index 753b205aad8de..d20a24688e8ec 100644 --- a/packages/@aws-cdk/aws-synthetics/README.md +++ b/packages/@aws-cdk/aws-synthetics/README.md @@ -125,7 +125,7 @@ const canary = new synthetics.Canary(stack, 'Canary', { handler: 'index.handler', code: synthetics.Code.fromInline('/* Synthetics handler code'), }), - deleteLambdaResourcesOnCanaryDeletion: true, + enableAutoDeleteLambdas: true, runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_8, }); ```