From 044b57c2065f1b864773dc61c5eb4adb21326e52 Mon Sep 17 00:00:00 2001 From: AWS CDK Team Date: Tue, 26 Sep 2023 13:24:20 +0000 Subject: [PATCH 1/6] chore(release): 2.98.0 --- CHANGELOG.v2.alpha.md | 7 +++ CHANGELOG.v2.md | 18 +++++++ packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md | 53 ++++++++++---------- packages/aws-cdk-lib/cx-api/lib/features.ts | 2 +- version.v2.json | 4 +- 5 files changed, 55 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.v2.alpha.md b/CHANGELOG.v2.alpha.md index 9371476197d49..f9d9b41f8c12e 100644 --- a/CHANGELOG.v2.alpha.md +++ b/CHANGELOG.v2.alpha.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.98.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.97.1-alpha.0...v2.98.0-alpha.0) (2023-09-26) + + +### Features + +* **scheduler:** disable Schedule on creation ([#27236](https://github.com/aws/aws-cdk/issues/27236)) ([193cd3f](https://github.com/aws/aws-cdk/commit/193cd3f575974e4058fcec957640a3d28d114fd1)) + ## [2.97.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.97.0-alpha.0...v2.97.1-alpha.0) (2023-09-25) ## [2.97.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.96.2-alpha.0...v2.97.0-alpha.0) (2023-09-22) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index eea568c5c58c0..fa75e4c26ba1c 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -2,6 +2,24 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.98.0](https://github.com/aws/aws-cdk/compare/v2.97.1...v2.98.0) (2023-09-26) + + +### Features + +* update AWS Service Spec ([#27276](https://github.com/aws/aws-cdk/issues/27276)) ([3d9ca8d](https://github.com/aws/aws-cdk/commit/3d9ca8dad29e6e6f813ab2340da7639c24ba5494)) +* **aws-cdk-lib:** reduce load time of JavaScript library ([#27217](https://github.com/aws/aws-cdk/issues/27217)) ([faffce0](https://github.com/aws/aws-cdk/commit/faffce06c3f1d543600f7e8dc430a5105c73ac5a)) + + +### Bug Fixes + +* **rds:** prevent rendering deprecated credentials when creating a database cluster from a snapshot (under feature flag) ([#27174](https://github.com/aws/aws-cdk/issues/27174)) ([1fd22a7](https://github.com/aws/aws-cdk/commit/1fd22a7498223ae5d2faf1799056e81be4f71f5c)), closes [#23815](https://github.com/aws/aws-cdk/issues/23815) + + +### Reverts + +* "feat(core): `Schedule` class" ([#27284](https://github.com/aws/aws-cdk/issues/27284)) ([252d9ba](https://github.com/aws/aws-cdk/commit/252d9bad024497e096de4def2abff329214f5294)), closes [aws/aws-cdk#27105](https://github.com/aws/aws-cdk/issues/27105) [#27259](https://github.com/aws/aws-cdk/issues/27259) + ## [2.97.1](https://github.com/aws/aws-cdk/compare/v2.97.0...v2.97.1) (2023-09-25) diff --git a/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md b/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md index a4af49626f5a3..c410cfc629cc9 100644 --- a/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +++ b/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md @@ -59,9 +59,9 @@ Flags come in three types: | [@aws-cdk/aws-efs:denyAnonymousAccess](#aws-cdkaws-efsdenyanonymousaccess) | EFS denies anonymous clients accesses | 2.93.0 | (default) | | [@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId](#aws-cdkaws-efsmounttargetorderinsensitivelogicalid) | When enabled, mount targets will have a stable logicalId that is linked to the associated subnet. | 2.93.0 | (fix) | | [@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion](#aws-cdkaws-lambda-nodejsuselatestruntimeversion) | Enables aws-lambda-nodejs.Function to use the latest available NodeJs runtime as the default | 2.93.0 | (default) | -| [@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials](#aws-cdkaws-rdspreventrenderingdeprecatedcredentials) | When enabled, creating an RDS database cluster from a snapshot will only render credentials for snapshot credentials. | V2NEXT | (fix) | | [@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier](#aws-cdkaws-appsyncusearnforsourceapiassociationidentifier) | When enabled, will always use the arn for identifiers for CfnSourceApiAssociation in the GraphqlApi construct rather than id. | 2.97.0 | (fix) | | [@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters](#aws-cdkaws-rdsauroraclusterchangescopeofinstanceparametergroupwitheachparameters) | When enabled, a scope of InstanceParameterGroup for AuroraClusterInstance with each parameters will change. | 2.97.0 | (fix) | +| [@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials](#aws-cdkaws-rdspreventrenderingdeprecatedcredentials) | When enabled, creating an RDS database cluster from a snapshot will only render credentials for snapshot credentials. | 2.98.0 | (fix) | @@ -112,9 +112,9 @@ The following json shows the current recommended set of flags, as `cdk init` wou "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true, "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true, "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true, - "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true, - "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true + "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true, + "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true } } ``` @@ -1119,29 +1119,6 @@ shipped as part of the runtime environment. **Compatibility with old behavior:** Pass `runtime: lambda.Runtime.NODEJS_16_X` to `Function` construct to restore the previous behavior. -### @aws-cdk/aws-rds:preventRenderingDeprecatedCredentials - -*When enabled, creating an RDS database cluster from a snapshot will only render credentials for snapshot credentials.* (fix) - -The `credentials` property on the `DatabaseClusterFromSnapshotProps` -interface was deprecated with the new `snapshotCredentials` property being -recommended. Before deprecating `credentials`, a secret would be generated -while rendering credentials if the `credentials` property was undefined or -if a secret wasn't provided via the `credentials` property. This behavior -is replicated with the new `snapshotCredentials` property, but the original -`credentials` secret can still be created resulting in an extra database -secret. - -Set this flag to prevent rendering deprecated `credentials` and creating an -extra database secret when only using `snapshotCredentials` to create an RDS -database cluster from a snapshot. - -| Since | Default | Recommended | -| ----- | ----- | ----- | -| (not in v1) | | | -| V2NEXT | `false` | `true` | - - ### @aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier *When enabled, will always use the arn for identifiers for CfnSourceApiAssociation in the GraphqlApi construct rather than id.* (fix) @@ -1175,4 +1152,28 @@ with each `InstanceParameterGroup` in the AuroraCluster. | 2.97.0 | `false` | `true` | +### @aws-cdk/aws-rds:preventRenderingDeprecatedCredentials + +*When enabled, creating an RDS database cluster from a snapshot will only render credentials for snapshot credentials.* (fix) + +The `credentials` property on the `DatabaseClusterFromSnapshotProps` +interface was deprecated with the new `snapshotCredentials` property being +recommended. Before deprecating `credentials`, a secret would be generated +while rendering credentials if the `credentials` property was undefined or +if a secret wasn't provided via the `credentials` property. This behavior +is replicated with the new `snapshotCredentials` property, but the original +`credentials` secret can still be created resulting in an extra database +secret. + +Set this flag to prevent rendering deprecated `credentials` and creating an +extra database secret when only using `snapshotCredentials` to create an RDS +database cluster from a snapshot. + + +| Since | Default | Recommended | +| ----- | ----- | ----- | +| (not in v1) | | | +| 2.98.0 | `false` | `true` | + + diff --git a/packages/aws-cdk-lib/cx-api/lib/features.ts b/packages/aws-cdk-lib/cx-api/lib/features.ts index ee273c772e0e4..6f494410f4dbd 100644 --- a/packages/aws-cdk-lib/cx-api/lib/features.ts +++ b/packages/aws-cdk-lib/cx-api/lib/features.ts @@ -959,7 +959,7 @@ export const FLAGS: Record = { extra database secret when only using \`snapshotCredentials\` to create an RDS database cluster from a snapshot. `, - introducedIn: { v2: 'V2NEXT' }, + introducedIn: { v2: '2.98.0' }, recommendedValue: true, }, }; diff --git a/version.v2.json b/version.v2.json index bd0b35d852ac7..805b98c1cbfcf 100644 --- a/version.v2.json +++ b/version.v2.json @@ -1,4 +1,4 @@ { - "version": "2.97.1", - "alphaVersion": "2.97.1-alpha.0" + "version": "2.98.0", + "alphaVersion": "2.98.0-alpha.0" } \ No newline at end of file From e12f8ed74a8df418d18add2976761590d870b608 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Tue, 26 Sep 2023 09:55:26 -0400 Subject: [PATCH 2/6] Update CHANGELOG.v2.md --- CHANGELOG.v2.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CHANGELOG.v2.md b/CHANGELOG.v2.md index fa75e4c26ba1c..8108831acc062 100644 --- a/CHANGELOG.v2.md +++ b/CHANGELOG.v2.md @@ -15,11 +15,6 @@ All notable changes to this project will be documented in this file. See [standa * **rds:** prevent rendering deprecated credentials when creating a database cluster from a snapshot (under feature flag) ([#27174](https://github.com/aws/aws-cdk/issues/27174)) ([1fd22a7](https://github.com/aws/aws-cdk/commit/1fd22a7498223ae5d2faf1799056e81be4f71f5c)), closes [#23815](https://github.com/aws/aws-cdk/issues/23815) - -### Reverts - -* "feat(core): `Schedule` class" ([#27284](https://github.com/aws/aws-cdk/issues/27284)) ([252d9ba](https://github.com/aws/aws-cdk/commit/252d9bad024497e096de4def2abff329214f5294)), closes [aws/aws-cdk#27105](https://github.com/aws/aws-cdk/issues/27105) [#27259](https://github.com/aws/aws-cdk/issues/27259) - ## [2.97.1](https://github.com/aws/aws-cdk/compare/v2.97.0...v2.97.1) (2023-09-25) From 9312c9763813af4ac6d2be96e78f6aeaefeeb32c Mon Sep 17 00:00:00 2001 From: Jane Chen <125300057+chenjane-dev@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:59:17 -0400 Subject: [PATCH 3/6] fix(appconfig): allow multiple environment monitor roles to be created (#27243) Currently, when adding multiple monitors under an environment, users are seeing the following error ``` Error: There is already a Construct with name 'Role' in Environment [MyEnvironment] ``` Before the logical id for any monitor role that is created was just `Role`. In this change, we use the monitor index in the logical id so there aren't any repeats in logical id's. This is also why there is a change in the integ test snapshot, since the logical id was refactored. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-appconfig-alpha/lib/environment.ts | 8 +- .../test/environment.test.ts | 76 ++++++++++++++++++- ...efaultTestDeployAssert75BD28E7.assets.json | 2 +- .../aws-appconfig-environment.assets.json | 6 +- .../aws-appconfig-environment.template.json | 4 +- .../integ.environment.js.snapshot/cdk.out | 2 +- .../integ.environment.js.snapshot/integ.json | 2 +- .../manifest.json | 8 +- .../integ.environment.js.snapshot/tree.json | 24 +++--- 9 files changed, 103 insertions(+), 29 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts index cd59cfa4265a5..fdcd7a29d92b6 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts @@ -236,10 +236,10 @@ export class Environment extends EnvironmentBase { applicationId: this.applicationId, name: this.name, description: this.description, - monitors: this.monitors?.map((monitor) => { + monitors: this.monitors?.map((monitor, index) => { return { alarmArn: monitor.alarm.alarmArn, - alarmRoleArn: monitor.alarmRole?.roleArn || this.createAlarmRole(monitor.alarm.alarmArn).roleArn, + alarmRoleArn: monitor.alarmRole?.roleArn || this.createAlarmRole(monitor.alarm.alarmArn, index).roleArn, }; }), }); @@ -256,7 +256,7 @@ export class Environment extends EnvironmentBase { this.application.addExistingEnvironment(this); } - private createAlarmRole(alarmArn: string): iam.IRole { + private createAlarmRole(alarmArn: string, index: number): iam.IRole { const policy = new iam.PolicyStatement({ effect: iam.Effect.ALLOW, actions: ['cloudwatch:DescribeAlarms'], @@ -265,7 +265,7 @@ export class Environment extends EnvironmentBase { const document = new iam.PolicyDocument({ statements: [policy], }); - const role = new iam.Role(this, 'Role', { + const role = new iam.Role(this, `Role${index}`, { roleName: PhysicalName.GENERATE_IF_NEEDED, assumedBy: new iam.ServicePrincipal('appconfig.amazonaws.com'), inlinePolicies: { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts b/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts index e0950fa0ed564..ffb8c092fa820 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts @@ -147,7 +147,7 @@ describe('environment', () => { }, AlarmRoleArn: { 'Fn::GetAtt': [ - 'MyEnvironmentRoleC08961D3', + 'MyEnvironmentRole01C8C013F', 'Arn', ], }, @@ -177,6 +177,80 @@ describe('environment', () => { }); }); + test('environment with monitors with two alarms', () => { + const stack = new cdk.Stack(); + const app = new Application(stack, 'MyAppConfig'); + new Environment(stack, 'MyEnvironment', { + name: 'TestEnv', + application: app, + monitors: [ + { + alarm: new Alarm(stack, 'Alarm1', { + threshold: 5, + evaluationPeriods: 5, + metric: new Metric( + { + namespace: 'aws', + metricName: 'myMetric', + }, + ), + }), + }, + { + alarm: new Alarm(stack, 'Alarm2', { + threshold: 5, + evaluationPeriods: 5, + metric: new Metric( + { + namespace: 'aws', + metricName: 'myMetric', + }, + ), + }), + }, + ], + }); + + Template.fromStack(stack).resourceCountIs('AWS::CloudWatch::Alarm', 2); + Template.fromStack(stack).resourceCountIs('AWS::IAM::Role', 2); + Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Environment', { + Name: 'TestEnv', + ApplicationId: { + Ref: 'MyAppConfigB4B63E75', + }, + Monitors: [ + { + AlarmArn: { + 'Fn::GetAtt': [ + 'Alarm1F9009D71', + 'Arn', + ], + }, + AlarmRoleArn: { + 'Fn::GetAtt': [ + 'MyEnvironmentRole01C8C013F', + 'Arn', + ], + }, + }, + { + AlarmArn: { + 'Fn::GetAtt': [ + 'Alarm2A7122E13', + 'Arn', + ], + }, + AlarmRoleArn: { + 'Fn::GetAtt': [ + 'MyEnvironmentRole135A2CEE4', + 'Arn', + ], + }, + }, + ], + }); + }); + test('from environment arn', () => { const stack = new cdk.Stack(); const env = Environment.fromEnvironmentArn(stack, 'MyEnvironment', diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json index e7f9aca08607f..49f0e48e091a4 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/appconfigenvironmentDefaultTestDeployAssert75BD28E7.assets.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "34.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json index 30512d7b22c0b..8a91333b6e2d2 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.assets.json @@ -1,7 +1,7 @@ { - "version": "32.0.0", + "version": "34.0.0", "files": { - "5a83c94c795349286c703ba61add79efe69c74c7adb8de98527fcf034b9683af": { + "c5abc7ef2e341477218fc19664c82ee2ea13e9509f2deaae6fc6200a619a5d1c": { "source": { "path": "aws-appconfig-environment.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "5a83c94c795349286c703ba61add79efe69c74c7adb8de98527fcf034b9683af.json", + "objectKey": "c5abc7ef2e341477218fc19664c82ee2ea13e9509f2deaae6fc6200a619a5d1c.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-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json index 78b08f894831d..e120019dcabe1 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/aws-appconfig-environment.template.json @@ -18,7 +18,7 @@ "Threshold": 10 } }, - "MyEnvironmentRoleC08961D3": { + "MyEnvironmentRole01C8C013F": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -72,7 +72,7 @@ }, "AlarmRoleArn": { "Fn::GetAtt": [ - "MyEnvironmentRoleC08961D3", + "MyEnvironmentRole01C8C013F", "Arn" ] } diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out index f0b901e7c06e5..2313ab5436501 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"32.0.0"} \ No newline at end of file +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json index 4d4d0f1d20168..a9ffb18c9ba71 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "34.0.0", "testCases": { "appconfig-environment/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json index 0749986d2339c..6f758fc4db657 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "34.0.0", "artifacts": { "aws-appconfig-environment.assets": { "type": "cdk:asset-manifest", @@ -17,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}/5a83c94c795349286c703ba61add79efe69c74c7adb8de98527fcf034b9683af.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c5abc7ef2e341477218fc19664c82ee2ea13e9509f2deaae6fc6200a619a5d1c.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -45,10 +45,10 @@ "data": "MyAlarm696658B6" } ], - "/aws-appconfig-environment/MyEnvironment/Role/Resource": [ + "/aws-appconfig-environment/MyEnvironment/Role0/Resource": [ { "type": "aws:cdk:logicalId", - "data": "MyEnvironmentRoleC08961D3" + "data": "MyEnvironmentRole01C8C013F" } ], "/aws-appconfig-environment/MyEnvironment/Resource": [ diff --git a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json index f094a53e8edb1..730c4e7fb0302 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-appconfig-alpha/test/integ.environment.js.snapshot/tree.json @@ -28,7 +28,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Application", "version": "0.0.0" } }, @@ -66,13 +66,13 @@ "id": "MyEnvironment", "path": "aws-appconfig-environment/MyEnvironment", "children": { - "Role": { - "id": "Role", - "path": "aws-appconfig-environment/MyEnvironment/Role", + "Role0": { + "id": "Role0", + "path": "aws-appconfig-environment/MyEnvironment/Role0", "children": { - "ImportRole": { - "id": "ImportRole", - "path": "aws-appconfig-environment/MyEnvironment/Role/ImportRole", + "ImportRole0": { + "id": "ImportRole0", + "path": "aws-appconfig-environment/MyEnvironment/Role0/ImportRole0", "constructInfo": { "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" @@ -80,7 +80,7 @@ }, "Resource": { "id": "Resource", - "path": "aws-appconfig-environment/MyEnvironment/Role/Resource", + "path": "aws-appconfig-environment/MyEnvironment/Role0/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::IAM::Role", "aws:cdk:cloudformation:props": { @@ -149,7 +149,7 @@ }, "alarmRoleArn": { "Fn::GetAtt": [ - "MyEnvironmentRoleC08961D3", + "MyEnvironmentRole01C8C013F", "Arn" ] } @@ -165,7 +165,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.Resource", + "fqn": "@aws-cdk/aws-appconfig-alpha.Environment", "version": "0.0.0" } }, @@ -204,7 +204,7 @@ "path": "appconfig-environment/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } }, "DeployAssert": { @@ -250,7 +250,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } } }, From 6616026d3879f0271b7813ed00f0899c666da1e3 Mon Sep 17 00:00:00 2001 From: Calvin Combs <66279577+comcalvi@users.noreply.github.com> Date: Tue, 26 Sep 2023 13:54:15 -0700 Subject: [PATCH 4/6] fix(batch): make `instanceType` optional on multinode jobs (#27223) Make `instanceType` optional. It used to be required. It will default to a batch optimal instance type. The breaking change is for `MultiNodeJobDefinition.instanceType`, which is now optional. This is not truly breaking because everyone has this property explicitly set now, and will continue to have it set after this change. Closes #27185. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../manifest.json | 2 +- .../stack.assets.json | 6 +- .../stack.template.json | 1 - .../tree.json | 132 +++++++++--------- .../test/integ.multinode-job-definition.ts | 1 - packages/aws-cdk-lib/aws-batch/README.md | 2 +- .../aws-batch/lib/multinode-job-definition.ts | 47 +++++-- .../test/multinode-job-definition.test.ts | 57 ++++++-- 8 files changed, 156 insertions(+), 92 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/manifest.json index 2ec338afffe6b..9f844bd585d06 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/manifest.json @@ -17,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}/81ce7809b6566e746dff5e83bfb6567cc956d1be95cc186d032456782ff3b852.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e0a079fad9490e60650bca4a35c6c90273204a816beb74fb80c7b5ae490208d1.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.assets.json index e95ff7f566c06..833c663116fea 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.assets.json @@ -1,7 +1,8 @@ { "version": "34.0.0", "files": { - "81ce7809b6566e746dff5e83bfb6567cc956d1be95cc186d032456782ff3b852": { + "e0a079fad9490e60650bca4a35c6c90273204a816beb74fb80c7b5ae490208d1": { + "source": { "path": "stack.template.json", "packaging": "file" @@ -9,7 +10,8 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "81ce7809b6566e746dff5e83bfb6567cc956d1be95cc186d032456782ff3b852.json", + "objectKey": "e0a079fad9490e60650bca4a35c6c90273204a816beb74fb80c7b5ae490208d1.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.template.json index e414a9a80ade4..212323df6324b 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/stack.template.json @@ -76,7 +76,6 @@ ] }, "Image": "amazon/amazon-ecs-sample", - "InstanceType": "r4.large", "ReadonlyRootFilesystem": false, "ResourceRequirements": [ { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/tree.json index 6c740a6044f69..27886a65ba0ae 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.js.snapshot/tree.json @@ -20,8 +20,9 @@ "id": "ImportExecutionRole", "path": "stack/myContainer/ExecutionRole/ImportExecutionRole", "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" + } }, "Resource": { @@ -45,8 +46,8 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnRole", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "DefaultPolicy": { @@ -100,34 +101,34 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Policy", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Role", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "batchDefaultLogGroup": { "id": "batchDefaultLogGroup", "path": "stack/myContainer/batchDefaultLogGroup", "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_batch.EcsEc2ContainerDefinition", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "SingleContainerMultiNodeJob": { @@ -164,8 +165,7 @@ "type": "VCPU", "value": "256" } - ], - "instanceType": "r4.large" + ] } } ], @@ -181,14 +181,14 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_batch.CfnJobDefinition", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_batch.MultiNodeJobDefinition", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "multinodecontainer": { @@ -203,8 +203,8 @@ "id": "ImportExecutionRole", "path": "stack/multinodecontainer/ExecutionRole/ImportExecutionRole", "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "Resource": { @@ -228,8 +228,8 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnRole", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "DefaultPolicy": { @@ -283,34 +283,34 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Policy", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Role", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "batchDefaultLogGroup": { "id": "batchDefaultLogGroup", "path": "stack/multinodecontainer/batchDefaultLogGroup", "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_batch.EcsEc2ContainerDefinition", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "MultiContainerMultiNodeJob": { @@ -388,14 +388,14 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_batch.CfnJobDefinition", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_batch.MultiNodeJobDefinition", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "multiContainer": { @@ -410,8 +410,8 @@ "id": "ImportExecutionRole", "path": "stack/multiContainer/ExecutionRole/ImportExecutionRole", "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "Resource": { @@ -435,8 +435,8 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnRole", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "DefaultPolicy": { @@ -490,56 +490,56 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Policy", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_iam.Role", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "batchDefaultLogGroup": { "id": "batchDefaultLogGroup", "path": "stack/multiContainer/batchDefaultLogGroup", "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_batch.EcsEc2ContainerDefinition", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "stack/BootstrapVersion", "constructInfo": { - "fqn": "aws-cdk-lib.CfnParameter", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "stack/CheckBootstrapVersion", "constructInfo": { - "fqn": "aws-cdk-lib.CfnRule", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.Stack", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "BatchMultiNodeJobDefinitionTest": { @@ -566,22 +566,22 @@ "id": "BootstrapVersion", "path": "BatchMultiNodeJobDefinitionTest/DefaultTest/DeployAssert/BootstrapVersion", "constructInfo": { - "fqn": "aws-cdk-lib.CfnParameter", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "BatchMultiNodeJobDefinitionTest/DefaultTest/DeployAssert/CheckBootstrapVersion", "constructInfo": { - "fqn": "aws-cdk-lib.CfnRule", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, "constructInfo": { - "fqn": "aws-cdk-lib.Stack", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } }, @@ -606,8 +606,8 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.App", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.2.70" } } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.ts index 2d5e8e0661e78..461881c870400 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.multinode-job-definition.ts @@ -8,7 +8,6 @@ const app = new App(); const stack = new Stack(app, 'stack'); new batch.MultiNodeJobDefinition(stack, 'SingleContainerMultiNodeJob', { - instanceType: InstanceType.of(InstanceClass.R4, InstanceSize.LARGE), containers: [{ startNode: 0, endNode: 10, diff --git a/packages/aws-cdk-lib/aws-batch/README.md b/packages/aws-cdk-lib/aws-batch/README.md index de0444438f072..a579bd0bc2386 100644 --- a/packages/aws-cdk-lib/aws-batch/README.md +++ b/packages/aws-cdk-lib/aws-batch/README.md @@ -556,7 +556,7 @@ In particular, the environment variable that tells the containers which one is t ```ts const multiNodeJob = new batch.MultiNodeJobDefinition(this, 'JobDefinition', { - instanceType: ec2.InstanceType.of(ec2.InstanceClass.R4, ec2.InstanceSize.LARGE), + instanceType: ec2.InstanceType.of(ec2.InstanceClass.R4, ec2.InstanceSize.LARGE), // optional, omit to let Batch choose the type for you containers: [{ container: new batch.EcsEc2ContainerDefinition(this, 'mainMPIContainer', { image: ecs.ContainerImage.fromRegistry('yourregsitry.com/yourMPIImage:latest'), diff --git a/packages/aws-cdk-lib/aws-batch/lib/multinode-job-definition.ts b/packages/aws-cdk-lib/aws-batch/lib/multinode-job-definition.ts index f1a6d84df52df..a103c8819f1fd 100644 --- a/packages/aws-cdk-lib/aws-batch/lib/multinode-job-definition.ts +++ b/packages/aws-cdk-lib/aws-batch/lib/multinode-job-definition.ts @@ -6,6 +6,18 @@ import { baseJobDefinitionProperties, IJobDefinition, JobDefinitionBase, JobDefi import * as ec2 from '../../aws-ec2'; import { ArnFormat, Lazy, Stack } from '../../core'; +/** + * Not a real instance type! Indicates that Batch will choose one it determines to be optimal + * for the workload. + */ +export class OptimalInstanceType extends ec2.InstanceType { + constructor() { + // this is not a real instance type! Batch uses an `undefined` value to mean 'optimal', + // which tells Batch to select the optimal instance type. + super('optimal'); + } +} + interface IMultiNodeJobDefinition extends IJobDefinition { /** * The containers that this multinode job will run. @@ -16,8 +28,10 @@ interface IMultiNodeJobDefinition extends IJobDefinition { /** * The instance type that this job definition will run + * + * @default - optimal instance, selected by Batch */ - readonly instanceType: ec2.InstanceType; + readonly instanceType?: ec2.InstanceType; /** * The index of the main node in this job. @@ -72,8 +86,10 @@ export interface MultiNodeJobDefinitionProps extends JobDefinitionProps { /** * The instance type that this job definition * will run. + * + * @default - optimal instance, selected by Batch */ - readonly instanceType: ec2.InstanceType; + readonly instanceType?: ec2.InstanceType; /** * The containers that this multinode job will run. @@ -124,25 +140,26 @@ export class MultiNodeJobDefinition extends JobDefinitionBase implements IMultiN } public readonly containers: MultiNodeContainer[]; - public readonly instanceType: ec2.InstanceType; public readonly mainNode?: number; public readonly propagateTags?: boolean; public readonly jobDefinitionArn: string; public readonly jobDefinitionName: string; - constructor(scope: Construct, id: string, props: MultiNodeJobDefinitionProps) { + private readonly _instanceType?: ec2.InstanceType; + + constructor(scope: Construct, id: string, props?: MultiNodeJobDefinitionProps) { super(scope, id, props); - this.containers = props.containers ?? []; - this.mainNode = props.mainNode; - this.instanceType = props.instanceType; + this.containers = props?.containers ?? []; + this.mainNode = props?.mainNode; + this._instanceType = props?.instanceType; this.propagateTags = props?.propagateTags; const resource = new CfnJobDefinition(this, 'Resource', { ...baseJobDefinitionProperties(this), type: 'multinode', - jobDefinitionName: props.jobDefinitionName, + jobDefinitionName: props?.jobDefinitionName, propagateTags: this.propagateTags, nodeProperties: { mainNode: this.mainNode ?? 0, @@ -151,7 +168,7 @@ export class MultiNodeJobDefinition extends JobDefinitionBase implements IMultiN targetNodes: container.startNode + ':' + container.endNode, container: { ...container.container._renderContainerDefinition(), - instanceType: this.instanceType.toString(), + instanceType: this._instanceType?.toString(), }, })), }), @@ -171,6 +188,18 @@ export class MultiNodeJobDefinition extends JobDefinitionBase implements IMultiN this.node.addValidation({ validate: () => validateContainers(this.containers) }); } + /** + * If the prop `instanceType` is left `undefined`, then this + * will hold a fake instance type, for backwards compatibility reasons. + */ + public get instanceType(): ec2.InstanceType { + if (!this._instanceType) { + return new OptimalInstanceType(); + } + + return this._instanceType; + } + public addContainer(container: MultiNodeContainer) { this.containers.push(container); } diff --git a/packages/aws-cdk-lib/aws-batch/test/multinode-job-definition.test.ts b/packages/aws-cdk-lib/aws-batch/test/multinode-job-definition.test.ts index e7fe9bccff53b..0e5fb4cd3395c 100644 --- a/packages/aws-cdk-lib/aws-batch/test/multinode-job-definition.test.ts +++ b/packages/aws-cdk-lib/aws-batch/test/multinode-job-definition.test.ts @@ -2,7 +2,7 @@ import { Template } from '../../assertions'; import { InstanceClass, InstanceSize, InstanceType } from '../../aws-ec2'; import * as ecs from '../../aws-ecs'; import { Size, Stack } from '../../core'; -import { Compatibility, EcsEc2ContainerDefinition, MultiNodeJobDefinition } from '../lib'; +import { Compatibility, EcsEc2ContainerDefinition, MultiNodeJobDefinition, OptimalInstanceType } from '../lib'; test('MultiNodeJobDefinition respects mainNode', () => { // GIVEN @@ -20,7 +20,6 @@ test('MultiNodeJobDefinition respects mainNode', () => { endNode: 9, }], mainNode: 5, - instanceType: InstanceType.of(InstanceClass.R4, InstanceSize.LARGE), }); // THEN @@ -28,9 +27,7 @@ test('MultiNodeJobDefinition respects mainNode', () => { NodeProperties: { MainNode: 5, NodeRangeProperties: [{ - Container: { - InstanceType: 'r4.large', - }, + Container: { }, TargetNodes: '0:9', }], NumNodes: 10, @@ -56,7 +53,6 @@ test('EcsJobDefinition respects propagateTags', () => { endNode: 9, }], mainNode: 0, - instanceType: InstanceType.of(InstanceClass.R4, InstanceSize.LARGE), }); // THEN @@ -65,6 +61,38 @@ test('EcsJobDefinition respects propagateTags', () => { }); }); +test('MultiNodeJobDefinition respects instanceType', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + new MultiNodeJobDefinition(stack, 'ECSJobDefn', { + containers: [{ + container: new EcsEc2ContainerDefinition(stack, 'MultinodeContainer', { + cpu: 256, + memory: Size.mebibytes(2048), + image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), + }), + startNode: 0, + endNode: 9, + }], + instanceType: InstanceType.of(InstanceClass.R4, InstanceSize.LARGE), + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Batch::JobDefinition', { + NodeProperties: { + NodeRangeProperties: [{ + Container: { + }, + TargetNodes: '0:9', + }], + NumNodes: 10, + }, + PlatformCapabilities: [Compatibility.EC2], + }); +}); + test('MultiNodeJobDefinition one container', () => { // GIVEN const stack = new Stack(); @@ -81,7 +109,6 @@ test('MultiNodeJobDefinition one container', () => { endNode: 9, }], mainNode: 0, - instanceType: InstanceType.of(InstanceClass.R4, InstanceSize.LARGE), }); // THEN @@ -90,7 +117,6 @@ test('MultiNodeJobDefinition one container', () => { MainNode: 0, NodeRangeProperties: [{ Container: { - InstanceType: 'r4.large', }, TargetNodes: '0:9', }], @@ -159,10 +185,19 @@ test('multinode job requires at least one container', () => { const stack = new Stack(); // WHEN - new MultiNodeJobDefinition(stack, 'ECSJobDefn', { - instanceType: InstanceType.of(InstanceClass.C4, InstanceSize.LARGE), - }); + new MultiNodeJobDefinition(stack, 'ECSJobDefn'); // THEN expect(() => Template.fromStack(stack)).toThrow(/multinode job has no containers!/); }); + +test('multinode job returns a dummy instance type when accessing `instanceType`', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + const jobDef = new MultiNodeJobDefinition(stack, 'ECSJobDefn'); + + // THEN + expect(jobDef.instanceType).toBeInstanceOf(OptimalInstanceType); +}); From 68895ff57b7e1aff1e3993780b383847a91edc28 Mon Sep 17 00:00:00 2001 From: mikewrighton Date: Wed, 27 Sep 2023 08:02:26 -0400 Subject: [PATCH 5/6] build(awslint): Cache L1 constructs in the CFN resource linter. (#27290) Incremental change to improve the performance of awslint. `CfnResourceReflection.findByName()` was checking the doc tags of every class in the assembly on each call, taking 170s for `aws-cdk-lib`. This change caches the tagged classes, eliminating the list traversal and taking `findByName` down to ~2s for the same package. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/awslint/lib/rules/cfn-resource.ts | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/awslint/lib/rules/cfn-resource.ts b/packages/awslint/lib/rules/cfn-resource.ts index 9ff12e0db2986..9e8a73b8804a9 100644 --- a/packages/awslint/lib/rules/cfn-resource.ts +++ b/packages/awslint/lib/rules/cfn-resource.ts @@ -4,10 +4,29 @@ import { CoreTypes } from './core-types'; import { ResourceReflection } from './resource'; import { Linter } from '../linter'; +const cfnResourceTagName = 'cloudformationResource'; + // this linter verifies that we have L2 coverage. it finds all "Cfn" classes and verifies // that we have a corresponding L1 class for it that's identified as a resource. export const cfnResourceLinter = new Linter(a => CfnResourceReflection.findAll(a)); +// Cache L1 constructs per type system. +const l1ConstructCache = new Map>(); + +function cacheL1ConstructsForTypeSystem(sys: reflect.TypeSystem) { + if (!l1ConstructCache.has(sys)) { + l1ConstructCache.set(sys, new Map()); + + for (const cls of sys.classes) { + const cfnResourceTag = cls.docs.customTag(cfnResourceTagName); + + if (cfnResourceTag) { + l1ConstructCache.get(sys)?.set(cfnResourceTag?.toLocaleLowerCase()!, cls); + } + } + } +} + cfnResourceLinter.add({ code: 'resource-class', message: 'every resource must have a resource class (L2), add \'@resource %s\' to its docstring', @@ -24,10 +43,13 @@ export class CfnResourceReflection { * @param fullName first two components are case-insensitive (e.g. `aws::s3::Bucket` is equivalent to `Aws::S3::Bucket`) */ public static findByName(sys: reflect.TypeSystem, fullName: string) { - for (const cls of sys.classes) { - if (cls.docs.customTag('cloudformationResource')?.toLocaleLowerCase() === fullName.toLocaleLowerCase()) { - return new CfnResourceReflection(cls); - } + if (!l1ConstructCache.has(sys)) { + cacheL1ConstructsForTypeSystem(sys); + } + + const cls = l1ConstructCache.get(sys)?.get(fullName.toLowerCase()); + if (cls) { + return new CfnResourceReflection(cls); } return undefined; From dd00d05c07cb3c6efd505e9f7ab577a5eec5070b Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Wed, 27 Sep 2023 09:21:34 -0400 Subject: [PATCH 6/6] =?UTF-8?q?feat(synthetics):=20graduate=20to=20stable?= =?UTF-8?q?=20=F0=9F=9A=80=20(#27305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are excited to graduate the `@aws-cdk/aws-synthetics-alpha` module to STABLE. It now lives on as `aws-cdk-lib/aws-synthetics`. **Deprecated properties removed**: - Runtimes before `SYNTHETICS_NODEJS_PUPPETEER_3_5` have been removed from the stable module. Use a later version instead. - `enableAutoDeleteLambdas` has been removed from the stable module. Use `cleanup: Cleanup.LAMBDA` instead, which achieves the same affect via custom resource. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../framework-integ/.gitignore | 3 + .../canaries/nodejs/node_modules/canary.js | 0 .../nodejs/node_modules/folder/canary.js | 0 .../test/canaries/python/canary.py | 0 .../test/aws-synthetics}/test/canary.zip | Bin ...-synthetics-canary-auto-delete.assets.json | 0 ...ynthetics-canary-auto-delete.template.json | 0 .../cdk.out | 0 ...efaultTestDeployAssert94B79CED.assets.json | 0 ...aultTestDeployAssert94B79CED.template.json | 0 .../integ.json | 0 .../manifest.json | 0 .../tree.json | 0 .../test/integ.canary-auto-delete-lambda.ts | 4 +- ...efaultTestDeployAssert3AD5A094.assets.json | 0 ...aultTestDeployAssert3AD5A094.template.json | 0 .../index.js | 0 ...07d10bf5f4747d6dd1516e2780726d9d6fa820.zip | Bin .../nodejs/node_modules/canary.js | 0 .../nodejs/node_modules/folder/canary.js | 0 .../python/canary.py | 0 .../canary-one.assets.json | 0 .../canary-one.template.json | 0 .../test/integ.canary.js.snapshot/cdk.out | 0 .../test/integ.canary.js.snapshot/integ.json | 0 .../integ.canary.js.snapshot/manifest.json | 0 .../test/integ.canary.js.snapshot/tree.json | 0 .../test/aws-synthetics}/test/integ.canary.ts | 4 +- ...07d10bf5f4747d6dd1516e2780726d9d6fa820.zip | Bin .../canary-vpc.assets.json | 0 .../canary-vpc.template.json | 0 .../test/integ.vpc.js.snapshot/cdk.out | 0 .../test/integ.vpc.js.snapshot/manifest.json | 0 .../test/integ.vpc.js.snapshot/tree.json | 0 .../test/aws-synthetics}/test/integ.vpc.ts | 4 +- .../aws-synthetics-alpha/.eslintrc.js | 8 - .../@aws-cdk/aws-synthetics-alpha/.gitignore | 28 -- .../@aws-cdk/aws-synthetics-alpha/.npmignore | 33 --- .../@aws-cdk/aws-synthetics-alpha/LICENSE | 201 ------------- packages/@aws-cdk/aws-synthetics-alpha/NOTICE | 2 - .../@aws-cdk/aws-synthetics-alpha/README.md | 265 ------------------ .../aws-synthetics-alpha/awslint.json | 5 - .../aws-synthetics-alpha/jest.config.js | 2 - .../aws-synthetics-alpha/lib/index.ts | 6 - .../aws-synthetics-alpha/package.json | 121 -------- .../rosetta/default.ts-fixture | 13 - .../airlift-custom-resource-handlers.sh | 23 -- .../custom-resource-handlers/README.md | 7 +- .../index.ts | 0 ...elete-underlying-resources-handler.test.ts | 2 +- packages/aws-cdk-lib/.gitignore | 1 + packages/aws-cdk-lib/aws-synthetics/README.md | 253 +++++++++++++++-- .../images/endpoint-example.png | Bin .../aws-synthetics}/images/ui-screenshot.png | Bin .../aws-synthetics}/lib/canary.ts | 41 +-- .../aws-synthetics}/lib/code.ts | 6 +- .../aws-cdk-lib/aws-synthetics/lib/index.ts | 6 + .../aws-synthetics}/lib/runtime.ts | 120 -------- .../aws-synthetics}/lib/schedule.ts | 2 +- .../canaries/nodejs/node_modules/canary.js | 52 ++++ .../nodejs/node_modules/folder/canary.js | 52 ++++ .../test/canaries/python/canary.py | 5 +- .../aws-synthetics}/test/canary.test.ts | 10 +- .../aws-synthetics/test/canary.zip | Bin 0 -> 636 bytes .../aws-synthetics}/test/code.test.ts | 15 +- .../aws-synthetics}/test/metric.test.ts | 2 +- .../aws-synthetics}/test/schedule.test.ts | 0 67 files changed, 394 insertions(+), 902 deletions(-) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/canaries/nodejs/node_modules/canary.js (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/canaries/nodejs/node_modules/folder/canary.js (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/canaries/python/canary.py (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/canary.zip (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.assets.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.template.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/cdk.out (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.assets.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.template.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/integ.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/manifest.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.js.snapshot/tree.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary-auto-delete-lambda.ts (94%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.assets.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.template.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/asset.216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329/index.js (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/canary.js (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/folder/canary.js (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/python/canary.py (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/canary-one.assets.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/canary-one.template.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/cdk.out (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/integ.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/manifest.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.js.snapshot/tree.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.canary.ts (98%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.vpc.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.vpc.js.snapshot/canary-vpc.assets.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.vpc.js.snapshot/canary-vpc.template.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.vpc.js.snapshot/cdk.out (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.vpc.js.snapshot/manifest.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.vpc.js.snapshot/tree.json (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => @aws-cdk-testing/framework-integ/test/aws-synthetics}/test/integ.vpc.ts (88%) delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/.eslintrc.js delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/.gitignore delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/.npmignore delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/LICENSE delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/NOTICE delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/README.md delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/awslint.json delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/jest.config.js delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/lib/index.ts delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/package.json delete mode 100644 packages/@aws-cdk/aws-synthetics-alpha/rosetta/default.ts-fixture delete mode 100755 packages/@aws-cdk/aws-synthetics-alpha/scripts/airlift-custom-resource-handlers.sh rename packages/@aws-cdk/custom-resource-handlers/lib/{aws-synthetics-alpha => aws-synthetics}/auto-delete-underlying-resources-handler/index.ts (100%) rename packages/@aws-cdk/custom-resource-handlers/test/{aws-synthetics-alpha => aws-synthetics}/auto-delete-underlying-resources-handler.test.ts (98%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/images/endpoint-example.png (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/images/ui-screenshot.png (100%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/lib/canary.ts (91%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/lib/code.ts (97%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/lib/runtime.ts (59%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/lib/schedule.ts (98%) create mode 100644 packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/canary.js create mode 100644 packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/folder/canary.js rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/test/canary.test.ts (98%) create mode 100644 packages/aws-cdk-lib/aws-synthetics/test/canary.zip rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/test/code.test.ts (95%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/test/metric.test.ts (97%) rename packages/{@aws-cdk/aws-synthetics-alpha => aws-cdk-lib/aws-synthetics}/test/schedule.test.ts (100%) diff --git a/packages/@aws-cdk-testing/framework-integ/.gitignore b/packages/@aws-cdk-testing/framework-integ/.gitignore index 4b8cda825f1bd..e4480afe45fe5 100644 --- a/packages/@aws-cdk-testing/framework-integ/.gitignore +++ b/packages/@aws-cdk-testing/framework-integ/.gitignore @@ -9,6 +9,9 @@ junit.xml coverage nyc.config.js +!test/aws-synthetics/test/canaries/**/* + + !**/*.snapshot/**/asset.*/*.js !**/*.snapshot/**/asset.*/*.d.ts diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/canaries/nodejs/node_modules/canary.js b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canaries/nodejs/node_modules/canary.js similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/canaries/nodejs/node_modules/canary.js rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canaries/nodejs/node_modules/canary.js diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/canaries/nodejs/node_modules/folder/canary.js b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canaries/nodejs/node_modules/folder/canary.js similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/canaries/nodejs/node_modules/folder/canary.js rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canaries/nodejs/node_modules/folder/canary.js diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/canaries/python/canary.py b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canaries/python/canary.py similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/canaries/python/canary.py rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canaries/python/canary.py diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/canary.zip b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canary.zip similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/canary.zip rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/canary.zip diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.assets.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.assets.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.assets.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.template.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.template.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdk-synthetics-canary-auto-delete.template.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdk.out similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdk.out rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdk.out diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.assets.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.assets.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.assets.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.template.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.template.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/cdkintegsyntheticscanaryautodeleteDefaultTestDeployAssert94B79CED.template.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/integ.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/integ.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/integ.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/manifest.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/manifest.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/manifest.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/tree.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.js.snapshot/tree.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.js.snapshot/tree.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.ts similarity index 94% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.ts rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.ts index 78281a1638d44..c4512c5ea8cd8 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary-auto-delete-lambda.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-auto-delete-lambda.ts @@ -1,7 +1,7 @@ -import { App, Stack, StackProps } from 'aws-cdk-lib'; +import { App, Stack, StackProps } from 'aws-cdk-lib/core'; import { IntegTest } from '@aws-cdk/integ-tests-alpha'; import { Construct } from 'constructs'; -import * as synthetics from '../lib'; +import * as synthetics from 'aws-cdk-lib/aws-synthetics'; import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from 'aws-cdk-lib/custom-resources'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.assets.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.assets.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.assets.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.template.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.template.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/IntegCanaryTestDefaultTestDeployAssert3AD5A094.template.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329/index.js similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329/index.js rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.216218e507a977a1bb3592f29c1a62ab3e0a9eb25569109a395315638e154329/index.js diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/canary.js b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/canary.js similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/canary.js rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/canary.js diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/folder/canary.js b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/folder/canary.js similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/folder/canary.js rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/nodejs/node_modules/folder/canary.js diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/python/canary.py b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/python/canary.py similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/python/canary.py rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/asset.d6b51cbdd22d449b9e57c20ef9d0977e1cfbf06806f8008ce376101a2ad432a8/python/canary.py diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/canary-one.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/canary-one.assets.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/canary-one.assets.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/canary-one.assets.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/canary-one.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/canary-one.template.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/canary-one.template.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/canary-one.template.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/cdk.out similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/cdk.out rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/cdk.out diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/integ.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/integ.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/integ.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/manifest.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/manifest.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/manifest.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/tree.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.js.snapshot/tree.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.js.snapshot/tree.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.ts similarity index 98% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.ts rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.ts index baec0e4e32656..624c50efa1413 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.canary.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary.ts @@ -3,8 +3,8 @@ import * as path from 'path'; import * as apigateway from 'aws-cdk-lib/aws-apigateway'; import * as s3 from 'aws-cdk-lib/aws-s3'; -import * as cdk from 'aws-cdk-lib'; -import { Canary, Cleanup, Code, Runtime, Schedule, Test } from '../lib'; +import * as cdk from 'aws-cdk-lib/core'; +import { Canary, Cleanup, Code, Runtime, Schedule, Test } from 'aws-cdk-lib/aws-synthetics'; import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha'; import { RemovalPolicy } from 'aws-cdk-lib'; diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/asset.b1b777dcb79a2fa2790059927207d10bf5f4747d6dd1516e2780726d9d6fa820.zip diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/canary-vpc.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.assets.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/canary-vpc.assets.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.assets.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/canary-vpc.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.template.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/canary-vpc.template.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/canary-vpc.template.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/cdk.out similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/cdk.out rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/cdk.out diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/manifest.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/manifest.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/manifest.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/tree.json similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.js.snapshot/tree.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.js.snapshot/tree.json diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.ts similarity index 88% rename from packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.ts rename to packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.ts index 2eccddbb335d8..9f1c2c3ec2c7b 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/test/integ.vpc.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.vpc.ts @@ -2,8 +2,8 @@ import * as path from 'path'; import * as ec2 from 'aws-cdk-lib/aws-ec2'; -import * as cdk from 'aws-cdk-lib'; -import * as synthetics from '../lib'; +import * as cdk from 'aws-cdk-lib/core'; +import * as synthetics from 'aws-cdk-lib/aws-synthetics'; /* * Stack verification steps: diff --git a/packages/@aws-cdk/aws-synthetics-alpha/.eslintrc.js b/packages/@aws-cdk/aws-synthetics-alpha/.eslintrc.js deleted file mode 100644 index b284f20df26e9..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/.eslintrc.js +++ /dev/null @@ -1,8 +0,0 @@ -const baseConfig = require('@aws-cdk/cdk-build-tools/config/eslintrc'); -baseConfig.parserOptions.project = __dirname + '/tsconfig.json'; - -baseConfig.rules['import/no-extraneous-dependencies'] = ['error', { devDependencies: true, peerDependencies: true } ]; -baseConfig.rules['import/order'] = 'off'; -baseConfig.rules['@aws-cdk/invalid-cfn-imports'] = 'off'; - -module.exports = baseConfig; diff --git a/packages/@aws-cdk/aws-synthetics-alpha/.gitignore b/packages/@aws-cdk/aws-synthetics-alpha/.gitignore deleted file mode 100644 index 10e0002cccb4e..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -*.js -*.js.map -*.d.ts -tsconfig.json -node_modules -*.generated.ts -dist -.jsii - -.LAST_BUILD -.nyc_output -coverage -.nycrc -.LAST_PACKAGE -*.snk -nyc.config.js -!.eslintrc.js -!jest.config.js -!test/canaries/**/* - -junit.xml - -!**/*.snapshot/**/asset.*/*.js -!**/*.snapshot/**/asset.*/*.d.ts - -!**/*.snapshot/**/asset.*/** - - diff --git a/packages/@aws-cdk/aws-synthetics-alpha/.npmignore b/packages/@aws-cdk/aws-synthetics-alpha/.npmignore deleted file mode 100644 index 0d049da0e16bc..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/.npmignore +++ /dev/null @@ -1,33 +0,0 @@ -# Don't include original .ts files when doing `npm pack` -*.ts -!*.d.ts -coverage -.nyc_output -*.tgz - -dist -.LAST_PACKAGE -.LAST_BUILD -!*.js - -# Include .jsii -!.jsii - -*.snk - -*.tsbuildinfo - -tsconfig.json - -.eslintrc.js -jest.config.js - -# exclude cdk artifacts -**/cdk.out -junit.xml -test/ -!*.lit.ts -**/*.snapshot - -# include custom-resource-handlers -!custom-resource-handlers/* diff --git a/packages/@aws-cdk/aws-synthetics-alpha/LICENSE b/packages/@aws-cdk/aws-synthetics-alpha/LICENSE deleted file mode 100644 index 9b722c65c5481..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/@aws-cdk/aws-synthetics-alpha/NOTICE b/packages/@aws-cdk/aws-synthetics-alpha/NOTICE deleted file mode 100644 index a27b7dd317649..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/NOTICE +++ /dev/null @@ -1,2 +0,0 @@ -AWS Cloud Development Kit (AWS CDK) -Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/packages/@aws-cdk/aws-synthetics-alpha/README.md b/packages/@aws-cdk/aws-synthetics-alpha/README.md deleted file mode 100644 index bcb5ff96a3671..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/README.md +++ /dev/null @@ -1,265 +0,0 @@ -# Amazon CloudWatch Synthetics Construct Library - - ---- - -![cdk-constructs: Developer Preview](https://img.shields.io/badge/cdk--constructs-developer--preview-informational.svg?style=for-the-badge) - -> The APIs of higher level constructs in this module are in **developer preview** before they -> become stable. We will only make breaking changes to address unforeseen API issues. Therefore, -> these APIs are not subject to [Semantic Versioning](https://semver.org/), and breaking changes -> will be announced in release notes. This means that while you may use them, you may need to -> update your source code when upgrading to a newer version of this package. - ---- - - - -Amazon CloudWatch Synthetics allow you to monitor your application by generating **synthetic** traffic. The traffic is produced by a **canary**: a configurable script that runs on a schedule. You configure the canary script to follow the same routes and perform the same actions as a user, which allows you to continually verify your user experience even when you don't have any traffic on your applications. - -## Canary - -To illustrate how to use a canary, assume your application defines the following endpoint: - -```console -% curl "https://api.example.com/user/books/topbook/" -The Hitchhikers Guide to the Galaxy -``` - -The below code defines a canary that will hit the `books/topbook` endpoint every 5 minutes: - -```ts -const canary = new synthetics.Canary(this, 'MyCanary', { - schedule: synthetics.Schedule.rate(Duration.minutes(5)), - test: synthetics.Test.custom({ - code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), - handler: 'index.handler', - }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, - environmentVariables: { - stage: 'prod', - }, -}); -``` - -The following is an example of an `index.js` file which exports the `handler` function: - -```js -const synthetics = require('Synthetics'); -const log = require('SyntheticsLogger'); - -const pageLoadBlueprint = async function () { - // Configure the stage of the API using environment variables - const url = `https://api.example.com/${process.env.stage}/user/books/topbook/`; - - const page = await synthetics.getPage(); - const response = await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 }); - // Wait for page to render. Increase or decrease wait time based on endpoint being monitored. - await page.waitFor(15000); - // This will take a screenshot that will be included in test output artifacts. - await synthetics.takeScreenshot('loaded', 'loaded'); - const pageTitle = await page.title(); - log.info('Page title: ' + pageTitle); - if (response.status() !== 200) { - throw 'Failed to load page!'; - } -}; - -exports.handler = async () => { - return await pageLoadBlueprint(); -}; -``` - -> **Note:** The function **must** be called `handler`. - -The canary will automatically produce a CloudWatch Dashboard: - -![UI Screenshot](images/ui-screenshot.png) - -The Canary code will be executed in a lambda function created by Synthetics on your behalf. The Lambda function includes a custom [runtime](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Library.html) provided by Synthetics. The provided runtime includes a variety of handy tools such as [Puppeteer](https://www.npmjs.com/package/puppeteer-core) (for nodejs based one) and Chromium. - -To learn more about Synthetics capabilities, check out the [docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html). - -### Canary Schedule - -You can specify the schedule on which a canary runs by providing a -[`Schedule`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-synthetics.Schedule.html) -object to the `schedule` property. - -Configure a run rate of up to 60 minutes with `Schedule.rate`: - -```ts -const schedule = synthetics.Schedule.rate(Duration.minutes(5)); // Runs every 5 minutes. -``` - -You can also specify a [cron expression](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_cron.html) with `Schedule.cron`: - -```ts -const schedule = synthetics.Schedule.cron({ - hour: '0,8,16', // Run at 12am, 8am, 4pm UTC every day -}); -``` - -If you want the canary to run just once upon deployment, you can use `Schedule.once()`. - -### Deleting underlying resources on canary deletion - -When you delete a lambda, the following underlying resources are isolated in your AWS account: - - - Lambda Function that runs your canary script - - S3 Bucket for artifact storage - - IAM roles and policies - - Log Groups in CloudWatch Logs. - -To learn more about these underlying resources, see -[Synthetics Canaries Deletion](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/synthetics_canaries_deletion.html). - -In the CDK, you can configure your canary to delete the underlying lambda function when the canary is deleted. -This can be provisioned by setting `cleanup: Cleanup.LAMBDA`. Note that this -will create a custom resource under the hood that takes care of the lambda deletion for you. - -```ts -const canary = new synthetics.Canary(this, 'Canary', { - test: synthetics.Test.custom({ - handler: 'index.handler', - code: synthetics.Code.fromInline('/* Synthetics handler code'), - }), - cleanup: synthetics.Cleanup.LAMBDA, - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, -}); -``` - -> Note: To properly clean up your canary on deletion, you still have to manually delete other resources -> like S3 buckets and CloudWatch logs. - -### 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. - -The `synthetics.Code` class exposes static methods to bundle your code artifacts: - - - `code.fromInline(code)` - specify an inline script. - - `code.fromAsset(path)` - specify a .zip file or a directory in the local filesystem which will be zipped and uploaded to S3 on deployment. See the above Note for directory structure. - - `code.fromBucket(bucket, key[, objectVersion])` - specify an S3 object that contains the .zip file of your runtime code. See the above Note for directory structure. - -Using the `Code` class static initializers: - -```ts -// To supply the code inline: -new synthetics.Canary(this, 'Inline Canary', { - test: synthetics.Test.custom({ - code: synthetics.Code.fromInline('/* Synthetics handler code */'), - handler: 'index.handler', // must be 'index.handler' - }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, -}); - -// To supply the code from your local filesystem: -new synthetics.Canary(this, 'Asset Canary', { - test: synthetics.Test.custom({ - code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), - handler: 'index.handler', // must end with '.handler' - }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, -}); - -// To supply the code from a S3 bucket: -import * as s3 from 'aws-cdk-lib/aws-s3'; -const bucket = new s3.Bucket(this, 'Code Bucket'); -new synthetics.Canary(this, 'Bucket Canary', { - test: synthetics.Test.custom({ - code: synthetics.Code.fromBucket(bucket, 'canary.zip'), - handler: 'index.handler', // must end with '.handler' - }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, -}); -``` - -> **Note:** Synthetics have a specified folder structure for canaries. For Node scripts supplied via `code.fromAsset()` or `code.fromBucket()`, the canary resource requires the following folder structure: -> -> ```plaintext -> canary/ -> ├── nodejs/ -> ├── node_modules/ -> ├── .js -> ``` -> -> -> For Python scripts supplied via `code.fromAsset()` or `code.fromBucket()`, the canary resource requires the following folder structure: -> -> ```plaintext -> canary/ -> ├── python/ -> ├── .py -> ``` -> -> See Synthetics [docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_WritingCanary.html). - -### Running a canary on a VPC - -You can specify what [VPC a canary executes in](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_VPC.html). -This can allow for monitoring services that may be internal to a specific VPC. To place a canary within a VPC, you can specify the `vpc` property with the desired `VPC` to place then canary in. -This will automatically attach the appropriate IAM permissions to attach to the VPC. This will also create a Security Group and attach to the default subnets for the VPC unless specified via `vpcSubnets` and `securityGroups`. - -```ts -import * as ec2 from 'aws-cdk-lib/aws-ec2'; - -declare const vpc: ec2.IVpc; -new synthetics.Canary(this, 'Vpc Canary', { - test: synthetics.Test.custom({ - code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), - handler: 'index.handler', - }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, - vpc, -}); -``` - -> **Note:** By default, the Synthetics runtime needs access to the S3 and CloudWatch APIs, which will fail in a private subnet without internet access enabled (e.g. an isolated subnnet). -> -> Ensure that the Canary is placed in a VPC either with internet connectivity or with VPC Endpoints for S3 and CloudWatch enabled and configured. -> -> See [Synthetics VPC docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_VPC.html). - -### Alarms - -You can configure a CloudWatch Alarm on a canary metric. Metrics are emitted by CloudWatch automatically and can be accessed by the following APIs: - -- `canary.metricSuccessPercent()` - percentage of successful canary runs over a given time -- `canary.metricDuration()` - how much time each canary run takes, in seconds. -- `canary.metricFailed()` - number of failed canary runs over a given time - -Create an alarm that tracks the canary metric: - -```ts -import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch'; - -declare const canary: synthetics.Canary; -new cloudwatch.Alarm(this, 'CanaryAlarm', { - metric: canary.metricSuccessPercent(), - evaluationPeriods: 2, - threshold: 90, - comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD, -}); -``` - -### Artifacts - -You can pass an S3 bucket to store artifacts from canary runs. If you do not, -one will be auto-generated when the canary is created. You may add -[lifecycle rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html) -to the auto-generated bucket. - -```ts -const canary = new synthetics.Canary(this, 'MyCanary', { - schedule: synthetics.Schedule.rate(Duration.minutes(5)), - test: synthetics.Test.custom({ - code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), - handler: 'index.handler', - }), - runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, - artifactsBucketLifecycleRules: [{ - expiration: Duration.days(30), - }], -}); -``` diff --git a/packages/@aws-cdk/aws-synthetics-alpha/awslint.json b/packages/@aws-cdk/aws-synthetics-alpha/awslint.json deleted file mode 100644 index dd97030f36303..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/awslint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "exclude": [ - "*:*" - ] -} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics-alpha/jest.config.js b/packages/@aws-cdk/aws-synthetics-alpha/jest.config.js deleted file mode 100644 index 3a2fd93a1228a..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/jest.config.js +++ /dev/null @@ -1,2 +0,0 @@ -const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); -module.exports = baseConfig; diff --git a/packages/@aws-cdk/aws-synthetics-alpha/lib/index.ts b/packages/@aws-cdk/aws-synthetics-alpha/lib/index.ts deleted file mode 100644 index 86cffd2cd1742..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/lib/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './canary'; -export * from './code'; -export * from './runtime'; -export * from './schedule'; - -// AWS::Synthetics CloudFormation Resources: diff --git a/packages/@aws-cdk/aws-synthetics-alpha/package.json b/packages/@aws-cdk/aws-synthetics-alpha/package.json deleted file mode 100644 index 0d4d3153b2e68..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/package.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "name": "@aws-cdk/aws-synthetics-alpha", - "version": "0.0.0", - "private": false, - "description": "The CDK Construct Library for AWS::Synthetics", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "jsii": { - "outdir": "dist", - "targets": { - "dotnet": { - "namespace": "Amazon.CDK.AWS.Synthetics.Alpha", - "packageId": "Amazon.CDK.AWS.Synthetics.Alpha", - "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/main/logo/default-256-dark.png" - }, - "java": { - "package": "software.amazon.awscdk.services.synthetics.alpha", - "maven": { - "groupId": "software.amazon.awscdk", - "artifactId": "synthetics-alpha" - } - }, - "python": { - "distName": "aws-cdk.aws-synthetics-alpha", - "module": "aws_cdk.aws_synthetics_alpha", - "classifiers": [ - "Framework :: AWS CDK", - "Framework :: AWS CDK :: 2" - ] - }, - "go": { - "moduleName": "github.com/aws/aws-cdk-go", - "packageName": "awscdksyntheticsalpha" - } - }, - "projectReferences": true, - "metadata": { - "jsii": { - "rosetta": { - "strict": true - } - } - } - }, - "repository": { - "type": "git", - "url": "https://github.com/aws/aws-cdk.git", - "directory": "packages/@aws-cdk/aws-synthetics-alpha" - }, - "homepage": "https://github.com/aws/aws-cdk", - "scripts": { - "build": "cdk-build", - "watch": "cdk-watch", - "lint": "cdk-lint", - "test": "cdk-test", - "integ": "integ-runner", - "pkglint": "pkglint -f", - "package": "cdk-package", - "awslint": "cdk-awslint", - "build+test+package": "yarn build+test && yarn package", - "build+test": "yarn build && yarn test", - "compat": "cdk-compat", - "rosetta:extract": "yarn --silent jsii-rosetta extract", - "build+extract": "yarn build && yarn rosetta:extract", - "build+test+extract": "yarn build+test && yarn rosetta:extract" - }, - "cdk-build": { - "env": { - "AWSLINT_BASE_CONSTRUCT": true - }, - "pre": [ - "./scripts/airlift-custom-resource-handlers.sh" - ] - }, - "keywords": [ - "aws", - "cdk", - "constructs", - "AWS::Synthetics", - "aws-synthetics" - ], - "author": { - "name": "Amazon Web Services", - "url": "https://aws.amazon.com", - "organization": true - }, - "license": "Apache-2.0", - "devDependencies": { - "@aws-cdk/cdk-build-tools": "0.0.0", - "@aws-cdk/custom-resource-handlers": "0.0.0", - "@aws-cdk/integ-runner": "0.0.0", - "@aws-cdk/pkglint": "0.0.0", - "@aws-cdk/integ-tests-alpha": "0.0.0", - "@types/jest": "^29.5.5", - "jest": "^29.7.0", - "aws-cdk-lib": "0.0.0", - "constructs": "^10.0.0" - }, - "dependencies": {}, - "peerDependencies": { - "aws-cdk-lib": "^0.0.0", - "constructs": "^10.0.0" - }, - "engines": { - "node": ">= 14.15.0" - }, - "stability": "experimental", - "maturity": "developer-preview", - "awscdkio": { - "announce": false - }, - "publishConfig": { - "tag": "latest" - }, - "pkglint": { - "exclude": [ - "naming/package-matches-directory", - "assert/assert-dependency" - ] - } -} diff --git a/packages/@aws-cdk/aws-synthetics-alpha/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-synthetics-alpha/rosetta/default.ts-fixture deleted file mode 100644 index 0ae2b7e2d279d..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/rosetta/default.ts-fixture +++ /dev/null @@ -1,13 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Construct } from 'constructs'; -import { Duration, Stack } from 'aws-cdk-lib'; -import * as synthetics from '@aws-cdk/aws-synthetics-alpha'; -import * as path from 'path'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - /// here - } -} diff --git a/packages/@aws-cdk/aws-synthetics-alpha/scripts/airlift-custom-resource-handlers.sh b/packages/@aws-cdk/aws-synthetics-alpha/scripts/airlift-custom-resource-handlers.sh deleted file mode 100755 index 5a5038ddd63d3..0000000000000 --- a/packages/@aws-cdk/aws-synthetics-alpha/scripts/airlift-custom-resource-handlers.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -scriptdir=$(cd $(dirname $0) && pwd) -customresourcedir=$(node -p "path.dirname(require.resolve('@aws-cdk/custom-resource-handlers/package.json'))") -awscdklibdir=${scriptdir}/.. - -list_custom_resources() { - for file in $customresourcedir/dist/aws-synthetics-alpha/*/index.js; do - echo $file | rev | cut -d "/" -f 2-4 | rev - done -} - -customresources=$(list_custom_resources) - -echo $customresources - -cd $awscdklibdir -mkdir -p $awscdklibdir/custom-resource-handlers - -for cr in $customresources; do - mkdir -p $awscdklibdir/custom-resource-handlers/$cr - cp $customresourcedir/$cr/index.js $awscdklibdir/custom-resource-handlers/$cr -done diff --git a/packages/@aws-cdk/custom-resource-handlers/README.md b/packages/@aws-cdk/custom-resource-handlers/README.md index a4beb0b3f433e..653aa30c11796 100644 --- a/packages/@aws-cdk/custom-resource-handlers/README.md +++ b/packages/@aws-cdk/custom-resource-handlers/README.md @@ -2,19 +2,20 @@ This package contains the following custom resource handlers: -Stable: +### Stable: - aws-s3/auto-delete-objects-handler - aws-ecr/auto-delete-images-handler - aws-events-targets/aws-api-handler +- aws-synthetics/auto-delete-underlying-resources-handler - custom-resources/aws-custom-resource-handler These handlers are copied into `aws-cdk-lib/custom-resource-handlers` at build time and included as part of the `aws-cdk-lib` package. -Experimental: +### Experimental: -- aws-synthetics-alpha/auto-delete-underlying-resources-handler +- None currently These handlers are excluded from `aws-cdk-lib/custom-resource-handlers` and are individually copied into their respective `-alpha` packages at build time. When an `-alpha` package is diff --git a/packages/@aws-cdk/custom-resource-handlers/lib/aws-synthetics-alpha/auto-delete-underlying-resources-handler/index.ts b/packages/@aws-cdk/custom-resource-handlers/lib/aws-synthetics/auto-delete-underlying-resources-handler/index.ts similarity index 100% rename from packages/@aws-cdk/custom-resource-handlers/lib/aws-synthetics-alpha/auto-delete-underlying-resources-handler/index.ts rename to packages/@aws-cdk/custom-resource-handlers/lib/aws-synthetics/auto-delete-underlying-resources-handler/index.ts diff --git a/packages/@aws-cdk/custom-resource-handlers/test/aws-synthetics-alpha/auto-delete-underlying-resources-handler.test.ts b/packages/@aws-cdk/custom-resource-handlers/test/aws-synthetics/auto-delete-underlying-resources-handler.test.ts similarity index 98% rename from packages/@aws-cdk/custom-resource-handlers/test/aws-synthetics-alpha/auto-delete-underlying-resources-handler.test.ts rename to packages/@aws-cdk/custom-resource-handlers/test/aws-synthetics/auto-delete-underlying-resources-handler.test.ts index 2be8237c29ef6..db7be6962df42 100644 --- a/packages/@aws-cdk/custom-resource-handlers/test/aws-synthetics-alpha/auto-delete-underlying-resources-handler.test.ts +++ b/packages/@aws-cdk/custom-resource-handlers/test/aws-synthetics/auto-delete-underlying-resources-handler.test.ts @@ -7,7 +7,7 @@ const mockLambdaClient = { const mockGetCanaryCommand = jest.fn().mockImplementation(() => { return {}; }); const mockDeleteFunctionCommand = jest.fn().mockImplementation(() => { return {}; }); -import { autoDeleteHandler } from '../../lib/aws-synthetics-alpha/auto-delete-underlying-resources-handler'; +import { autoDeleteHandler } from '../../lib/aws-synthetics/auto-delete-underlying-resources-handler'; jest.mock('@aws-sdk/client-lambda', () => { return { diff --git a/packages/aws-cdk-lib/.gitignore b/packages/aws-cdk-lib/.gitignore index 9cf013f0393fa..3bc4dfa941b49 100644 --- a/packages/aws-cdk-lib/.gitignore +++ b/packages/aws-cdk-lib/.gitignore @@ -17,6 +17,7 @@ tsconfig.json !.eslintrc.js !jest.config.js cloudformation-include/cfn-types-2-classes.json +!aws-synthetics/test/canaries/**/* junit.xml !**/*.snapshot/**/asset.*/*.js diff --git a/packages/aws-cdk-lib/aws-synthetics/README.md b/packages/aws-cdk-lib/aws-synthetics/README.md index 3bb396a164eea..1220cf1042a39 100644 --- a/packages/aws-cdk-lib/aws-synthetics/README.md +++ b/packages/aws-cdk-lib/aws-synthetics/README.md @@ -1,31 +1,250 @@ -# AWS::Synthetics Construct Library +# Amazon CloudWatch Synthetics Construct Library -This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. +Amazon CloudWatch Synthetics allow you to monitor your application by generating **synthetic** traffic. The traffic is produced by a **canary**: a configurable script that runs on a schedule. You configure the canary script to follow the same routes and perform the same actions as a user, which allows you to continually verify your user experience even when you don't have any traffic on your applications. -```ts nofixture -import * as synthetics from 'aws-cdk-lib/aws-synthetics'; +## Canary + +To illustrate how to use a canary, assume your application defines the following endpoint: + +```console +% curl "https://api.example.com/user/books/topbook/" +The Hitchhikers Guide to the Galaxy +``` + +The below code defines a canary that will hit the `books/topbook` endpoint every 5 minutes: + +```ts +const canary = new synthetics.Canary(this, 'MyCanary', { + schedule: synthetics.Schedule.rate(Duration.minutes(5)), + test: synthetics.Test.custom({ + code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), + handler: 'index.handler', + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + environmentVariables: { + stage: 'prod', + }, +}); +``` + +The following is an example of an `index.js` file which exports the `handler` function: + +```js +const synthetics = require('Synthetics'); +const log = require('SyntheticsLogger'); + +const pageLoadBlueprint = async function () { + // Configure the stage of the API using environment variables + const url = `https://api.example.com/${process.env.stage}/user/books/topbook/`; + + const page = await synthetics.getPage(); + const response = await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 }); + // Wait for page to render. Increase or decrease wait time based on endpoint being monitored. + await page.waitFor(15000); + // This will take a screenshot that will be included in test output artifacts. + await synthetics.takeScreenshot('loaded', 'loaded'); + const pageTitle = await page.title(); + log.info('Page title: ' + pageTitle); + if (response.status() !== 200) { + throw 'Failed to load page!'; + } +}; + +exports.handler = async () => { + return await pageLoadBlueprint(); +}; +``` + +> **Note:** The function **must** be called `handler`. + +The canary will automatically produce a CloudWatch Dashboard: + +![UI Screenshot](images/ui-screenshot.png) + +The Canary code will be executed in a lambda function created by Synthetics on your behalf. The Lambda function includes a custom [runtime](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Library.html) provided by Synthetics. The provided runtime includes a variety of handy tools such as [Puppeteer](https://www.npmjs.com/package/puppeteer-core) (for nodejs based one) and Chromium. + +To learn more about Synthetics capabilities, check out the [docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html). + +### Canary Schedule + +You can specify the schedule on which a canary runs by providing a +[`Schedule`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-synthetics.Schedule.html) +object to the `schedule` property. + +Configure a run rate of up to 60 minutes with `Schedule.rate`: + +```ts +const schedule = synthetics.Schedule.rate(Duration.minutes(5)); // Runs every 5 minutes. +``` + +You can also specify a [cron expression](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_cron.html) with `Schedule.cron`: + +```ts +const schedule = synthetics.Schedule.cron({ + hour: '0,8,16', // Run at 12am, 8am, 4pm UTC every day +}); +``` + +If you want the canary to run just once upon deployment, you can use `Schedule.once()`. + +### Deleting underlying resources on canary deletion + +When you delete a lambda, the following underlying resources are isolated in your AWS account: + + - Lambda Function that runs your canary script + - S3 Bucket for artifact storage + - IAM roles and policies + - Log Groups in CloudWatch Logs. + +To learn more about these underlying resources, see +[Synthetics Canaries Deletion](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/synthetics_canaries_deletion.html). + +In the CDK, you can configure your canary to delete the underlying lambda function when the canary is deleted. +This can be provisioned by setting `cleanup: Cleanup.LAMBDA`. Note that this +will create a custom resource under the hood that takes care of the lambda deletion for you. + +```ts +const canary = new synthetics.Canary(this, 'Canary', { + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code'), + }), + cleanup: synthetics.Cleanup.LAMBDA, + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, +}); +``` + +> Note: To properly clean up your canary on deletion, you still have to manually delete other resources +> like S3 buckets and CloudWatch logs. + +### 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. + +The `synthetics.Code` class exposes static methods to bundle your code artifacts: + + - `code.fromInline(code)` - specify an inline script. + - `code.fromAsset(path)` - specify a .zip file or a directory in the local filesystem which will be zipped and uploaded to S3 on deployment. See the above Note for directory structure. + - `code.fromBucket(bucket, key[, objectVersion])` - specify an S3 object that contains the .zip file of your runtime code. See the above Note for directory structure. + +Using the `Code` class static initializers: + +```ts +// To supply the code inline: +new synthetics.Canary(this, 'Inline Canary', { + test: synthetics.Test.custom({ + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + handler: 'index.handler', // must be 'index.handler' + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, +}); + +// To supply the code from your local filesystem: +new synthetics.Canary(this, 'Asset Canary', { + test: synthetics.Test.custom({ + code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), + handler: 'index.handler', // must end with '.handler' + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, +}); + +// To supply the code from a S3 bucket: +import * as s3 from 'aws-cdk-lib/aws-s3'; +const bucket = new s3.Bucket(this, 'Code Bucket'); +new synthetics.Canary(this, 'Bucket Canary', { + test: synthetics.Test.custom({ + code: synthetics.Code.fromBucket(bucket, 'canary.zip'), + handler: 'index.handler', // must end with '.handler' + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, +}); ``` - +> **Note:** Synthetics have a specified folder structure for canaries. For Node scripts supplied via `code.fromAsset()` or `code.fromBucket()`, the canary resource requires the following folder structure: +> +> ```plaintext +> canary/ +> ├── nodejs/ +> ├── node_modules/ +> ├── .js +> ``` +> +> +> For Python scripts supplied via `code.fromAsset()` or `code.fromBucket()`, the canary resource requires the following folder structure: +> +> ```plaintext +> canary/ +> ├── python/ +> ├── .py +> ``` +> +> See Synthetics [docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_WritingCanary.html). + +### Running a canary on a VPC -There are no official hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. Here are some suggestions on how to proceed: +You can specify what [VPC a canary executes in](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_VPC.html). +This can allow for monitoring services that may be internal to a specific VPC. To place a canary within a VPC, you can specify the `vpc` property with the desired `VPC` to place then canary in. +This will automatically attach the appropriate IAM permissions to attach to the VPC. This will also create a Security Group and attach to the default subnets for the VPC unless specified via `vpcSubnets` and `securityGroups`. -- Search [Construct Hub for Synthetics construct libraries](https://constructs.dev/search?q=synthetics) -- Use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, in the same way you would use [the CloudFormation AWS::Synthetics resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Synthetics.html) directly. +```ts +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +declare const vpc: ec2.IVpc; +new synthetics.Canary(this, 'Vpc Canary', { + test: synthetics.Test.custom({ + code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), + handler: 'index.handler', + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + vpc, +}); +``` -> An experimental construct library for this service is available in preview. Since it is not stable yet, it is distributed -> as a separate package so that you can pin its version independently of the rest of the CDK. See the package: +> **Note:** By default, the Synthetics runtime needs access to the S3 and CloudWatch APIs, which will fail in a private subnet without internet access enabled (e.g. an isolated subnnet). > -> @aws-cdk/aws-synthetics-alpha +> Ensure that the Canary is placed in a VPC either with internet connectivity or with VPC Endpoints for S3 and CloudWatch enabled and configured. +> +> See [Synthetics VPC docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_VPC.html). + +### Alarms - +You can configure a CloudWatch Alarm on a canary metric. Metrics are emitted by CloudWatch automatically and can be accessed by the following APIs: -There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. -However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly. +- `canary.metricSuccessPercent()` - percentage of successful canary runs over a given time +- `canary.metricDuration()` - how much time each canary run takes, in seconds. +- `canary.metricFailed()` - number of failed canary runs over a given time -For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::Synthetics](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Synthetics.html). +Create an alarm that tracks the canary metric: -(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and submit an RFC if you are interested in contributing to this construct library.) +```ts +import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch'; + +declare const canary: synthetics.Canary; +new cloudwatch.Alarm(this, 'CanaryAlarm', { + metric: canary.metricSuccessPercent(), + evaluationPeriods: 2, + threshold: 90, + comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD, +}); +``` - +### Artifacts + +You can pass an S3 bucket to store artifacts from canary runs. If you do not, +one will be auto-generated when the canary is created. You may add +[lifecycle rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html) +to the auto-generated bucket. + +```ts +const canary = new synthetics.Canary(this, 'MyCanary', { + schedule: synthetics.Schedule.rate(Duration.minutes(5)), + test: synthetics.Test.custom({ + code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), + handler: 'index.handler', + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0, + artifactsBucketLifecycleRules: [{ + expiration: Duration.days(30), + }], +}); +``` diff --git a/packages/@aws-cdk/aws-synthetics-alpha/images/endpoint-example.png b/packages/aws-cdk-lib/aws-synthetics/images/endpoint-example.png similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/images/endpoint-example.png rename to packages/aws-cdk-lib/aws-synthetics/images/endpoint-example.png diff --git a/packages/@aws-cdk/aws-synthetics-alpha/images/ui-screenshot.png b/packages/aws-cdk-lib/aws-synthetics/images/ui-screenshot.png similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/images/ui-screenshot.png rename to packages/aws-cdk-lib/aws-synthetics/images/ui-screenshot.png diff --git a/packages/@aws-cdk/aws-synthetics-alpha/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts similarity index 91% rename from packages/@aws-cdk/aws-synthetics-alpha/lib/canary.ts rename to packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index c144d464a8bb6..dd33e7b6f0002 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -1,17 +1,16 @@ import * as crypto from 'crypto'; -import { Metric, MetricOptions, MetricProps } from 'aws-cdk-lib/aws-cloudwatch'; -import * as ec2 from 'aws-cdk-lib/aws-ec2'; -import * as iam from 'aws-cdk-lib/aws-iam'; -import * as s3 from 'aws-cdk-lib/aws-s3'; -import * as cdk from 'aws-cdk-lib/core'; +import * as path from 'path'; import { Construct } from 'constructs'; import { Code } from './code'; import { Runtime } from './runtime'; import { Schedule } from './schedule'; -import { CloudWatchSyntheticsMetrics } from 'aws-cdk-lib/aws-synthetics/lib/synthetics-canned-metrics.generated'; -import { CfnCanary } from 'aws-cdk-lib/aws-synthetics'; -import { CustomResource, CustomResourceProvider, CustomResourceProviderRuntime } from 'aws-cdk-lib/core'; -import * as path from 'path'; +import { CloudWatchSyntheticsMetrics } from './synthetics-canned-metrics.generated'; +import { CfnCanary } from './synthetics.generated'; +import { Metric, MetricOptions, MetricProps } from '../../aws-cloudwatch'; +import * as ec2 from '../../aws-ec2'; +import * as iam from '../../aws-iam'; +import * as s3 from '../../aws-s3'; +import * as cdk from '../../core'; const AUTO_DELETE_UNDERLYING_RESOURCES_RESOURCE_TYPE = 'Custom::SyntheticsAutoDeleteUnderlyingResources'; const AUTO_DELETE_UNDERLYING_RESOURCES_TAG = 'aws-cdk:auto-delete-underlying-resources'; @@ -213,16 +212,6 @@ export interface CanaryProps { */ readonly securityGroups?: ec2.ISecurityGroup[]; - /** - * 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 - * - * @default false - * @deprecated this feature has been deprecated by the service team, use `cleanup: Cleanup.LAMBDA` instead which will use a Custom Resource to achieve the same effect. - */ - readonly enableAutoDeleteLambdas?: boolean; - /** * Specify the underlying resources to be cleaned up when the canary is deleted. * Using `Cleanup.LAMBDA` will create a Custom Resource to achieve this. @@ -326,16 +315,16 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { this.canaryState = resource.attrState; this.canaryName = this.getResourceNameAttribute(resource.ref); - if (props.cleanup === Cleanup.LAMBDA ?? props.enableAutoDeleteLambdas) { + if (props.cleanup === Cleanup.LAMBDA) { this.cleanupUnderlyingResources(); } } private cleanupUnderlyingResources() { - const provider = CustomResourceProvider.getOrCreateProvider(this, AUTO_DELETE_UNDERLYING_RESOURCES_RESOURCE_TYPE, { - codeDirectory: path.join(__dirname, '..', 'custom-resource-handlers', 'dist', 'aws-synthetics-alpha', 'auto-delete-underlying-resources-handler'), + const provider = cdk.CustomResourceProvider.getOrCreateProvider(this, AUTO_DELETE_UNDERLYING_RESOURCES_RESOURCE_TYPE, { + codeDirectory: path.join(__dirname, '..', '..', 'custom-resource-handlers', 'dist', 'aws-synthetics', 'auto-delete-underlying-resources-handler'), useCfnResponseWrapper: false, - runtime: CustomResourceProviderRuntime.NODEJS_18_X, + runtime: cdk.CustomResourceProviderRuntime.NODEJS_18_X, description: `Lambda function for auto-deleting underlying resources created by ${this.canaryName}.`, policyStatements: [{ Effect: 'Allow', @@ -348,7 +337,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { }], }); - new CustomResource(this, 'AutoDeleteUnderlyingResourcesCustomResource', { + new cdk.CustomResource(this, 'AutoDeleteUnderlyingResourcesCustomResource', { resourceType: AUTO_DELETE_UNDERLYING_RESOURCES_RESOURCE_TYPE, serviceToken: provider.serviceToken, properties: { @@ -510,10 +499,6 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { private validateHandler(handler: string, runtime: Runtime) { const oldRuntimes = [ Runtime.SYNTHETICS_PYTHON_SELENIUM_1_0, - Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_0, - Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_1, - Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2, - Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3, ]; if (oldRuntimes.includes(runtime)) { if (!handler.match(/^[0-9A-Za-z_\\-]+\.handler*$/)) { diff --git a/packages/@aws-cdk/aws-synthetics-alpha/lib/code.ts b/packages/aws-cdk-lib/aws-synthetics/lib/code.ts similarity index 97% rename from packages/@aws-cdk/aws-synthetics-alpha/lib/code.ts rename to packages/aws-cdk-lib/aws-synthetics/lib/code.ts index 1c094e90a5b76..aa53c3c06d030 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/lib/code.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/code.ts @@ -1,10 +1,10 @@ import * as fs from 'fs'; import * as path from 'path'; -import * as s3 from 'aws-cdk-lib/aws-s3'; -import * as s3_assets from 'aws-cdk-lib/aws-s3-assets'; import { Construct } from 'constructs'; import { RuntimeFamily } from './runtime'; -import { Stage } from 'aws-cdk-lib/core'; +import * as s3 from '../../aws-s3'; +import * as s3_assets from '../../aws-s3-assets'; +import { Stage } from '../../core'; /** * The code the canary should execute diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/index.ts b/packages/aws-cdk-lib/aws-synthetics/lib/index.ts index 211c1ad4b58f9..2d760552096e5 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/index.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/index.ts @@ -1 +1,7 @@ +export * from './canary'; +export * from './code'; +export * from './runtime'; +export * from './schedule'; + +// AWS::Synthetics CloudFormation Resources: export * from './synthetics.generated'; \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics-alpha/lib/runtime.ts b/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts similarity index 59% rename from packages/@aws-cdk/aws-synthetics-alpha/lib/runtime.ts rename to packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts index 96b13746acbd9..587d0ae40cf56 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/lib/runtime.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/runtime.ts @@ -22,126 +22,6 @@ export enum RuntimeFamily { * Runtime options for a canary */ export class Runtime { - /** - * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** - * - * `syn-1.0` includes the following: - * - * - Synthetics library 1.0 - * - Synthetics handler code 1.0 - * - Lambda runtime Node.js 10.x - * - Puppeteer-core version 1.14.0 - * - The Chromium version that matches Puppeteer-core 1.14.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-1.0 - * @deprecated Use the latest version instead - */ - public static readonly SYNTHETICS_1_0 = new Runtime('syn-1.0', RuntimeFamily.NODEJS); - - /** - * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** - * - * `syn-nodejs-2.0` includes the following: - * - Lambda runtime Node.js 10.x - * - Puppeteer-core version 3.3.0 - * - Chromium version 83.0.4103.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-2.0 - * @deprecated Use the latest version instead - */ - public static readonly SYNTHETICS_NODEJS_2_0 = new Runtime('syn-nodejs-2.0', RuntimeFamily.NODEJS); - - /** - * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** - * - * `syn-nodejs-2.1` includes the following: - * - Lambda runtime Node.js 10.x - * - Puppeteer-core version 3.3.0 - * - Chromium version 83.0.4103.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-2.1 - * @deprecated Use the latest version instead - */ - public static readonly SYNTHETICS_NODEJS_2_1 = new Runtime('syn-nodejs-2.1', RuntimeFamily.NODEJS); - - /** - * **Deprecated by AWS Synthetics. You can't create canaries with deprecated runtimes.** - * - * `syn-nodejs-2.2` includes the following: - * - Lambda runtime Node.js 10.x - * - Puppeteer-core version 3.3.0 - * - Chromium version 83.0.4103.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-2.2 - * @deprecated Use the latest version instead - */ - 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 - * - Chromium version 88.0.4298.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-3.0 - * @deprecated Use the latest version instead - */ - 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 - * - Chromium version 88.0.4298.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-3.1 - * @deprecated Use the latest version instead - */ - 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 - * - Chromium version 88.0.4298.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-3.2 - * @deprecated Use the latest version instead - */ - public static readonly SYNTHETICS_NODEJS_PUPPETEER_3_2 = new Runtime('syn-nodejs-puppeteer-3.2', RuntimeFamily.NODEJS); - - /** - * `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 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-3.3 - * @deprecated Use the latest version instead - */ - 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 - * - Chromium version 88.0.4298.0 - * - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-3.4 - * @deprecated Use the latest version instead - */ - public static readonly SYNTHETICS_NODEJS_PUPPETEER_3_4 = new Runtime('syn-nodejs-puppeteer-3.4', RuntimeFamily.NODEJS); - /** * `syn-nodejs-puppeteer-3.5` includes the following: * - Lambda runtime Node.js 14.x diff --git a/packages/@aws-cdk/aws-synthetics-alpha/lib/schedule.ts b/packages/aws-cdk-lib/aws-synthetics/lib/schedule.ts similarity index 98% rename from packages/@aws-cdk/aws-synthetics-alpha/lib/schedule.ts rename to packages/aws-cdk-lib/aws-synthetics/lib/schedule.ts index 7be04de89fab3..f1618beb6137c 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/lib/schedule.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/schedule.ts @@ -1,4 +1,4 @@ -import { Duration } from 'aws-cdk-lib/core'; +import { Duration } from '../../core'; /** * Schedule for canary runs diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/canary.js b/packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/canary.js new file mode 100644 index 0000000000000..d7936811fd8c1 --- /dev/null +++ b/packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/canary.js @@ -0,0 +1,52 @@ +var synthetics = require('Synthetics'); +const log = require('SyntheticsLogger'); +const https = require('https'); +const http = require('http'); + +const apiCanaryBlueprint = async function () { + const postData = ""; + + const verifyRequest = async function (requestOption) { + return new Promise((resolve, reject) => { + log.info("Making request with options: " + JSON.stringify(requestOption)); + let req + if (requestOption.protocol === 'https:') { + req = https.request(requestOption); + } else { + req = http.request(requestOption); + } + req.on('response', (res) => { + log.info(`Status Code: ${res.statusCode}`) + log.info(`Response Headers: ${JSON.stringify(res.headers)}`) + if (res.statusCode !== 200) { + reject("Failed: " + requestOption.pathname); + } + res.on('data', (d) => { + log.info("Response: " + d); + }); + res.on('end', () => { + resolve(); + }) + }); + + req.on('error', (error) => { + reject(error); + }); + + if (postData) { + req.write(postData); + } + req.end(); + }); + } + + const headers = {} + headers['User-Agent'] = [synthetics.getCanaryUserAgentString(), headers['User-Agent']].join(' '); + const requestOptions = new URL(process.env.URL); + requestOptions['headers'] = headers; + await verifyRequest(requestOptions); +}; + +exports.handler = async () => { + return await apiCanaryBlueprint(); +}; \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/folder/canary.js b/packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/folder/canary.js new file mode 100644 index 0000000000000..2ee399fbc633f --- /dev/null +++ b/packages/aws-cdk-lib/aws-synthetics/test/canaries/nodejs/node_modules/folder/canary.js @@ -0,0 +1,52 @@ +var synthetics = require('Synthetics'); +const log = require('SyntheticsLogger'); +const https = require('https'); +const http = require('http'); + +const apiCanaryBlueprint = async function () { + const postData = ""; + + const verifyRequest = async function (requestOption) { + return new Promise((resolve, reject) => { + log.info("Making request with options: " + JSON.stringify(requestOption)); + let req + if (requestOption.protocol === 'https:') { + req = https.request(requestOption); + } else { + req = http.request(requestOption); + } + req.on('response', (res) => { + log.info(`Status Code: ${res.statusCode}`) + log.info(`Response Headers: ${JSON.stringify(res.headers)}`) + if (res.statusCode !== 200) { + reject("Failed: " + requestOption.pathname); + } + res.on('data', (d) => { + log.info("Response: " + d); + }); + res.on('end', () => { + resolve(); + }) + }); + + req.on('error', (error) => { + reject(error); + }); + + if (postData) { + req.write(postData); + } + req.end(); + }); + } + + const headers = {} + headers['User-Agent'] = [synthetics.getCanaryUserAgentString(), headers['User-Agent']].join(' '); + const requestOptions = new URL(process.env.URL); + requestOptions['headers'] = headers; + await verifyRequest(requestOptions); +}; + +exports.functionName = async () => { + return await apiCanaryBlueprint(); +}; \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canaries/python/canary.py b/packages/aws-cdk-lib/aws-synthetics/test/canaries/python/canary.py index 2dbed4e312afe..fac8b8004a7a7 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canaries/python/canary.py +++ b/packages/aws-cdk-lib/aws-synthetics/test/canaries/python/canary.py @@ -1,5 +1,6 @@ # This example comes from the AWS Synthetics service console "API canary" blueprint +import os import json import http.client import urllib.parse @@ -23,7 +24,7 @@ def verify_request(method, url, post_data=None, headers={}): else: conn = http.client.HTTPConnection(parsed_url.hostname, parsed_url.port) - conn.request(method, url, str(post_data), headers) + conn.request(method, url, post_data, headers) response = conn.getresponse() logger.info("Status Code: %s " % response.status) logger.info("Response Headers: %s" % json.dumps(response.headers.as_string())) @@ -46,7 +47,7 @@ def verify_request(method, url, post_data=None, headers={}): def main(): - url = 'https://example.com/' + url = os.environ['URL'] method = 'GET' postData = "" headers = {} diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts similarity index 98% rename from packages/@aws-cdk/aws-synthetics-alpha/test/canary.test.ts rename to packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index d4460351dcc61..4923d252fa215 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -1,9 +1,9 @@ import * as path from 'path'; -import { Match, Template } from 'aws-cdk-lib/assertions'; -import * as ec2 from 'aws-cdk-lib/aws-ec2'; -import * as iam from 'aws-cdk-lib/aws-iam'; -import * as s3 from 'aws-cdk-lib/aws-s3'; -import { Duration, Lazy, Stack } from 'aws-cdk-lib'; +import { Match, Template } from '../../assertions'; +import * as ec2 from '../../aws-ec2'; +import * as iam from '../../aws-iam'; +import * as s3 from '../../aws-s3'; +import { Duration, Lazy, Stack } from '../../core'; import * as synthetics from '../lib'; test('Basic canary properties work', () => { diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.zip b/packages/aws-cdk-lib/aws-synthetics/test/canary.zip new file mode 100644 index 0000000000000000000000000000000000000000..b8d48b451cf330f303c1ed8cd0e3bc12381e862c GIT binary patch literal 636 zcmWIWW@Zs#00HZ+zX4zdlwfC2V93i)NzE$O4-MgEU~hV^7!SgK3^n3QE4UdLS#p}{ zvRTelGZzNH4RJ*?L{FKt1RH%uQfTm@?P>cuBSWV<$;9#gkGSLC(G+7)b zCMV`47FFtH6@wl74QM0`qZ#eJR^x=emgcq79%sBydg=yk2=&lecg8#H!iA6xTZ30T z3kvW!cV7G4dC#k-Px@aEIPY=x { test('fromInline works', () => { @@ -19,7 +18,7 @@ describe(synthetics.Code.fromInline, () => { };`); // THEN - expect(inline.bind(stack, 'index.handler', RuntimeFamily.NODEJS).inlineCode).toEqual(` + expect(inline.bind(stack, 'index.handler', synthetics.RuntimeFamily.NODEJS).inlineCode).toEqual(` exports.handler = async () => { console.log(\'hello world\'); };`); @@ -35,7 +34,7 @@ describe(synthetics.Code.fromInline, () => { const stack = new Stack(new App(), 'canaries'); // THEN - expect(() => synthetics.Code.fromInline('code').bind(stack, 'canary.handler', RuntimeFamily.NODEJS)) + expect(() => synthetics.Code.fromInline('code').bind(stack, 'canary.handler', synthetics.RuntimeFamily.NODEJS)) .toThrowError('The handler for inline code must be "index.handler" (got "canary.handler")'); }); }); @@ -245,7 +244,7 @@ describe(synthetics.Code.fromBucket, () => { // WHEN const code = synthetics.Code.fromBucket(bucket, 'code.js'); - const codeConfig = code.bind(stack, 'code.handler', RuntimeFamily.NODEJS); + const codeConfig = code.bind(stack, 'code.handler', synthetics.RuntimeFamily.NODEJS); // THEN expect(codeConfig.s3Location?.bucketName).toEqual(bucket.bucketName); diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/metric.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/metric.test.ts similarity index 97% rename from packages/@aws-cdk/aws-synthetics-alpha/test/metric.test.ts rename to packages/aws-cdk-lib/aws-synthetics/test/metric.test.ts index 550d28cdbc8b9..596256b40a8cd 100644 --- a/packages/@aws-cdk/aws-synthetics-alpha/test/metric.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/metric.test.ts @@ -1,4 +1,4 @@ -import { App, Stack } from 'aws-cdk-lib'; +import { App, Stack } from '../../core'; import * as synthetics from '../lib'; test('.metricXxx() methods can be used to obtain Metrics for the canary', () => { diff --git a/packages/@aws-cdk/aws-synthetics-alpha/test/schedule.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/schedule.test.ts similarity index 100% rename from packages/@aws-cdk/aws-synthetics-alpha/test/schedule.test.ts rename to packages/aws-cdk-lib/aws-synthetics/test/schedule.test.ts