From 028495e55fed02f727024a443fc29a17d4629fe3 Mon Sep 17 00:00:00 2001 From: Nick Lynch Date: Sat, 3 Oct 2020 02:12:24 +0100 Subject: [PATCH 01/47] fix(rds): secret for ServerlessCluster is not accessible programmatically (#10657) In a last-minute change, the secret was changed from public (matching all of the other RDS constructs) to private. This means users who don't specify a secret, and rely on the auto-generated one, have no programmatic means of accessing the secret. Brought up by a user on the CDK.dev Slack channel. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts b/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts index a79b08507f82e..3f2dbfef37c7d 100644 --- a/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts +++ b/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts @@ -319,7 +319,8 @@ export class ServerlessCluster extends ServerlessClusterBase { /** * The secret attached to this cluster */ - private readonly secret?: secretsmanager.ISecret; + public readonly secret?: secretsmanager.ISecret; + private readonly subnetGroup: ISubnetGroup; private readonly vpc: ec2.IVpc; private readonly vpcSubnets?: ec2.SubnetSelection; @@ -327,7 +328,7 @@ export class ServerlessCluster extends ServerlessClusterBase { private readonly singleUserRotationApplication: secretsmanager.SecretRotationApplication; private readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication; - constructor(scope:Construct, id: string, props: ServerlessClusterProps) { + constructor(scope: Construct, id: string, props: ServerlessClusterProps) { super(scope, id); this.vpc = props.vpc; From 4d20079c6c6e8343a3807beb5dbaca841d77c3d6 Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Sat, 3 Oct 2020 18:03:26 +0530 Subject: [PATCH 02/47] fix(glue): incorrect s3 prefix used for grant* in Table (#10627) Fix incorrect s3 prefix used for grant* in Table closes #10582 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-glue/lib/table.ts | 10 +++++++--- .../@aws-cdk/aws-glue/test/integ.table.expected.json | 6 +++--- packages/@aws-cdk/aws-glue/test/table.test.ts | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/aws-glue/lib/table.ts b/packages/@aws-cdk/aws-glue/lib/table.ts index 59b5e551ebc03..76971993b581b 100644 --- a/packages/@aws-cdk/aws-glue/lib/table.ts +++ b/packages/@aws-cdk/aws-glue/lib/table.ts @@ -297,7 +297,7 @@ export class Table extends Resource implements ITable { public grantRead(grantee: iam.IGrantable): iam.Grant { const ret = this.grant(grantee, readPermissions); if (this.encryptionKey && this.encryption === TableEncryption.CLIENT_SIDE_KMS) { this.encryptionKey.grantDecrypt(grantee); } - this.bucket.grantRead(grantee, this.s3Prefix); + this.bucket.grantRead(grantee, this.getS3PrefixForGrant()); return ret; } @@ -309,7 +309,7 @@ export class Table extends Resource implements ITable { public grantWrite(grantee: iam.IGrantable): iam.Grant { const ret = this.grant(grantee, writePermissions); if (this.encryptionKey && this.encryption === TableEncryption.CLIENT_SIDE_KMS) { this.encryptionKey.grantEncrypt(grantee); } - this.bucket.grantWrite(grantee, this.s3Prefix); + this.bucket.grantWrite(grantee, this.getS3PrefixForGrant()); return ret; } @@ -321,7 +321,7 @@ export class Table extends Resource implements ITable { public grantReadWrite(grantee: iam.IGrantable): iam.Grant { const ret = this.grant(grantee, [...readPermissions, ...writePermissions]); if (this.encryptionKey && this.encryption === TableEncryption.CLIENT_SIDE_KMS) { this.encryptionKey.grantEncryptDecrypt(grantee); } - this.bucket.grantReadWrite(grantee, this.s3Prefix); + this.bucket.grantReadWrite(grantee, this.getS3PrefixForGrant()); return ret; } @@ -332,6 +332,10 @@ export class Table extends Resource implements ITable { actions, }); } + + private getS3PrefixForGrant() { + return this.s3Prefix + '*'; + } } function validateSchema(columns: Column[], partitionKeys?: Column[]): void { diff --git a/packages/@aws-cdk/aws-glue/test/integ.table.expected.json b/packages/@aws-cdk/aws-glue/test/integ.table.expected.json index de662c9fea636..a7e41f98f7e82 100644 --- a/packages/@aws-cdk/aws-glue/test/integ.table.expected.json +++ b/packages/@aws-cdk/aws-glue/test/integ.table.expected.json @@ -537,7 +537,7 @@ "Arn" ] }, - "/" + "/*" ] ] } @@ -614,7 +614,7 @@ "Arn" ] }, - "/" + "/*" ] ] } @@ -726,7 +726,7 @@ "Arn" ] }, - "/" + "/*" ] ] } diff --git a/packages/@aws-cdk/aws-glue/test/table.test.ts b/packages/@aws-cdk/aws-glue/test/table.test.ts index 7da75572f4ffb..4cad8b4b0efd3 100644 --- a/packages/@aws-cdk/aws-glue/test/table.test.ts +++ b/packages/@aws-cdk/aws-glue/test/table.test.ts @@ -1240,7 +1240,7 @@ test('grants: read only', () => { 'Arn', ], }, - '/', + '/*', ], ], }, @@ -1343,7 +1343,7 @@ test('grants: write only', () => { 'Arn', ], }, - '/', + '/*', ], ], }, @@ -1456,7 +1456,7 @@ test('grants: read and write', () => { 'Arn', ], }, - '/', + '/*', ], ], }, From b0c56999be6a1756b95eb9d976b36598a91c8316 Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Sat, 3 Oct 2020 18:32:05 +0530 Subject: [PATCH 03/47] fix(glue): GetTableVersion permission not available for read (#10628) Fix `glue:GetTableVersion` permission not available for read closes #10577 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-glue/lib/table.ts | 1 + packages/@aws-cdk/aws-glue/test/integ.table.expected.json | 5 +++++ packages/@aws-cdk/aws-glue/test/table.test.ts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/packages/@aws-cdk/aws-glue/lib/table.ts b/packages/@aws-cdk/aws-glue/lib/table.ts index 76971993b581b..859bb0b2ee325 100644 --- a/packages/@aws-cdk/aws-glue/lib/table.ts +++ b/packages/@aws-cdk/aws-glue/lib/table.ts @@ -406,6 +406,7 @@ const readPermissions = [ 'glue:GetPartitions', 'glue:GetTable', 'glue:GetTables', + 'glue:GetTableVersion', 'glue:GetTableVersions', ]; diff --git a/packages/@aws-cdk/aws-glue/test/integ.table.expected.json b/packages/@aws-cdk/aws-glue/test/integ.table.expected.json index a7e41f98f7e82..d9f6d7f602195 100644 --- a/packages/@aws-cdk/aws-glue/test/integ.table.expected.json +++ b/packages/@aws-cdk/aws-glue/test/integ.table.expected.json @@ -474,6 +474,7 @@ "glue:GetPartitions", "glue:GetTable", "glue:GetTables", + "glue:GetTableVersion", "glue:GetTableVersions", "glue:BatchCreatePartition", "glue:BatchDeletePartition", @@ -551,6 +552,7 @@ "glue:GetPartitions", "glue:GetTable", "glue:GetTables", + "glue:GetTableVersion", "glue:GetTableVersions", "glue:BatchCreatePartition", "glue:BatchDeletePartition", @@ -663,6 +665,7 @@ "glue:GetPartitions", "glue:GetTable", "glue:GetTables", + "glue:GetTableVersion", "glue:GetTableVersions", "glue:BatchCreatePartition", "glue:BatchDeletePartition", @@ -740,6 +743,7 @@ "glue:GetPartitions", "glue:GetTable", "glue:GetTables", + "glue:GetTableVersion", "glue:GetTableVersions", "glue:BatchCreatePartition", "glue:BatchDeletePartition", @@ -784,6 +788,7 @@ "glue:GetPartitions", "glue:GetTable", "glue:GetTables", + "glue:GetTableVersion", "glue:GetTableVersions", "glue:BatchCreatePartition", "glue:BatchDeletePartition", diff --git a/packages/@aws-cdk/aws-glue/test/table.test.ts b/packages/@aws-cdk/aws-glue/test/table.test.ts index 4cad8b4b0efd3..ec92e7ced4ff2 100644 --- a/packages/@aws-cdk/aws-glue/test/table.test.ts +++ b/packages/@aws-cdk/aws-glue/test/table.test.ts @@ -1185,6 +1185,7 @@ test('grants: read only', () => { 'glue:GetPartitions', 'glue:GetTable', 'glue:GetTables', + 'glue:GetTableVersion', 'glue:GetTableVersions', ], Effect: 'Allow', @@ -1393,6 +1394,7 @@ test('grants: read and write', () => { 'glue:GetPartitions', 'glue:GetTable', 'glue:GetTables', + 'glue:GetTableVersion', 'glue:GetTableVersions', 'glue:BatchCreatePartition', 'glue:BatchDeletePartition', From dd543d121de159c40788425f7f421835a1e0d5b7 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Sat, 3 Oct 2020 10:28:33 -0300 Subject: [PATCH 04/47] chore(s3): arnForObjects docstring refers to wrong signature (#10658) I'm not sure how the docs got rolledback, but `arnForObjects` behavior was changed in https://github.com/aws/aws-cdk/commit/5ac6e7768a2130d925f6afb13cc49b352dd6ff64. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-s3/lib/bucket.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-s3/lib/bucket.ts b/packages/@aws-cdk/aws-s3/lib/bucket.ts index 1e2357c4d840c..5142995ca0937 100644 --- a/packages/@aws-cdk/aws-s3/lib/bucket.ts +++ b/packages/@aws-cdk/aws-s3/lib/bucket.ts @@ -500,9 +500,9 @@ abstract class BucketBase extends Resource implements IBucket { * Returns an ARN that represents all objects within the bucket that match * the key pattern specified. To represent all keys, specify ``"*"``. * - * If you specify multiple components for keyPattern, they will be concatenated:: + * If you need to specify a keyPattern with multiple components, concatenate them into a single string, e.g.: * - * arnForObjects('home/', team, '/', user, '/*') + * arnForObjects(`home/${team}/${user}/*`) * */ public arnForObjects(keyPattern: string): string { From 92080a22fdda6f68d17a32a7efa27b841c8afcdb Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Sun, 4 Oct 2020 16:03:28 +0100 Subject: [PATCH 05/47] chore(core): migrate constructs to use "constructs" module (#10655) With all of CDK construct libraries in the repo migrated[1],[2],[3] to use "constructs" module, finally move "core" module also to use the same pattern. [1]: https://github.com/aws/aws-cdk/commit/c17969926a2644fc9607dd9b5f105450ed64309a [2]: https://github.com/aws/aws-cdk/commit/60c782fe173449ebf912f509de7db6df89985915 [3]: https://github.com/aws/aws-cdk/commit/a76428bd8559e497cd631d17ff9af2a01792b4c2 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/core/lib/asset-staging.ts | 8 ++++++-- .../core/lib/cfn-codedeploy-blue-green-hook.ts | 2 +- packages/@aws-cdk/core/lib/cfn-condition.ts | 2 +- packages/@aws-cdk/core/lib/cfn-element.ts | 16 ++++++++++------ packages/@aws-cdk/core/lib/cfn-hook.ts | 2 +- packages/@aws-cdk/core/lib/cfn-include.ts | 2 +- packages/@aws-cdk/core/lib/cfn-json.ts | 8 ++++++-- packages/@aws-cdk/core/lib/cfn-mapping.ts | 2 +- packages/@aws-cdk/core/lib/cfn-output.ts | 2 +- packages/@aws-cdk/core/lib/cfn-parameter.ts | 2 +- packages/@aws-cdk/core/lib/cfn-resource.ts | 8 ++++---- packages/@aws-cdk/core/lib/cfn-rule.ts | 2 +- .../custom-resource-provider.ts | 8 ++++++-- packages/@aws-cdk/core/lib/custom-resource.ts | 2 +- packages/@aws-cdk/core/lib/nested-stack.ts | 10 +++++++--- packages/@aws-cdk/core/lib/stack.ts | 10 +++++++--- packages/@aws-cdk/core/lib/stage.ts | 9 ++++++--- packages/@aws-cdk/core/lib/tag-aspect.ts | 2 +- packages/@aws-cdk/core/lib/util.ts | 2 +- packages/@aws-cdk/core/package.json | 5 ++++- packages/awslint/lib/rules/construct.ts | 2 +- 21 files changed, 68 insertions(+), 38 deletions(-) diff --git a/packages/@aws-cdk/core/lib/asset-staging.ts b/packages/@aws-cdk/core/lib/asset-staging.ts index 53f607f9588a0..ca051c2c48165 100644 --- a/packages/@aws-cdk/core/lib/asset-staging.ts +++ b/packages/@aws-cdk/core/lib/asset-staging.ts @@ -2,14 +2,18 @@ import * as crypto from 'crypto'; import * as os from 'os'; import * as path from 'path'; import * as cxapi from '@aws-cdk/cx-api'; +import { Construct } from 'constructs'; import * as fs from 'fs-extra'; import { AssetHashType, AssetOptions } from './assets'; import { BundlingOptions } from './bundling'; -import { Construct } from './construct-compat'; import { FileSystem, FingerprintOptions } from './fs'; import { Stack } from './stack'; import { Stage } from './stage'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from './construct-compat'; + /** * Initialization properties for `AssetStaging`. */ @@ -38,7 +42,7 @@ export interface AssetStagingProps extends FingerprintOptions, AssetOptions { * The file/directory are staged based on their content hash (fingerprint). This * means that only if content was changed, copy will happen. */ -export class AssetStaging extends Construct { +export class AssetStaging extends CoreConstruct { /** * The directory inside the bundling container into which the asset sources will be mounted. * @experimental diff --git a/packages/@aws-cdk/core/lib/cfn-codedeploy-blue-green-hook.ts b/packages/@aws-cdk/core/lib/cfn-codedeploy-blue-green-hook.ts index 67f1b1b489fc5..c0950afb258af 100644 --- a/packages/@aws-cdk/core/lib/cfn-codedeploy-blue-green-hook.ts +++ b/packages/@aws-cdk/core/lib/cfn-codedeploy-blue-green-hook.ts @@ -1,7 +1,7 @@ +import { Construct } from 'constructs'; import { CfnHook } from './cfn-hook'; import { FromCloudFormationOptions } from './cfn-parse'; import { CfnResource } from './cfn-resource'; -import { Construct } from './construct-compat'; /** * The possible types of traffic shifting for the blue-green deployment configuration. diff --git a/packages/@aws-cdk/core/lib/cfn-condition.ts b/packages/@aws-cdk/core/lib/cfn-condition.ts index 354ad1f32d122..db3fe5915e512 100644 --- a/packages/@aws-cdk/core/lib/cfn-condition.ts +++ b/packages/@aws-cdk/core/lib/cfn-condition.ts @@ -1,5 +1,5 @@ +import { Construct } from 'constructs'; import { CfnElement } from './cfn-element'; -import { Construct } from './construct-compat'; import { IResolvable, IResolveContext } from './resolvable'; export interface CfnConditionProps { diff --git a/packages/@aws-cdk/core/lib/cfn-element.ts b/packages/@aws-cdk/core/lib/cfn-element.ts index 7aadf278f13cd..d381441f9a19e 100644 --- a/packages/@aws-cdk/core/lib/cfn-element.ts +++ b/packages/@aws-cdk/core/lib/cfn-element.ts @@ -1,14 +1,17 @@ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Construct } from './construct-compat'; +import { Construct, Node } from 'constructs'; + +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from './construct-compat'; import { Lazy } from './lazy'; -import { Token } from './token'; const CFN_ELEMENT_SYMBOL = Symbol.for('@aws-cdk/core.CfnElement'); /** * An element of a CloudFormation stack. */ -export abstract class CfnElement extends Construct { +export abstract class CfnElement extends CoreConstruct { /** * Returns `true` if a construct is a stack element (i.e. part of the * synthesized cloudformation template). @@ -58,10 +61,10 @@ export abstract class CfnElement extends Construct { this.stack = Stack.of(this); this.logicalId = Lazy.stringValue({ produce: () => this.synthesizeLogicalId() }, { - displayHint: `${notTooLong(this.node.path)}.LogicalID`, + displayHint: `${notTooLong(Node.of(this).path)}.LogicalID`, }); - this.node.addMetadata(cxschema.ArtifactMetadataEntryType.LOGICAL_ID, this.logicalId, this.constructor); + Node.of(this).addMetadata(cxschema.ArtifactMetadataEntryType.LOGICAL_ID, this.logicalId, this.constructor); } /** @@ -78,7 +81,7 @@ export abstract class CfnElement extends Construct { * node +internal+ entries filtered. */ public get creationStack(): string[] { - const trace = this.node.metadata.find(md => md.type === cxschema.ArtifactMetadataEntryType.LOGICAL_ID)!.trace; + const trace = Node.of(this).metadata.find(md => md.type === cxschema.ArtifactMetadataEntryType.LOGICAL_ID)!.trace; if (!trace) { return []; } @@ -161,3 +164,4 @@ function notTooLong(x: string) { import { CfnReference } from './private/cfn-reference'; import { Stack } from './stack'; +import { Token } from './token'; diff --git a/packages/@aws-cdk/core/lib/cfn-hook.ts b/packages/@aws-cdk/core/lib/cfn-hook.ts index 8e83ae4e8da28..3860e5afbc701 100644 --- a/packages/@aws-cdk/core/lib/cfn-hook.ts +++ b/packages/@aws-cdk/core/lib/cfn-hook.ts @@ -1,5 +1,5 @@ +import { Construct } from 'constructs'; import { CfnElement } from './cfn-element'; -import { Construct } from './construct-compat'; import { ignoreEmpty } from './util'; /** diff --git a/packages/@aws-cdk/core/lib/cfn-include.ts b/packages/@aws-cdk/core/lib/cfn-include.ts index 61f70072f47a6..4cfedc1c03c25 100644 --- a/packages/@aws-cdk/core/lib/cfn-include.ts +++ b/packages/@aws-cdk/core/lib/cfn-include.ts @@ -1,5 +1,5 @@ +import { Construct } from 'constructs'; import { CfnElement } from './cfn-element'; -import { Construct } from './construct-compat'; export interface CfnIncludeProps { /** diff --git a/packages/@aws-cdk/core/lib/cfn-json.ts b/packages/@aws-cdk/core/lib/cfn-json.ts index eee32038a0099..0e5801ed8ade9 100644 --- a/packages/@aws-cdk/core/lib/cfn-json.ts +++ b/packages/@aws-cdk/core/lib/cfn-json.ts @@ -1,4 +1,4 @@ -import { Construct } from './construct-compat'; +import { Construct } from 'constructs'; import { CustomResource } from './custom-resource'; import { CfnUtilsProvider } from './private/cfn-utils-provider'; import { CfnUtilsResourceType } from './private/cfn-utils-provider/consts'; @@ -7,6 +7,10 @@ import { IResolvable, IResolveContext } from './resolvable'; import { Stack } from './stack'; import { captureStackTrace } from './stack-trace'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from './construct-compat'; + export interface CfnJsonProps { /** * The value to resolve. Can be any JavaScript object, including tokens and @@ -29,7 +33,7 @@ export interface CfnJsonProps { * * This construct is backed by a custom resource. */ -export class CfnJson extends Construct implements IResolvable { +export class CfnJson extends CoreConstruct implements IResolvable { public readonly creationStack: string[] = []; /** diff --git a/packages/@aws-cdk/core/lib/cfn-mapping.ts b/packages/@aws-cdk/core/lib/cfn-mapping.ts index 7399d29f31e81..196baf3aadb96 100644 --- a/packages/@aws-cdk/core/lib/cfn-mapping.ts +++ b/packages/@aws-cdk/core/lib/cfn-mapping.ts @@ -1,6 +1,6 @@ +import { Construct } from 'constructs'; import { CfnRefElement } from './cfn-element'; import { Fn } from './cfn-fn'; -import { Construct } from './construct-compat'; import { Token } from './token'; export interface CfnMappingProps { diff --git a/packages/@aws-cdk/core/lib/cfn-output.ts b/packages/@aws-cdk/core/lib/cfn-output.ts index 3f2784f890073..ae1a52159244c 100644 --- a/packages/@aws-cdk/core/lib/cfn-output.ts +++ b/packages/@aws-cdk/core/lib/cfn-output.ts @@ -1,5 +1,5 @@ +import { Construct } from 'constructs'; import { CfnElement } from './cfn-element'; -import { Construct } from './construct-compat'; export interface CfnOutputProps { /** diff --git a/packages/@aws-cdk/core/lib/cfn-parameter.ts b/packages/@aws-cdk/core/lib/cfn-parameter.ts index c9f219d17ae72..18182f5ef7de2 100644 --- a/packages/@aws-cdk/core/lib/cfn-parameter.ts +++ b/packages/@aws-cdk/core/lib/cfn-parameter.ts @@ -1,5 +1,5 @@ +import { Construct } from 'constructs'; import { CfnElement } from './cfn-element'; -import { Construct } from './construct-compat'; import { CfnReference } from './private/cfn-reference'; import { IResolvable, IResolveContext } from './resolvable'; import { Token } from './token'; diff --git a/packages/@aws-cdk/core/lib/cfn-resource.ts b/packages/@aws-cdk/core/lib/cfn-resource.ts index 4cb8934617c2b..c899d95b657c8 100644 --- a/packages/@aws-cdk/core/lib/cfn-resource.ts +++ b/packages/@aws-cdk/core/lib/cfn-resource.ts @@ -4,7 +4,7 @@ import { CfnCondition } from './cfn-condition'; /* eslint-disable import/order */ import { CfnRefElement } from './cfn-element'; import { CfnCreationPolicy, CfnDeletionPolicy, CfnUpdatePolicy } from './cfn-resource-policy'; -import { Construct, IConstruct } from './construct-compat'; +import { Construct, IConstruct, Node } from 'constructs'; import { addDependency } from './deps'; import { CfnReference } from './private/cfn-reference'; import { Reference } from './reference'; @@ -92,8 +92,8 @@ export class CfnResource extends CfnRefElement { // if aws:cdk:enable-path-metadata is set, embed the current construct's // path in the CloudFormation template, so it will be possible to trace // back to the actual construct path. - if (this.node.tryGetContext(cxapi.PATH_METADATA_ENABLE_CONTEXT)) { - this.addMetadata(cxapi.PATH_METADATA_KEY, this.node.path); + if (Node.of(this).tryGetContext(cxapi.PATH_METADATA_ENABLE_CONTEXT)) { + this.addMetadata(cxapi.PATH_METADATA_KEY, Node.of(this).path); } } @@ -238,7 +238,7 @@ export class CfnResource extends CfnRefElement { return; } - addDependency(this, target, `"${this.node.path}" depends on "${target.node.path}"`); + addDependency(this, target, `"${Node.of(this).path}" depends on "${Node.of(target).path}"`); } /** diff --git a/packages/@aws-cdk/core/lib/cfn-rule.ts b/packages/@aws-cdk/core/lib/cfn-rule.ts index 847c67982192b..f3141ca636ce2 100644 --- a/packages/@aws-cdk/core/lib/cfn-rule.ts +++ b/packages/@aws-cdk/core/lib/cfn-rule.ts @@ -1,6 +1,6 @@ +import { Construct } from 'constructs'; import { ICfnConditionExpression } from './cfn-condition'; import { CfnRefElement } from './cfn-element'; -import { Construct } from './construct-compat'; import { capitalizePropertyNames } from './util'; /** diff --git a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts index 10b53033f3f7c..821307e466a77 100644 --- a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts +++ b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts @@ -1,9 +1,9 @@ import * as fs from 'fs'; import * as path from 'path'; +import { Construct } from 'constructs'; import { AssetStaging } from '../asset-staging'; import { FileAssetPackaging } from '../assets'; import { CfnResource } from '../cfn-resource'; -import { Construct } from '../construct-compat'; import { Duration } from '../duration'; import { Size } from '../size'; import { Stack } from '../stack'; @@ -12,6 +12,10 @@ import { Token } from '../token'; const ENTRYPOINT_FILENAME = '__entrypoint__'; const ENTRYPOINT_NODEJS_SOURCE = path.join(__dirname, 'nodejs-entrypoint.js'); +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from '../construct-compat'; + /** * Initialization properties for `CustomResourceProvider`. * @@ -75,7 +79,7 @@ export enum CustomResourceProviderRuntime { * * @experimental */ -export class CustomResourceProvider extends Construct { +export class CustomResourceProvider extends CoreConstruct { /** * Returns a stack-level singleton ARN (service token) for the custom resource * provider. diff --git a/packages/@aws-cdk/core/lib/custom-resource.ts b/packages/@aws-cdk/core/lib/custom-resource.ts index 6926d8fc31a56..7fbf9505cf971 100644 --- a/packages/@aws-cdk/core/lib/custom-resource.ts +++ b/packages/@aws-cdk/core/lib/custom-resource.ts @@ -1,5 +1,5 @@ +import { Construct } from 'constructs'; import { CfnResource } from './cfn-resource'; -import { Construct } from './construct-compat'; import { RemovalPolicy } from './removal-policy'; import { Resource } from './resource'; import { Token } from './token'; diff --git a/packages/@aws-cdk/core/lib/nested-stack.ts b/packages/@aws-cdk/core/lib/nested-stack.ts index 7e52427467039..395d3bd63c8c5 100644 --- a/packages/@aws-cdk/core/lib/nested-stack.ts +++ b/packages/@aws-cdk/core/lib/nested-stack.ts @@ -1,10 +1,10 @@ import * as crypto from 'crypto'; +import { Construct, Node } from 'constructs'; import { FileAssetPackaging } from './assets'; import { Fn } from './cfn-fn'; import { Aws } from './cfn-pseudo'; import { CfnResource } from './cfn-resource'; import { CfnStack } from './cloudformation.generated'; -import { Construct } from './construct-compat'; import { Duration } from './duration'; import { Lazy } from './lazy'; import { IResolveContext } from './resolvable'; @@ -12,6 +12,10 @@ import { Stack } from './stack'; import { NestedStackSynthesizer } from './stack-synthesizers'; import { Token } from './token'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from './construct-compat'; + const NESTED_STACK_SYMBOL = Symbol.for('@aws-cdk/core.NestedStack'); /** @@ -105,7 +109,7 @@ export class NestedStack extends Stack { this._parentStack = parentStack; // @deprecate: remove this in v2.0 (redundent) - const parentScope = new Construct(scope, id + '.NestedStack'); + const parentScope = new CoreConstruct(scope, id + '.NestedStack'); Object.defineProperty(this, NESTED_STACK_SYMBOL, { value: true }); @@ -223,7 +227,7 @@ function findParentStack(scope: Construct): Stack { throw new Error('Nested stacks cannot be defined as a root construct'); } - const parentStack = scope.node.scopes.reverse().find(p => Stack.isStack(p)); + const parentStack = Node.of(scope).scopes.reverse().find(p => Stack.isStack(p)); if (!parentStack) { throw new Error('Nested stacks must be defined within scope of another non-nested stack'); } diff --git a/packages/@aws-cdk/core/lib/stack.ts b/packages/@aws-cdk/core/lib/stack.ts index 8d9c57fe91942..88f407ef01839 100644 --- a/packages/@aws-cdk/core/lib/stack.ts +++ b/packages/@aws-cdk/core/lib/stack.ts @@ -2,7 +2,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as cxschema from '@aws-cdk/cloud-assembly-schema'; import * as cxapi from '@aws-cdk/cx-api'; -import { IConstruct, Node } from 'constructs'; +import { IConstruct, Construct, Node } from 'constructs'; import { Annotations } from './annotations'; import { App } from './app'; import { Arn, ArnComponents } from './arn'; @@ -11,7 +11,7 @@ import { CfnElement } from './cfn-element'; import { Fn } from './cfn-fn'; import { Aws, ScopedAws } from './cfn-pseudo'; import { CfnResource, TagType } from './cfn-resource'; -import { Construct, ISynthesisSession } from './construct-compat'; +import { ISynthesisSession } from './construct-compat'; import { ContextProvider } from './context-provider'; import { Environment } from './environment'; import { FeatureFlags } from './feature-flags'; @@ -20,6 +20,10 @@ import { LogicalIDs } from './private/logical-id'; import { resolve } from './private/resolve'; import { makeUniqueId } from './private/uniqueid'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from './construct-compat'; + const STACK_SYMBOL = Symbol.for('@aws-cdk/core.Stack'); const MY_STACK_CACHE = Symbol.for('@aws-cdk/core.Stack.myStack'); @@ -140,7 +144,7 @@ export interface StackProps { /** * A root construct which represents a single CloudFormation stack. */ -export class Stack extends Construct implements ITaggable { +export class Stack extends CoreConstruct implements ITaggable { /** * Return whether the given object is a Stack. * diff --git a/packages/@aws-cdk/core/lib/stage.ts b/packages/@aws-cdk/core/lib/stage.ts index bf18e89d89313..50ef0b7c5b081 100644 --- a/packages/@aws-cdk/core/lib/stage.ts +++ b/packages/@aws-cdk/core/lib/stage.ts @@ -1,9 +1,12 @@ import * as cxapi from '@aws-cdk/cx-api'; -import { IConstruct, Node } from 'constructs'; -import { Construct } from './construct-compat'; +import { IConstruct, Construct, Node } from 'constructs'; import { Environment } from './environment'; import { synthesize } from './private/synthesis'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from './construct-compat'; + /** * Initialization props for a stage. */ @@ -65,7 +68,7 @@ export interface StageProps { * copies of your application which should be be deployed to different * environments. */ -export class Stage extends Construct { +export class Stage extends CoreConstruct { /** * Return the stage this construct is contained with, if available. If called * on a nested stage, returns its parent. diff --git a/packages/@aws-cdk/core/lib/tag-aspect.ts b/packages/@aws-cdk/core/lib/tag-aspect.ts index 34d9a6dfd4e40..d56c28b551d87 100644 --- a/packages/@aws-cdk/core/lib/tag-aspect.ts +++ b/packages/@aws-cdk/core/lib/tag-aspect.ts @@ -1,8 +1,8 @@ // import * as cxapi from '@aws-cdk/cx-api'; +import { Annotations } from './annotations'; import { IAspect, Aspects } from './aspect'; import { Construct, IConstruct } from './construct-compat'; import { ITaggable, TagManager } from './tag-manager'; -import { Annotations } from './annotations'; /** * Properties for a tag diff --git a/packages/@aws-cdk/core/lib/util.ts b/packages/@aws-cdk/core/lib/util.ts index 6924b197667af..e626600a206cd 100644 --- a/packages/@aws-cdk/core/lib/util.ts +++ b/packages/@aws-cdk/core/lib/util.ts @@ -1,4 +1,4 @@ -import { IConstruct } from './construct-compat'; +import { IConstruct } from 'constructs'; import { Intrinsic } from './private/intrinsic'; import { IPostProcessor, IResolveContext } from './resolvable'; import { Stack } from './stack'; diff --git a/packages/@aws-cdk/core/package.json b/packages/@aws-cdk/core/package.json index 87db86c38a8e1..130dc095e88eb 100644 --- a/packages/@aws-cdk/core/package.json +++ b/packages/@aws-cdk/core/package.json @@ -141,7 +141,10 @@ "cfn2ts-core-import": ".", "pre": [ "rm -rf test/fs/fixtures && cd test/fs && tar -xzf fixtures.tar.gz" - ] + ], + "env": { + "AWSLINT_BASE_CONSTRUCT": "true" + } }, "nyc": { "statements": 55, diff --git a/packages/awslint/lib/rules/construct.ts b/packages/awslint/lib/rules/construct.ts index 0cdb50eebded6..8e591e1f27d8f 100644 --- a/packages/awslint/lib/rules/construct.ts +++ b/packages/awslint/lib/rules/construct.ts @@ -97,7 +97,7 @@ constructLinter.add({ const expectedParams = new Array(); let baseType; - if (process.env.AWSLINT_BASE_CONSTRUCT && !initializer.parentType.name.startsWith('Cfn')) { + if (process.env.AWSLINT_BASE_CONSTRUCT && !CoreTypes.isCfnResource(e.ctx.classType)) { baseType = e.ctx.core.baseConstructClass; } else { baseType = e.ctx.core.constructClass; From 9e11e5ae09b883e1a573c5ebc3dc7222f9851cbc Mon Sep 17 00:00:00 2001 From: sullis Date: Sun, 4 Oct 2020 20:23:36 -0700 Subject: [PATCH 06/47] chore(java): JUnit 4.12 -> JUnit 4.13 (#10670) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/lib/init-templates/app/java/pom.template.xml | 2 +- .../aws-cdk/lib/init-templates/sample-app/java/pom.template.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/init-templates/app/java/pom.template.xml b/packages/aws-cdk/lib/init-templates/app/java/pom.template.xml index b5332bc56e493..18a08d803562f 100644 --- a/packages/aws-cdk/lib/init-templates/app/java/pom.template.xml +++ b/packages/aws-cdk/lib/init-templates/app/java/pom.template.xml @@ -47,7 +47,7 @@ junit junit - 4.12 + 4.13 test diff --git a/packages/aws-cdk/lib/init-templates/sample-app/java/pom.template.xml b/packages/aws-cdk/lib/init-templates/sample-app/java/pom.template.xml index 00c69e22164ba..7159e270096a4 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/java/pom.template.xml +++ b/packages/aws-cdk/lib/init-templates/sample-app/java/pom.template.xml @@ -59,7 +59,7 @@ junit junit - 4.12 + 4.13 test From 63088e1ae92d810a3954ae87031c2989e0b04327 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 5 Oct 2020 10:28:19 +0200 Subject: [PATCH 07/47] chore: move 'core' tests to jest via nodeunit-shim (#10661) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/core/.gitignore | 3 +- packages/@aws-cdk/core/.npmignore | 3 +- packages/@aws-cdk/core/jest.config.js | 10 ++++++ packages/@aws-cdk/core/lib/tag-manager.ts | 24 ++++++++++---- packages/@aws-cdk/core/package.json | 4 +-- ...est.annotations.ts => annotations.test.ts} | 6 ++-- .../core/test/{test.app.ts => app.test.ts} | 10 +++--- .../core/test/{test.arn.ts => arn.test.ts} | 6 ++-- .../test/{test.aspect.ts => aspect.test.ts} | 6 ++-- .../test/{test.assets.ts => assets.test.ts} | 6 ++-- .../{test.bundling.ts => bundling.test.ts} | 6 ++-- .../{test.cfn-json.ts => cfn-json.test.ts} | 6 ++-- ...cfn-parameter.ts => cfn-parameter.test.ts} | 6 ++-- ...t.cfn-resource.ts => cfn-resource.test.ts} | 20 ++++++------ ...on-json.ts => cloudformation-json.test.ts} | 6 ++-- .../{test.condition.ts => condition.test.ts} | 6 ++-- .../{test.construct.ts => construct.test.ts} | 6 ++-- .../test/{test.context.ts => context.test.ts} | 6 ++-- ...ken.ts => cross-environment-token.test.ts} | 6 ++-- ...er.ts => custom-resource-provider.test.ts} | 6 ++-- ...ntrypoint.ts => nodejs-entrypoint.test.ts} | 8 ++--- ...om-resource.ts => custom-resource.test.ts} | 6 ++-- .../{test.duration.ts => duration.test.ts} | 32 +++++++++---------- ...reference.ts => dynamic-reference.test.ts} | 6 ++-- ...est.environment.ts => environment.test.ts} | 6 ++-- ...{test.expiration.ts => expiration.test.ts} | 18 +++++------ ...feature-flags.ts => feature-flags.test.ts} | 6 ++-- .../core/test/{test.fn.ts => fn.test.ts} | 24 +++++++------- .../fs/{test.fs-copy.ts => fs-copy.test.ts} | 6 ++-- ...-fingerprint.ts => fs-fingerprint.test.ts} | 6 ++-- .../core/test/fs/{test.fs.ts => fs.test.ts} | 6 ++-- .../test/fs/{test.utils.ts => utils.test.ts} | 6 ++-- .../test/{test.include.ts => include.test.ts} | 6 ++-- ...{test.logical-id.ts => logical-id.test.ts} | 6 ++-- .../{test.mappings.ts => mappings.test.ts} | 10 +++--- .../test/{test.output.ts => output.test.ts} | 6 ++-- .../{test.parameter.ts => parameter.test.ts} | 6 ++-- ...tor.ts => physical-name-generator.test.ts} | 24 +++++++------- ...tree-metadata.ts => tree-metadata.test.ts} | 6 ++-- .../{test.resource.ts => resource.test.ts} | 6 ++-- .../core/test/{test.rule.ts => rule.test.ts} | 6 ++-- ...t.runtime-info.ts => runtime-info.test.ts} | 6 ++-- ...t.secret-value.ts => secret-value.test.ts} | 6 ++-- .../core/test/{test.size.ts => size.test.ts} | 6 ++-- ...nthesis.ts => new-style-synthesis.test.ts} | 8 ++--- .../test/{test.stack.ts => stack.test.ts} | 8 ++--- .../test/{test.stage.ts => stage.test.ts} | 8 ++--- .../test/{test.staging.ts => staging.test.ts} | 6 ++-- .../{test.synthesis.ts => synthesis.test.ts} | 6 ++-- ...{test.tag-aspect.ts => tag-aspect.test.ts} | 6 ++-- ...est.tag-manager.ts => tag-manager.test.ts} | 6 ++-- .../test/{test.tokens.ts => tokens.test.ts} | 8 ++--- .../core/test/{test.util.ts => util.test.ts} | 4 +-- tools/nodeunit-shim/index.ts | 10 +++++- 54 files changed, 238 insertions(+), 208 deletions(-) create mode 100644 packages/@aws-cdk/core/jest.config.js rename packages/@aws-cdk/core/test/{test.annotations.ts => annotations.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.app.ts => app.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.arn.ts => arn.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.aspect.ts => aspect.test.ts} (97%) rename packages/@aws-cdk/core/test/{test.assets.ts => assets.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.bundling.ts => bundling.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.cfn-json.ts => cfn-json.test.ts} (97%) rename packages/@aws-cdk/core/test/{test.cfn-parameter.ts => cfn-parameter.test.ts} (93%) rename packages/@aws-cdk/core/test/{test.cfn-resource.ts => cfn-resource.test.ts} (90%) rename packages/@aws-cdk/core/test/{test.cloudformation-json.ts => cloudformation-json.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.condition.ts => condition.test.ts} (96%) rename packages/@aws-cdk/core/test/{test.construct.ts => construct.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.context.ts => context.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.cross-environment-token.ts => cross-environment-token.test.ts} (98%) rename packages/@aws-cdk/core/test/custom-resource-provider/{test.custom-resource-provider.ts => custom-resource-provider.test.ts} (98%) rename packages/@aws-cdk/core/test/custom-resource-provider/{test.nodejs-entrypoint.ts => nodejs-entrypoint.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.custom-resource.ts => custom-resource.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.duration.ts => duration.test.ts} (88%) rename packages/@aws-cdk/core/test/{test.dynamic-reference.ts => dynamic-reference.test.ts} (84%) rename packages/@aws-cdk/core/test/{test.environment.ts => environment.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.expiration.ts => expiration.test.ts} (80%) rename packages/@aws-cdk/core/test/{test.feature-flags.ts => feature-flags.test.ts} (92%) rename packages/@aws-cdk/core/test/{test.fn.ts => fn.test.ts} (91%) rename packages/@aws-cdk/core/test/fs/{test.fs-copy.ts => fs-copy.test.ts} (98%) rename packages/@aws-cdk/core/test/fs/{test.fs-fingerprint.ts => fs-fingerprint.test.ts} (98%) rename packages/@aws-cdk/core/test/fs/{test.fs.ts => fs.test.ts} (95%) rename packages/@aws-cdk/core/test/fs/{test.utils.ts => utils.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.include.ts => include.test.ts} (97%) rename packages/@aws-cdk/core/test/{test.logical-id.ts => logical-id.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.mappings.ts => mappings.test.ts} (94%) rename packages/@aws-cdk/core/test/{test.output.ts => output.test.ts} (93%) rename packages/@aws-cdk/core/test/{test.parameter.ts => parameter.test.ts} (94%) rename packages/@aws-cdk/core/test/private/{test.physical-name-generator.ts => physical-name-generator.test.ts} (84%) rename packages/@aws-cdk/core/test/private/{test.tree-metadata.ts => tree-metadata.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.resource.ts => resource.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.rule.ts => rule.test.ts} (94%) rename packages/@aws-cdk/core/test/{test.runtime-info.ts => runtime-info.test.ts} (97%) rename packages/@aws-cdk/core/test/{test.secret-value.ts => secret-value.test.ts} (97%) rename packages/@aws-cdk/core/test/{test.size.ts => size.test.ts} (98%) rename packages/@aws-cdk/core/test/stack-synthesis/{test.new-style-synthesis.ts => new-style-synthesis.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.stack.ts => stack.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.stage.ts => stage.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.staging.ts => staging.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.synthesis.ts => synthesis.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.tag-aspect.ts => tag-aspect.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.tag-manager.ts => tag-manager.test.ts} (98%) rename packages/@aws-cdk/core/test/{test.tokens.ts => tokens.test.ts} (99%) rename packages/@aws-cdk/core/test/{test.util.ts => util.test.ts} (98%) diff --git a/packages/@aws-cdk/core/.gitignore b/packages/@aws-cdk/core/.gitignore index 5960e89add3c9..3bbfa40f65522 100644 --- a/packages/@aws-cdk/core/.gitignore +++ b/packages/@aws-cdk/core/.gitignore @@ -14,4 +14,5 @@ nyc.config.js *.snk !.eslintrc.js -junit.xml \ No newline at end of file +junit.xml +!jest.config.js \ No newline at end of file diff --git a/packages/@aws-cdk/core/.npmignore b/packages/@aws-cdk/core/.npmignore index dfcc4c31f1c8d..90948e3dcecea 100644 --- a/packages/@aws-cdk/core/.npmignore +++ b/packages/@aws-cdk/core/.npmignore @@ -25,4 +25,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +jest.config.js \ No newline at end of file diff --git a/packages/@aws-cdk/core/jest.config.js b/packages/@aws-cdk/core/jest.config.js new file mode 100644 index 0000000000000..9dd30a713dd6b --- /dev/null +++ b/packages/@aws-cdk/core/jest.config.js @@ -0,0 +1,10 @@ +const baseConfig = require('cdk-build-tools/config/jest.config'); +module.exports = { + ...baseConfig, + coverageThreshold: { + global: { + branches: 60, + statements: 75, + } + } +}; diff --git a/packages/@aws-cdk/core/lib/tag-manager.ts b/packages/@aws-cdk/core/lib/tag-manager.ts index 2189af4bc4929..cdc224500ef1b 100644 --- a/packages/@aws-cdk/core/lib/tag-manager.ts +++ b/packages/@aws-cdk/core/lib/tag-manager.ts @@ -185,12 +185,22 @@ class NoFormat implements ITagFormatter { } } -const TAG_FORMATTERS: {[key: string]: ITagFormatter} = { - [TagType.AUTOSCALING_GROUP]: new AsgFormatter(), - [TagType.STANDARD]: new StandardFormatter(), - [TagType.MAP]: new MapFormatter(), - [TagType.KEY_VALUE]: new KeyValueFormatter(), - [TagType.NOT_TAGGABLE]: new NoFormat(), + +let _tagFormattersCache: {[key: string]: ITagFormatter} | undefined; + +/** + * Access tag formatters table + * + * In a function because we're in a load cycle with cfn-resource that defines `TagType`. + */ +function TAG_FORMATTERS(): {[key: string]: ITagFormatter} { + return _tagFormattersCache ?? (_tagFormattersCache = { + [TagType.AUTOSCALING_GROUP]: new AsgFormatter(), + [TagType.STANDARD]: new StandardFormatter(), + [TagType.MAP]: new MapFormatter(), + [TagType.KEY_VALUE]: new KeyValueFormatter(), + [TagType.NOT_TAGGABLE]: new NoFormat(), + }); }; /** @@ -245,7 +255,7 @@ export class TagManager { constructor(tagType: TagType, resourceTypeName: string, tagStructure?: any, options: TagManagerOptions = { }) { this.resourceTypeName = resourceTypeName; - this.tagFormatter = TAG_FORMATTERS[tagType]; + this.tagFormatter = TAG_FORMATTERS()[tagType]; if (tagStructure !== undefined) { this._setTag(...this.tagFormatter.parseTags(tagStructure, this.initialTagPriority)); } diff --git a/packages/@aws-cdk/core/package.json b/packages/@aws-cdk/core/package.json index 130dc095e88eb..9731f371c38d6 100644 --- a/packages/@aws-cdk/core/package.json +++ b/packages/@aws-cdk/core/package.json @@ -139,6 +139,7 @@ "cdk-build": { "cloudformation": "AWS::CloudFormation", "cfn2ts-core-import": ".", + "jest": true, "pre": [ "rm -rf test/fs/fixtures && cd test/fs && tar -xzf fixtures.tar.gz" ], @@ -167,13 +168,12 @@ "@types/lodash": "^4.14.161", "@types/minimatch": "^3.0.3", "@types/node": "^10.17.35", - "@types/nodeunit": "^0.0.31", "@types/sinon": "^9.0.7", "cdk-build-tools": "0.0.0", "cfn2ts": "0.0.0", "fast-check": "^2.4.0", "lodash": "^4.17.20", - "nodeunit": "^0.11.3", + "nodeunit-shim": "0.0.0", "pkglint": "0.0.0", "sinon": "^9.1.0", "ts-mock-imports": "^1.3.0" diff --git a/packages/@aws-cdk/core/test/test.annotations.ts b/packages/@aws-cdk/core/test/annotations.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.annotations.ts rename to packages/@aws-cdk/core/test/annotations.test.ts index 4a193452a95c2..1b0cbf209c528 100644 --- a/packages/@aws-cdk/core/test/test.annotations.ts +++ b/packages/@aws-cdk/core/test/annotations.test.ts @@ -1,11 +1,11 @@ import { CloudAssembly } from '@aws-cdk/cx-api'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { Construct, App, Stack } from '../lib'; import { Annotations } from '../lib/annotations'; const restore = process.env.CDK_BLOCK_DEPRECATIONS; -export = { +nodeunitShim({ 'tearDown'(cb: any) { process.env.CDK_BLOCK_DEPRECATIONS = restore; // restore to the original value cb(); @@ -78,7 +78,7 @@ export = { test.throws(() => Annotations.of(c1).addDeprecation('foo', 'bar'), /MyStack\/Hello: The API foo is deprecated: bar\. This API will be removed in the next major release/); test.done(); }, -}; +}); function getWarnings(casm: CloudAssembly) { const result = new Array<{ path: string, message: string }>(); diff --git a/packages/@aws-cdk/core/test/test.app.ts b/packages/@aws-cdk/core/test/app.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.app.ts rename to packages/@aws-cdk/core/test/app.test.ts index ac14bcff7e620..27b567b0f71be 100644 --- a/packages/@aws-cdk/core/test/test.app.ts +++ b/packages/@aws-cdk/core/test/app.test.ts @@ -1,6 +1,6 @@ import { ContextProvider } from '@aws-cdk/cloud-assembly-schema'; import * as cxapi from '@aws-cdk/cx-api'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnResource, Construct, Stack, StackProps } from '../lib'; import { Annotations } from '../lib/annotations'; import { App, AppProps } from '../lib/app'; @@ -47,7 +47,7 @@ function synthStack(name: string, includeMetadata: boolean = false, context?: an return stack; } -export = { +nodeunitShim({ 'synthesizes all stacks and returns synthesis result'(test: Test) { const response = synth(); delete (response as any).dir; @@ -57,7 +57,7 @@ export = { const stack1 = response.stacks[0]; test.deepEqual(stack1.stackName, 'stack1'); test.deepEqual(stack1.id, 'stack1'); - test.deepEqual(stack1.environment.account, 12345); + test.deepEqual(stack1.environment.account, '12345'); test.deepEqual(stack1.environment.region, 'us-east-1'); test.deepEqual(stack1.environment.name, 'aws://12345/us-east-1'); test.deepEqual(stack1.template, { @@ -408,7 +408,7 @@ export = { test.done(); }, -}; +}); class MyConstruct extends Construct { constructor(scope: Construct, id: string) { @@ -444,4 +444,4 @@ function withCliVersion(block: () => A): A { } finally { delete process.env[cxapi.CLI_VERSION_ENV]; } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/core/test/test.arn.ts b/packages/@aws-cdk/core/test/arn.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.arn.ts rename to packages/@aws-cdk/core/test/arn.test.ts index 820ceeae21f40..5fa7a83d98f7a 100644 --- a/packages/@aws-cdk/core/test/test.arn.ts +++ b/packages/@aws-cdk/core/test/arn.test.ts @@ -1,9 +1,9 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { ArnComponents, Aws, CfnOutput, ScopedAws, Stack } from '../lib'; import { Intrinsic } from '../lib/private/intrinsic'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'create from components with defaults'(test: Test) { const stack = new Stack(); @@ -277,4 +277,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.aspect.ts b/packages/@aws-cdk/core/test/aspect.test.ts similarity index 97% rename from packages/@aws-cdk/core/test/test.aspect.ts rename to packages/@aws-cdk/core/test/aspect.test.ts index 90294a86055a7..5a94e397a91da 100644 --- a/packages/@aws-cdk/core/test/test.aspect.ts +++ b/packages/@aws-cdk/core/test/aspect.test.ts @@ -1,5 +1,5 @@ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App } from '../lib'; import { IAspect, Aspects } from '../lib/aspect'; import { Construct, IConstruct } from '../lib/construct-compat'; @@ -25,7 +25,7 @@ class MyAspect implements IAspect { } } -export = { +nodeunitShim({ 'Aspects are invoked only once'(test: Test) { const app = new App(); const root = new MyConstruct(app, 'MyConstruct'); @@ -74,4 +74,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.assets.ts b/packages/@aws-cdk/core/test/assets.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.assets.ts rename to packages/@aws-cdk/core/test/assets.test.ts index 5f77e89db470f..fcfae3a9d147f 100644 --- a/packages/@aws-cdk/core/test/test.assets.ts +++ b/packages/@aws-cdk/core/test/assets.test.ts @@ -1,9 +1,9 @@ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { FileAssetPackaging, Stack } from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'addFileAsset correctly sets metadata and creates S3 parameters'(test: Test) { // GIVEN const stack = new Stack(); @@ -156,4 +156,4 @@ export = { test.deepEqual(toCloudFormation(stack), { }); test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.bundling.ts b/packages/@aws-cdk/core/test/bundling.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.bundling.ts rename to packages/@aws-cdk/core/test/bundling.test.ts index 566e5c5008c25..411ddc0f1cb92 100644 --- a/packages/@aws-cdk/core/test/test.bundling.ts +++ b/packages/@aws-cdk/core/test/bundling.test.ts @@ -1,9 +1,9 @@ import * as child_process from 'child_process'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import * as sinon from 'sinon'; import { BundlingDockerImage, FileSystem } from '../lib'; -export = { +nodeunitShim({ 'tearDown'(callback: any) { sinon.restore(); callback(); @@ -152,4 +152,4 @@ export = { test.ok(fingerprintStub.calledWith('docker-path', sinon.match({ extraHash: JSON.stringify({}) }))); test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.cfn-json.ts b/packages/@aws-cdk/core/test/cfn-json.test.ts similarity index 97% rename from packages/@aws-cdk/core/test/test.cfn-json.ts rename to packages/@aws-cdk/core/test/cfn-json.test.ts index 73943cb11f4ab..85ee12c822cb8 100644 --- a/packages/@aws-cdk/core/test/test.cfn-json.ts +++ b/packages/@aws-cdk/core/test/cfn-json.test.ts @@ -1,10 +1,10 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnResource, Lazy, Stack } from '../lib'; import { CfnJson } from '../lib/cfn-json'; import { CfnUtilsResourceType } from '../lib/private/cfn-utils-provider/consts'; import { handler } from '../lib/private/cfn-utils-provider/index'; -export = { +nodeunitShim({ 'resolves to a fn::getatt'(test: Test) { // GIVEN @@ -89,4 +89,4 @@ export = { test.deepEqual(input, response.Data.Value); test.done(); }, -}; \ No newline at end of file +}); diff --git a/packages/@aws-cdk/core/test/test.cfn-parameter.ts b/packages/@aws-cdk/core/test/cfn-parameter.test.ts similarity index 93% rename from packages/@aws-cdk/core/test/test.cfn-parameter.ts rename to packages/@aws-cdk/core/test/cfn-parameter.test.ts index a370b3948d401..7441e4548cf98 100644 --- a/packages/@aws-cdk/core/test/test.cfn-parameter.ts +++ b/packages/@aws-cdk/core/test/cfn-parameter.test.ts @@ -1,7 +1,7 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnParameter, Stack } from '../lib'; -export = { +nodeunitShim({ 'valueAsString supports both string and number types'(test: Test) { // GIVEN const stack = new Stack(); @@ -29,4 +29,4 @@ export = { test.done(); }, -} \ No newline at end of file +}); diff --git a/packages/@aws-cdk/core/test/test.cfn-resource.ts b/packages/@aws-cdk/core/test/cfn-resource.test.ts similarity index 90% rename from packages/@aws-cdk/core/test/test.cfn-resource.ts rename to packages/@aws-cdk/core/test/cfn-resource.test.ts index 03b615c464171..a36f5ec56e8e1 100644 --- a/packages/@aws-cdk/core/test/test.cfn-resource.ts +++ b/packages/@aws-cdk/core/test/cfn-resource.test.ts @@ -1,9 +1,9 @@ -import * as nodeunit from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import * as core from '../lib'; -export = nodeunit.testCase({ +nodeunitShim({ '._toCloudFormation': { - 'does not call renderProperties with an undefined value'(test: nodeunit.Test) { + 'does not call renderProperties with an undefined value'(test: Test) { const app = new core.App(); const stack = new core.Stack(app, 'TestStack'); const resource = new core.CfnResource(stack, 'DefaultResource', { type: 'Test::Resource::Fake' }); @@ -26,7 +26,7 @@ export = nodeunit.testCase({ test.done(); }, - 'renders "Properties" for a resource that has only properties set to "false"'(test: nodeunit.Test) { + 'renders "Properties" for a resource that has only properties set to "false"'(test: Test) { const app = new core.App(); const stack = new core.Stack(app, 'TestStack'); new core.CfnResource(stack, 'Resource', { @@ -51,7 +51,7 @@ export = nodeunit.testCase({ }, }, - 'applyRemovalPolicy default includes Update policy'(test: nodeunit.Test) { + 'applyRemovalPolicy default includes Update policy'(test: Test) { // GIVEN const app = new core.App(); const stack = new core.Stack(app, 'TestStack'); @@ -74,7 +74,7 @@ export = nodeunit.testCase({ test.done(); }, - 'can switch off updating Update policy'(test: nodeunit.Test) { + 'can switch off updating Update policy'(test: Test) { // GIVEN const app = new core.App(); const stack = new core.Stack(app, 'TestStack'); @@ -98,7 +98,7 @@ export = nodeunit.testCase({ test.done(); }, - 'can add metadata'(test: nodeunit.Test) { + 'can add metadata'(test: Test) { // GIVEN const app = new core.App(); const stack = new core.Stack(app, 'TestStack'); @@ -122,7 +122,7 @@ export = nodeunit.testCase({ test.done(); }, - 'subclasses can override "shouldSynthesize" to lazy-determine if the resource should be included'(test: nodeunit.Test) { + 'subclasses can override "shouldSynthesize" to lazy-determine if the resource should be included'(test: Test) { // GIVEN class HiddenCfnResource extends core.CfnResource { protected shouldSynthesize() { @@ -151,7 +151,7 @@ export = nodeunit.testCase({ test.done(); }, - 'CfnResource cannot be created outside Stack'(test: nodeunit.Test) { + 'CfnResource cannot be created outside Stack'(test: Test) { const app = new core.App(); test.throws(() => { new core.CfnResource(app, 'Resource', { @@ -166,7 +166,7 @@ export = nodeunit.testCase({ /** * Stages start a new scope, which does not count as a Stack anymore */ - 'CfnResource cannot be in Stage in Stack'(test: nodeunit.Test) { + 'CfnResource cannot be in Stage in Stack'(test: Test) { const app = new core.App(); const stack = new core.Stack(app, 'Stack'); const stage = new core.Stage(stack, 'Stage'); diff --git a/packages/@aws-cdk/core/test/test.cloudformation-json.ts b/packages/@aws-cdk/core/test/cloudformation-json.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.cloudformation-json.ts rename to packages/@aws-cdk/core/test/cloudformation-json.test.ts index 69ea1b2055a06..8d7e571501462 100644 --- a/packages/@aws-cdk/core/test/test.cloudformation-json.ts +++ b/packages/@aws-cdk/core/test/cloudformation-json.test.ts @@ -1,9 +1,9 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnOutput, Fn, Lazy, Stack, Token } from '../lib'; import { Intrinsic } from '../lib/private/intrinsic'; import { evaluateCFN } from './evaluate-cfn'; -export = { +nodeunitShim({ 'string tokens can be JSONified and JSONification can be reversed'(test: Test) { const stack = new Stack(); @@ -235,7 +235,7 @@ export = { test.done(); }, -}; +}); /** * Return two Tokens, one of which evaluates to a Token directly, one which evaluates to it lazily diff --git a/packages/@aws-cdk/core/test/test.condition.ts b/packages/@aws-cdk/core/test/condition.test.ts similarity index 96% rename from packages/@aws-cdk/core/test/test.condition.ts rename to packages/@aws-cdk/core/test/condition.test.ts index c6c0ae8db05a6..8c43f9eb1507c 100644 --- a/packages/@aws-cdk/core/test/test.condition.ts +++ b/packages/@aws-cdk/core/test/condition.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import * as cdk from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'chain conditions'(test: Test) { // GIVEN const stack = new cdk.Stack(); @@ -63,4 +63,4 @@ export = { }); test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.construct.ts b/packages/@aws-cdk/core/test/construct.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.construct.ts rename to packages/@aws-cdk/core/test/construct.test.ts index 06aced4d21fe6..872ba9dceedca 100644 --- a/packages/@aws-cdk/core/test/test.construct.ts +++ b/packages/@aws-cdk/core/test/construct.test.ts @@ -1,12 +1,12 @@ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App as Root, Aws, Construct, ConstructNode, ConstructOrder, IConstruct, Lazy, ValidationError } from '../lib'; import { Annotations } from '../lib/annotations'; import { reEnableStackTraceCollection, restoreStackTraceColection } from './util'; /* eslint-disable @typescript-eslint/naming-convention */ -export = { +nodeunitShim({ 'the "Root" construct is a special construct which can be used as the root of the tree'(test: Test) { const root = new Root(); test.equal(root.node.id, '', 'if not specified, name of a root construct is an empty string'); @@ -505,7 +505,7 @@ export = { }, }, -}; +}); function createTree(context?: any) { const root = new Root(); diff --git a/packages/@aws-cdk/core/test/test.context.ts b/packages/@aws-cdk/core/test/context.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.context.ts rename to packages/@aws-cdk/core/test/context.test.ts index 3d86dfd2b7d54..89c720e735999 100644 --- a/packages/@aws-cdk/core/test/test.context.ts +++ b/packages/@aws-cdk/core/test/context.test.ts @@ -1,9 +1,9 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { Construct, Stack } from '../lib'; import { ContextProvider } from '../lib/context-provider'; import { synthesize } from '../lib/private/synthesis'; -export = { +nodeunitShim({ 'AvailabilityZoneProvider returns a list with dummy values if the context is not available'(test: Test) { const stack = new Stack(undefined, 'TestStack', { env: { account: '12345', region: 'us-east-1' } }); const azs = stack.availabilityZones; @@ -167,7 +167,7 @@ export = { test.done(); }, -}; +}); /** * Get the expected context key from a stack with missing parameters diff --git a/packages/@aws-cdk/core/test/test.cross-environment-token.ts b/packages/@aws-cdk/core/test/cross-environment-token.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.cross-environment-token.ts rename to packages/@aws-cdk/core/test/cross-environment-token.test.ts index cd97e4661162e..4ab55922369e4 100644 --- a/packages/@aws-cdk/core/test/test.cross-environment-token.ts +++ b/packages/@aws-cdk/core/test/cross-environment-token.test.ts @@ -1,10 +1,10 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnOutput, CfnResource, Construct, PhysicalName, Resource, Stack } from '../lib'; import { toCloudFormation } from './util'; /* eslint-disable quote-props */ -export = { +nodeunitShim({ 'CrossEnvironmentToken': { 'can reference an ARN with a fixed physical name directly in a different account'(test: Test) { // GIVEN @@ -242,7 +242,7 @@ export = { test.done(); }, -}; +}); class MyResource extends Resource { public readonly arn: string; diff --git a/packages/@aws-cdk/core/test/custom-resource-provider/test.custom-resource-provider.ts b/packages/@aws-cdk/core/test/custom-resource-provider/custom-resource-provider.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/custom-resource-provider/test.custom-resource-provider.ts rename to packages/@aws-cdk/core/test/custom-resource-provider/custom-resource-provider.test.ts index ca3d8e4839241..f3dbff18ed651 100644 --- a/packages/@aws-cdk/core/test/custom-resource-provider/test.custom-resource-provider.ts +++ b/packages/@aws-cdk/core/test/custom-resource-provider/custom-resource-provider.test.ts @@ -1,12 +1,12 @@ import * as fs from 'fs'; import * as path from 'path'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { AssetStaging, CustomResourceProvider, CustomResourceProviderRuntime, Duration, Size, Stack } from '../../lib'; import { toCloudFormation } from '../util'; const TEST_HANDLER = `${__dirname}/mock-provider`; -export = { +nodeunitShim({ 'minimal configuration'(test: Test) { // GIVEN const stack = new Stack(); @@ -169,4 +169,4 @@ export = { test.deepEqual(lambda.Properties.Timeout, 300); test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/custom-resource-provider/test.nodejs-entrypoint.ts b/packages/@aws-cdk/core/test/custom-resource-provider/nodejs-entrypoint.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/custom-resource-provider/test.nodejs-entrypoint.ts rename to packages/@aws-cdk/core/test/custom-resource-provider/nodejs-entrypoint.test.ts index 40f3fdea54c8e..18e6dfe053ce7 100644 --- a/packages/@aws-cdk/core/test/custom-resource-provider/test.nodejs-entrypoint.ts +++ b/packages/@aws-cdk/core/test/custom-resource-provider/nodejs-entrypoint.test.ts @@ -4,10 +4,10 @@ import * as https from 'https'; import * as os from 'os'; import * as path from 'path'; import * as url from 'url'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import * as entrypoint from '../../lib/custom-resource-provider/nodejs-entrypoint'; -export = { +nodeunitShim({ 'handler return value is sent back to cloudformation as a success response': { async 'physical resource id (ref)'(test: Test) { @@ -147,7 +147,7 @@ export = { test.done(); }, -}; +}); function makeEvent(req: Partial): AWSLambda.CloudFormationCustomResourceEvent { return { @@ -195,4 +195,4 @@ async function invokeHandler(req: AWSLambda.CloudFormationCustomResourceEvent, u } return JSON.parse(actualResponse) as AWSLambda.CloudFormationCustomResourceResponse; -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/core/test/test.custom-resource.ts b/packages/@aws-cdk/core/test/custom-resource.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.custom-resource.ts rename to packages/@aws-cdk/core/test/custom-resource.test.ts index a85da1753cd13..619a46c062f6b 100644 --- a/packages/@aws-cdk/core/test/test.custom-resource.ts +++ b/packages/@aws-cdk/core/test/custom-resource.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CustomResource, RemovalPolicy, Stack } from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'simple case provider identified by service token'(test: Test) { // GIVEN const stack = new Stack(); @@ -170,4 +170,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.duration.ts b/packages/@aws-cdk/core/test/duration.test.ts similarity index 88% rename from packages/@aws-cdk/core/test/test.duration.ts rename to packages/@aws-cdk/core/test/duration.test.ts index dd3305f7ea945..4d84d80c3eaf7 100644 --- a/packages/@aws-cdk/core/test/test.duration.ts +++ b/packages/@aws-cdk/core/test/duration.test.ts @@ -1,14 +1,14 @@ -import * as nodeunit from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { Duration, Lazy, Stack, Token } from '../lib'; -export = nodeunit.testCase({ - 'negative amount'(test: nodeunit.Test) { +nodeunitShim({ + 'negative amount'(test: Test) { test.throws(() => Duration.seconds(-1), /negative/); test.done(); }, - 'unresolved amount'(test: nodeunit.Test) { + 'unresolved amount'(test: Test) { const stack = new Stack(); const lazyDuration = Duration.seconds(Token.asNumber({ resolve: () => 1337 })); test.equals(stack.resolve(lazyDuration.toSeconds()), 1337); @@ -20,7 +20,7 @@ export = nodeunit.testCase({ test.done(); }, - 'Duration in seconds'(test: nodeunit.Test) { + 'Duration in seconds'(test: Test) { const duration = Duration.seconds(300); test.equal(duration.toSeconds(), 300); @@ -33,7 +33,7 @@ export = nodeunit.testCase({ test.done(); }, - 'Duration in minutes'(test: nodeunit.Test) { + 'Duration in minutes'(test: Test) { const duration = Duration.minutes(5); test.equal(duration.toSeconds(), 300); @@ -46,7 +46,7 @@ export = nodeunit.testCase({ test.done(); }, - 'Duration in hours'(test: nodeunit.Test) { + 'Duration in hours'(test: Test) { const duration = Duration.hours(5); test.equal(duration.toSeconds(), 18_000); @@ -59,7 +59,7 @@ export = nodeunit.testCase({ test.done(); }, - 'seconds to milliseconds'(test: nodeunit.Test) { + 'seconds to milliseconds'(test: Test) { const duration = Duration.seconds(5); test.equal(duration.toMilliseconds(), 5_000); @@ -67,7 +67,7 @@ export = nodeunit.testCase({ test.done(); }, - 'Duration in days'(test: nodeunit.Test) { + 'Duration in days'(test: Test) { const duration = Duration.days(1); test.equal(duration.toSeconds(), 86_400); @@ -77,7 +77,7 @@ export = nodeunit.testCase({ test.done(); }, - 'toISOString'(test: nodeunit.Test) { + 'toISOString'(test: Test) { test.equal(Duration.millis(0).toISOString(), 'PT0S'); test.equal(Duration.seconds(0).toISOString(), 'PT0S'); test.equal(Duration.minutes(0).toISOString(), 'PT0S'); @@ -95,7 +95,7 @@ export = nodeunit.testCase({ test.done(); }, - 'toIsoString'(test: nodeunit.Test) { + 'toIsoString'(test: Test) { test.equal(Duration.millis(0).toIsoString(), 'PT0S'); test.equal(Duration.seconds(0).toIsoString(), 'PT0S'); test.equal(Duration.minutes(0).toIsoString(), 'PT0S'); @@ -114,7 +114,7 @@ export = nodeunit.testCase({ test.done(); }, - 'parse'(test: nodeunit.Test) { + 'parse'(test: Test) { test.equal(Duration.parse('PT0S').toSeconds(), 0); test.equal(Duration.parse('PT0M').toSeconds(), 0); test.equal(Duration.parse('PT0H').toSeconds(), 0); @@ -130,7 +130,7 @@ export = nodeunit.testCase({ test.done(); }, - 'reject illegal parses'(test: nodeunit.Test) { + 'reject illegal parses'(test: Test) { const err = 'Not a valid ISO duration'; test.throws(() => { Duration.parse('PT1D'); @@ -143,7 +143,7 @@ export = nodeunit.testCase({ test.done(); }, - 'to human string'(test: nodeunit.Test) { + 'to human string'(test: Test) { test.equal(Duration.minutes(0).toHumanString(), '0 minutes'); test.equal(Duration.minutes(Lazy.numberValue({ produce: () => 5 })).toHumanString(), ' minutes'); @@ -162,7 +162,7 @@ export = nodeunit.testCase({ test.done(); }, - 'add two durations'(test: nodeunit.Test) { + 'add two durations'(test: Test) { test.equal(Duration.minutes(1).plus(Duration.seconds(30)).toSeconds(), Duration.seconds(90).toSeconds()); test.equal(Duration.minutes(1).plus(Duration.seconds(30)).toMinutes({ integral: false }), Duration.seconds(90).toMinutes({ integral: false })); @@ -170,7 +170,7 @@ export = nodeunit.testCase({ }, }); -function floatEqual(test: nodeunit.Test, actual: number, expected: number) { +function floatEqual(test: Test, actual: number, expected: number) { test.ok( // Floats are subject to rounding errors up to Number.ESPILON actual >= expected - Number.EPSILON && actual <= expected + Number.EPSILON, diff --git a/packages/@aws-cdk/core/test/test.dynamic-reference.ts b/packages/@aws-cdk/core/test/dynamic-reference.test.ts similarity index 84% rename from packages/@aws-cdk/core/test/test.dynamic-reference.ts rename to packages/@aws-cdk/core/test/dynamic-reference.test.ts index 33be26fdab223..e9da4b23b837d 100644 --- a/packages/@aws-cdk/core/test/test.dynamic-reference.ts +++ b/packages/@aws-cdk/core/test/dynamic-reference.test.ts @@ -1,7 +1,7 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnDynamicReference, CfnDynamicReferenceService, Stack } from '../lib'; -export = { +nodeunitShim({ 'can create dynamic references with service and key with colons'(test: Test) { // GIVEN const stack = new Stack(); @@ -14,4 +14,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.environment.ts b/packages/@aws-cdk/core/test/environment.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.environment.ts rename to packages/@aws-cdk/core/test/environment.test.ts index ff6cd0881b597..5432fd178f1f8 100644 --- a/packages/@aws-cdk/core/test/test.environment.ts +++ b/packages/@aws-cdk/core/test/environment.test.ts @@ -1,7 +1,7 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, Aws, Stack, Token } from '../lib'; -export = { +nodeunitShim({ 'By default, environment region and account are not defined and resolve to intrinsics'(test: Test) { const stack = new Stack(); test.ok(Token.isUnresolved(stack.account)); @@ -137,4 +137,4 @@ export = { test.done(); }, }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.expiration.ts b/packages/@aws-cdk/core/test/expiration.test.ts similarity index 80% rename from packages/@aws-cdk/core/test/test.expiration.ts rename to packages/@aws-cdk/core/test/expiration.test.ts index 2aa9078f3448c..de17852f4308c 100644 --- a/packages/@aws-cdk/core/test/test.expiration.ts +++ b/packages/@aws-cdk/core/test/expiration.test.ts @@ -1,14 +1,14 @@ -import * as nodeunit from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { Duration, Expiration } from '../lib'; -export = nodeunit.testCase({ - 'from string'(test: nodeunit.Test) { +nodeunitShim({ + 'from string'(test: Test) { const date = new Date('Sun, 26 Jan 2020 00:53:20 GMT'); test.equal(Expiration.fromString('Sun, 26 Jan 2020 00:53:20 GMT').date.getDate(), date.getDate()); test.done(); }, - 'at specified date'(test: nodeunit.Test) { + 'at specified date'(test: Test) { const date = new Date('Sun, 26 Jan 2020 00:53:20 GMT'); test.equal(Expiration.atDate(new Date('Sun, 26 Jan 2020 00:53:20 GMT')).date.toUTCString(), 'Sun, 26 Jan 2020 00:53:20 GMT'); test.equal(Expiration.atDate(new Date(1580000000000)).date.toUTCString(), 'Sun, 26 Jan 2020 00:53:20 GMT'); @@ -16,30 +16,30 @@ export = nodeunit.testCase({ test.done(); }, - 'at time stamp'(test: nodeunit.Test) { + 'at time stamp'(test: Test) { test.equal(Expiration.atDate(new Date(1580000000000)).date.toUTCString(), 'Sun, 26 Jan 2020 00:53:20 GMT'); test.done(); }, - 'after'(test: nodeunit.Test) { + 'after'(test: Test) { test.ok(Math.abs(new Date(Expiration.after(Duration.minutes(10)).date.toUTCString()).getTime() - (Date.now() + 600000)) < 15000); test.done(); }, - 'toEpoch returns correct value'(test: nodeunit.Test) { + 'toEpoch returns correct value'(test: Test) { const date = new Date('Sun, 26 Jan 2020 00:53:20 GMT'); test.equal(Expiration.atDate(date).toEpoch(), 1580000000); test.done(); }, - 'isBefore'(test: nodeunit.Test) { + 'isBefore'(test: Test) { const expire = Expiration.after(Duration.days(2)); test.ok(!expire.isBefore(Duration.days(1))); test.ok(expire.isBefore(Duration.days(3))); test.done(); }, - 'isAfter'(test: nodeunit.Test) { + 'isAfter'(test: Test) { const expire = Expiration.after(Duration.days(2)); test.ok(expire.isAfter(Duration.days(1))); test.ok(!expire.isAfter(Duration.days(3))); diff --git a/packages/@aws-cdk/core/test/test.feature-flags.ts b/packages/@aws-cdk/core/test/feature-flags.test.ts similarity index 92% rename from packages/@aws-cdk/core/test/test.feature-flags.ts rename to packages/@aws-cdk/core/test/feature-flags.test.ts index abb1723e6a3dc..b3ca21c45bea8 100644 --- a/packages/@aws-cdk/core/test/test.feature-flags.ts +++ b/packages/@aws-cdk/core/test/feature-flags.test.ts @@ -1,8 +1,8 @@ import * as cxapi from '@aws-cdk/cx-api'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { FeatureFlags, Stack } from '../lib'; -export = { +nodeunitShim({ isEnabled: { 'returns true when the flag is enabled'(test: Test) { const stack = new Stack(); @@ -28,4 +28,4 @@ export = { test.done(); }, }, -} \ No newline at end of file +}); diff --git a/packages/@aws-cdk/core/test/test.fn.ts b/packages/@aws-cdk/core/test/fn.test.ts similarity index 91% rename from packages/@aws-cdk/core/test/test.fn.ts rename to packages/@aws-cdk/core/test/fn.test.ts index ec3f537ba0945..66828aceba543 100644 --- a/packages/@aws-cdk/core/test/test.fn.ts +++ b/packages/@aws-cdk/core/test/fn.test.ts @@ -1,11 +1,11 @@ import * as fc from 'fast-check'; import * as _ from 'lodash'; -import * as nodeunit from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnOutput, Fn, Stack, Token } from '../lib'; import { Intrinsic } from '../lib/private/intrinsic'; -function asyncTest(cb: (test: nodeunit.Test) => Promise): (test: nodeunit.Test) => void { - return async (test: nodeunit.Test) => { +function asyncTest(cb: (test: Test) => Promise): (test: Test) => void { + return async (test: Test) => { let error: Error; try { await cb(test); @@ -24,23 +24,23 @@ const nonEmptyString = fc.string(1, 16); const tokenish = fc.array(nonEmptyString, 2, 2).map(arr => ({ [arr[0]]: arr[1] })); const anyValue = fc.oneof(nonEmptyString, tokenish); -export = nodeunit.testCase({ +nodeunitShim({ 'eager resolution for non-tokens': { - 'Fn.select'(test: nodeunit.Test) { + 'Fn.select'(test: Test) { test.deepEqual(Fn.select(2, ['hello', 'you', 'dude']), 'dude'); test.done(); }, - 'Fn.split'(test: nodeunit.Test) { + 'Fn.split'(test: Test) { test.deepEqual(Fn.split(':', 'hello:world:yeah'), ['hello', 'world', 'yeah']); test.done(); }, }, 'FnParseDomainName': { - 'parse domain name from resolved url'(test: nodeunit.Test) { + 'parse domain name from resolved url'(test: Test) { test.deepEqual(Fn.parseDomainName('https://test.com/'), 'test.com'); test.done(); }, - 'parse domain name on token'(test: nodeunit.Test) { + 'parse domain name on token'(test: Test) { const stack = new Stack(); const url = Fn.join('//', [ 'https:', @@ -54,11 +54,11 @@ export = nodeunit.testCase({ }, }, 'FnJoin': { - 'rejects empty list of arguments to join'(test: nodeunit.Test) { + 'rejects empty list of arguments to join'(test: Test) { test.throws(() => Fn.join('.', [])); test.done(); }, - 'collapse nested FnJoins even if they contain tokens'(test: nodeunit.Test) { + 'collapse nested FnJoins even if they contain tokens'(test: Test) { const stack = new Stack(); const obj = Fn.join('', [ @@ -188,7 +188,7 @@ export = nodeunit.testCase({ }), }, 'Ref': { - 'returns a reference given a logical name'(test: nodeunit.Test) { + 'returns a reference given a logical name'(test: Test) { const stack = new Stack(); test.deepEqual(stack.resolve(Fn.ref('hello')), { Ref: 'hello', @@ -196,7 +196,7 @@ export = nodeunit.testCase({ test.done(); }, }, - 'nested Fn::Join with list token'(test: nodeunit.Test) { + 'nested Fn::Join with list token'(test: Test) { const stack = new Stack(); const inner = Fn.join(',', Token.asList({ NotReallyList: true })); const outer = Fn.join(',', [inner, 'Foo']); diff --git a/packages/@aws-cdk/core/test/fs/test.fs-copy.ts b/packages/@aws-cdk/core/test/fs/fs-copy.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/fs/test.fs-copy.ts rename to packages/@aws-cdk/core/test/fs/fs-copy.test.ts index 840bc94a97087..03ffc770b870c 100644 --- a/packages/@aws-cdk/core/test/fs/test.fs-copy.ts +++ b/packages/@aws-cdk/core/test/fs/fs-copy.test.ts @@ -1,10 +1,10 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { FileSystem, SymlinkFollowMode } from '../../lib/fs'; -export = { +nodeunitShim({ 'Default: copies all files and subdirectories, with default follow mode is "External"'(test: Test) { // GIVEN const outdir = fs.mkdtempSync(path.join(os.tmpdir(), 'copy-tests')); @@ -124,7 +124,7 @@ export = { ]); test.done(); }, -}; +}); function tree(dir: string, depth = ''): string[] { const lines = new Array(); diff --git a/packages/@aws-cdk/core/test/fs/test.fs-fingerprint.ts b/packages/@aws-cdk/core/test/fs/fs-fingerprint.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/fs/test.fs-fingerprint.ts rename to packages/@aws-cdk/core/test/fs/fs-fingerprint.test.ts index b41ddfffc38c2..ad5bf9cf14160 100644 --- a/packages/@aws-cdk/core/test/fs/test.fs-fingerprint.ts +++ b/packages/@aws-cdk/core/test/fs/fs-fingerprint.test.ts @@ -1,10 +1,10 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { FileSystem, SymlinkFollowMode } from '../../lib/fs'; -export = { +nodeunitShim({ files: { 'does not change with the file name'(test: Test) { // GIVEN @@ -185,4 +185,4 @@ export = { test.done(); }, }, -}; +}); diff --git a/packages/@aws-cdk/core/test/fs/test.fs.ts b/packages/@aws-cdk/core/test/fs/fs.test.ts similarity index 95% rename from packages/@aws-cdk/core/test/fs/test.fs.ts rename to packages/@aws-cdk/core/test/fs/fs.test.ts index 7616eaef536fc..e1e195daa1005 100644 --- a/packages/@aws-cdk/core/test/fs/test.fs.ts +++ b/packages/@aws-cdk/core/test/fs/fs.test.ts @@ -1,11 +1,11 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import * as sinon from 'sinon'; import { FileSystem } from '../../lib/fs'; -export = { +nodeunitShim({ 'tearDown'(callback: any) { sinon.restore(); callback(); @@ -47,4 +47,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/fs/test.utils.ts b/packages/@aws-cdk/core/test/fs/utils.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/fs/test.utils.ts rename to packages/@aws-cdk/core/test/fs/utils.test.ts index 2e43d125d597b..1013095199a03 100644 --- a/packages/@aws-cdk/core/test/fs/test.utils.ts +++ b/packages/@aws-cdk/core/test/fs/utils.test.ts @@ -1,11 +1,11 @@ import * as fs from 'fs'; import * as path from 'path'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { ImportMock } from 'ts-mock-imports'; import { SymlinkFollowMode } from '../../lib/fs'; import * as util from '../../lib/fs/utils'; -export = { +nodeunitShim({ shouldExclude: { 'excludes nothing by default'(test: Test) { test.ok(!util.shouldExclude([], path.join('some', 'file', 'path'))); @@ -192,4 +192,4 @@ export = { }, }, }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.include.ts b/packages/@aws-cdk/core/test/include.test.ts similarity index 97% rename from packages/@aws-cdk/core/test/test.include.ts rename to packages/@aws-cdk/core/test/include.test.ts index f029506c061e0..d36dbf8739d19 100644 --- a/packages/@aws-cdk/core/test/test.include.ts +++ b/packages/@aws-cdk/core/test/include.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnInclude, CfnOutput, CfnParameter, CfnResource, Stack } from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'the Include construct can be used to embed an existing template as-is into a stack'(test: Test) { const stack = new Stack(); @@ -78,7 +78,7 @@ export = { test.done(); }, -}; +}); const template = { Parameters: { diff --git a/packages/@aws-cdk/core/test/test.logical-id.ts b/packages/@aws-cdk/core/test/logical-id.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.logical-id.ts rename to packages/@aws-cdk/core/test/logical-id.test.ts index d7483b3374397..f4ab0f8eb63d9 100644 --- a/packages/@aws-cdk/core/test/test.logical-id.ts +++ b/packages/@aws-cdk/core/test/logical-id.test.ts @@ -1,11 +1,11 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnElement, CfnResource, Construct, Stack } from '../lib'; import { toCloudFormation } from './util'; /** * These tests are executed once (for specific ID schemes) */ -export = { +nodeunitShim({ 'if the naming scheme uniquifies with a hash we can have the same concatenated identifier'(test: Test) { // GIVEN const stack = new Stack(undefined, 'TestStack'); @@ -270,7 +270,7 @@ export = { test.done(); }, -}; +}); function generateString(chars: number) { let s = ''; diff --git a/packages/@aws-cdk/core/test/test.mappings.ts b/packages/@aws-cdk/core/test/mappings.test.ts similarity index 94% rename from packages/@aws-cdk/core/test/test.mappings.ts rename to packages/@aws-cdk/core/test/mappings.test.ts index f73fe5446b541..7dd67fbcead45 100644 --- a/packages/@aws-cdk/core/test/test.mappings.ts +++ b/packages/@aws-cdk/core/test/mappings.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { Aws, CfnMapping, CfnResource, Fn, Stack } from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'mappings can be added as another type of entity, and mapping.findInMap can be used to get a token'(test: Test) { const stack = new Stack(); const mapping = new CfnMapping(stack, 'MyMapping', { @@ -24,8 +24,8 @@ export = { RefToValueInMap: mapping.findInMap('TopLevelKey1', 'SecondLevelKey1'), }, }); - test.throws(() => mapping.findInMap('NotFoundTopLevel', 'NotFound'), 'cant take a reference on a non existing key'); - test.throws(() => mapping.findInMap('TopLevelKey1', 'NotFound'), 'cant take a reference on a non existing key'); + test.throws(() => mapping.findInMap('NotFoundTopLevel', 'NotFound'), 'Mapping doesn\'t contain top-level key \'NotFoundTopLevel\''); + test.throws(() => mapping.findInMap('TopLevelKey1', 'NotFound'), 'Mapping doesn\'t contain second-level key \'NotFound\''); // set value can be used to set/modify a specific value mapping.setValue('TopLevelKey2', 'SecondLevelKey2', 'Hi'); @@ -121,4 +121,4 @@ export = { test.deepEqual(stack.resolve(v), { 'Fn::FindInMap': ['mapping', 'size', { Ref: 'AWS::Region' }] }); test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.output.ts b/packages/@aws-cdk/core/test/output.test.ts similarity index 93% rename from packages/@aws-cdk/core/test/test.output.ts rename to packages/@aws-cdk/core/test/output.test.ts index 64024b37570c5..d7b509159a2bb 100644 --- a/packages/@aws-cdk/core/test/test.output.ts +++ b/packages/@aws-cdk/core/test/output.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnOutput, CfnResource, Stack } from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'outputs can be added to the stack'(test: Test) { const stack = new Stack(); const res = new CfnResource(stack, 'MyResource', { type: 'R' }); @@ -46,4 +46,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.parameter.ts b/packages/@aws-cdk/core/test/parameter.test.ts similarity index 94% rename from packages/@aws-cdk/core/test/test.parameter.ts rename to packages/@aws-cdk/core/test/parameter.test.ts index 92cb128b5bc9e..d13edbffddb0a 100644 --- a/packages/@aws-cdk/core/test/test.parameter.ts +++ b/packages/@aws-cdk/core/test/parameter.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnParameter, CfnResource, Construct, Stack } from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'parameters can be used and referenced using param.ref'(test: Test) { const stack = new Stack(); @@ -41,4 +41,4 @@ export = { test.deepEqual(stack.resolve(param), { Ref: 'MyParam' }); test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/private/test.physical-name-generator.ts b/packages/@aws-cdk/core/test/private/physical-name-generator.test.ts similarity index 84% rename from packages/@aws-cdk/core/test/private/test.physical-name-generator.ts rename to packages/@aws-cdk/core/test/private/physical-name-generator.test.ts index 9c77a3eec6dfa..2d6e5e93d8d2a 100644 --- a/packages/@aws-cdk/core/test/private/test.physical-name-generator.ts +++ b/packages/@aws-cdk/core/test/private/physical-name-generator.test.ts @@ -1,10 +1,10 @@ -import * as nodeunit from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, Aws, Lazy, Resource, Stack, Token } from '../../lib'; import { GeneratedWhenNeededMarker, generatePhysicalName, isGeneratedWhenNeededMarker } from '../../lib/private/physical-name-generator'; -export = nodeunit.testCase({ +nodeunitShim({ generatePhysicalName: { - 'generates correct physical names'(test: nodeunit.Test) { + 'generates correct physical names'(test: Test) { const app = new App(); const stack = new Stack(app, 'TestStack', { env: { account: '012345678912', region: 'bermuda-triangle-1' } }); @@ -17,7 +17,7 @@ export = nodeunit.testCase({ test.done(); }, - 'generates different names in different accounts'(test: nodeunit.Test) { + 'generates different names in different accounts'(test: Test) { const appA = new App(); const stackA = new Stack(appA, 'TestStack', { env: { account: '012345678912', region: 'bermuda-triangle-1' } }); const resourceA = new TestResource(stackA, 'Resource'); @@ -31,7 +31,7 @@ export = nodeunit.testCase({ test.done(); }, - 'generates different names in different regions'(test: nodeunit.Test) { + 'generates different names in different regions'(test: Test) { const appA = new App(); const stackA = new Stack(appA, 'TestStack', { env: { account: '012345678912', region: 'bermuda-triangle-1' } }); const resourceA = new TestResource(stackA, 'Resource'); @@ -45,7 +45,7 @@ export = nodeunit.testCase({ test.done(); }, - 'fails when the region is an unresolved token'(test: nodeunit.Test) { + 'fails when the region is an unresolved token'(test: Test) { const app = new App(); const stack = new Stack(app, 'TestStack', { env: { account: '012345678912', region: Aws.REGION } }); const testResource = new TestResource(stack, 'A'); @@ -56,7 +56,7 @@ export = nodeunit.testCase({ test.done(); }, - 'fails when the region is not provided'(test: nodeunit.Test) { + 'fails when the region is not provided'(test: Test) { const app = new App(); const stack = new Stack(app, 'TestStack', { env: { account: '012345678912' } }); const testResource = new TestResource(stack, 'A'); @@ -67,7 +67,7 @@ export = nodeunit.testCase({ test.done(); }, - 'fails when the account is an unresolved token'(test: nodeunit.Test) { + 'fails when the account is an unresolved token'(test: Test) { const app = new App(); const stack = new Stack(app, 'TestStack', { env: { account: Aws.ACCOUNT_ID, region: 'bermuda-triangle-1' } }); const testResource = new TestResource(stack, 'A'); @@ -78,7 +78,7 @@ export = nodeunit.testCase({ test.done(); }, - 'fails when the account is not provided'(test: nodeunit.Test) { + 'fails when the account is not provided'(test: Test) { const app = new App(); const stack = new Stack(app, 'TestStack', { env: { region: 'bermuda-triangle-1' } }); const testResource = new TestResource(stack, 'A'); @@ -91,7 +91,7 @@ export = nodeunit.testCase({ }, GeneratedWhenNeededMarker: { - 'is correctly recognized'(test: nodeunit.Test) { + 'is correctly recognized'(test: Test) { const marker = new GeneratedWhenNeededMarker(); const asString = Token.asString(marker); @@ -100,7 +100,7 @@ export = nodeunit.testCase({ test.done(); }, - 'throws when resolved'(test: nodeunit.Test) { + 'throws when resolved'(test: Test) { const marker = new GeneratedWhenNeededMarker(); const asString = Token.asString(marker); @@ -111,7 +111,7 @@ export = nodeunit.testCase({ }, isGeneratedWhenNeededMarker: { - 'correctly response for other tokens'(test: nodeunit.Test) { + 'correctly response for other tokens'(test: Test) { test.ok(!isGeneratedWhenNeededMarker('this is not even a token!')); test.ok(!isGeneratedWhenNeededMarker(Lazy.stringValue({ produce: () => 'Bazinga!' }))); diff --git a/packages/@aws-cdk/core/test/private/test.tree-metadata.ts b/packages/@aws-cdk/core/test/private/tree-metadata.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/private/test.tree-metadata.ts rename to packages/@aws-cdk/core/test/private/tree-metadata.test.ts index 3ef3966b2fd95..ce64cf5991e1a 100644 --- a/packages/@aws-cdk/core/test/private/test.tree-metadata.ts +++ b/packages/@aws-cdk/core/test/private/tree-metadata.test.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnParameter, CfnResource, Construct, Lazy, Stack, TreeInspector } from '../../lib/index'; abstract class AbstractCfnResource extends CfnResource { @@ -19,7 +19,7 @@ abstract class AbstractCfnResource extends CfnResource { protected abstract get cfnProperties(): { [key: string]: any }; } -export = { +nodeunitShim({ 'tree metadata is generated as expected'(test: Test) { const app = new App(); @@ -309,7 +309,7 @@ export = { test.done(); }, -}; +}); function readJson(outdir: string, file: string) { return JSON.parse(fs.readFileSync(path.join(outdir, file), 'utf-8')); diff --git a/packages/@aws-cdk/core/test/test.resource.ts b/packages/@aws-cdk/core/test/resource.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.resource.ts rename to packages/@aws-cdk/core/test/resource.test.ts index 0a4a29f664db8..a559a33658ba2 100644 --- a/packages/@aws-cdk/core/test/test.resource.ts +++ b/packages/@aws-cdk/core/test/resource.test.ts @@ -1,5 +1,5 @@ import * as cxapi from '@aws-cdk/cx-api'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, App as Root, CfnCondition, CfnDeletionPolicy, CfnResource, Construct, @@ -8,7 +8,7 @@ import { import { synthesize } from '../lib/private/synthesis'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'all resources derive from Resource, which derives from Entity'(test: Test) { const stack = new Stack(); @@ -783,7 +783,7 @@ export = { test.done(); }, -}; +}); interface CounterProps { Count: number; diff --git a/packages/@aws-cdk/core/test/test.rule.ts b/packages/@aws-cdk/core/test/rule.test.ts similarity index 94% rename from packages/@aws-cdk/core/test/test.rule.ts rename to packages/@aws-cdk/core/test/rule.test.ts index 8385183333855..637f204235f83 100644 --- a/packages/@aws-cdk/core/test/test.rule.ts +++ b/packages/@aws-cdk/core/test/rule.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnRule, Fn, Stack } from '../lib'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'Rule can be used to create rules'(test: Test) { const stack = new Stack(); @@ -45,4 +45,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.runtime-info.ts b/packages/@aws-cdk/core/test/runtime-info.test.ts similarity index 97% rename from packages/@aws-cdk/core/test/test.runtime-info.ts rename to packages/@aws-cdk/core/test/runtime-info.test.ts index 46d8e42f85048..67f931bb63ec5 100644 --- a/packages/@aws-cdk/core/test/test.runtime-info.ts +++ b/packages/@aws-cdk/core/test/runtime-info.test.ts @@ -1,10 +1,10 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { collectRuntimeInformation } from '../lib/private/runtime-info'; -export = { +nodeunitShim({ 'version reporting includes @aws-solutions-konstruk libraries'(test: Test) { const pkgdir = fs.mkdtempSync(path.join(os.tmpdir(), 'runtime-info-konstruk-fixture')); const mockVersion = '1.2.3'; @@ -70,4 +70,4 @@ export = { test.equal(runtimeInfo.libraries['@aws-solutions-konstruk/bar'], undefined); test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.secret-value.ts b/packages/@aws-cdk/core/test/secret-value.test.ts similarity index 97% rename from packages/@aws-cdk/core/test/test.secret-value.ts rename to packages/@aws-cdk/core/test/secret-value.test.ts index 759af3d0d2c27..155a0d371aab0 100644 --- a/packages/@aws-cdk/core/test/test.secret-value.ts +++ b/packages/@aws-cdk/core/test/secret-value.test.ts @@ -1,7 +1,7 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnDynamicReference, CfnDynamicReferenceService, CfnParameter, SecretValue, Stack } from '../lib'; -export = { +nodeunitShim({ 'plainText'(test: Test) { // GIVEN const stack = new Stack(); @@ -99,4 +99,4 @@ export = { test.done(); }, -}; \ No newline at end of file +}); diff --git a/packages/@aws-cdk/core/test/test.size.ts b/packages/@aws-cdk/core/test/size.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.size.ts rename to packages/@aws-cdk/core/test/size.test.ts index dcb25ebd95b72..e6e9534039b90 100644 --- a/packages/@aws-cdk/core/test/test.size.ts +++ b/packages/@aws-cdk/core/test/size.test.ts @@ -1,7 +1,7 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { Size, SizeRoundingBehavior, Stack, Token } from '../lib'; -export = { +nodeunitShim({ 'negative amount'(test: Test) { test.throws(() => Size.kibibytes(-1), /negative/); @@ -109,7 +109,7 @@ export = { test.done(); }, -}; +}); function floatEqual(test: Test, actual: number, expected: number) { test.ok( diff --git a/packages/@aws-cdk/core/test/stack-synthesis/test.new-style-synthesis.ts b/packages/@aws-cdk/core/test/stack-synthesis/new-style-synthesis.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/stack-synthesis/test.new-style-synthesis.ts rename to packages/@aws-cdk/core/test/stack-synthesis/new-style-synthesis.test.ts index 8028658b4c7dc..08b48162086a0 100644 --- a/packages/@aws-cdk/core/test/stack-synthesis/test.new-style-synthesis.ts +++ b/packages/@aws-cdk/core/test/stack-synthesis/new-style-synthesis.test.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as cxschema from '@aws-cdk/cloud-assembly-schema'; import * as cxapi from '@aws-cdk/cx-api'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnResource, DefaultStackSynthesizer, FileAssetPackaging, Stack } from '../../lib'; import { evaluateCFN } from '../evaluate-cfn'; @@ -13,7 +13,7 @@ const CFN_CONTEXT = { let app: App; let stack: Stack; -export = { +nodeunitShim({ 'setUp'(cb: () => void) { app = new App({ context: { @@ -218,7 +218,7 @@ export = { test.done(); }, -}; +}); /** * Evaluate a possibly string-containing value the same way CFN would do @@ -242,4 +242,4 @@ function readAssetManifest(asm: cxapi.CloudAssembly): cxschema.AssetManifest { function last(xs?: A[]): A | undefined { return xs ? xs[xs.length - 1] : undefined; -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/core/test/test.stack.ts b/packages/@aws-cdk/core/test/stack.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.stack.ts rename to packages/@aws-cdk/core/test/stack.test.ts index 409c096da3610..50a91b7be7827 100644 --- a/packages/@aws-cdk/core/test/test.stack.ts +++ b/packages/@aws-cdk/core/test/stack.test.ts @@ -1,5 +1,5 @@ import * as cxapi from '@aws-cdk/cx-api'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnCondition, CfnInclude, CfnOutput, CfnParameter, CfnResource, Construct, Lazy, ScopedAws, Stack, validateString, ISynthesisSession, Tags, LegacyStackSynthesizer, DefaultStackSynthesizer, @@ -9,7 +9,7 @@ import { resolveReferences } from '../lib/private/refs'; import { PostResolveToken } from '../lib/util'; import { toCloudFormation } from './util'; -export = { +nodeunitShim({ 'a stack can be serialized into a CloudFormation template, initially it\'s empty'(test: Test) { const stack = new Stack(); test.deepEqual(toCloudFormation(stack), { }); @@ -581,7 +581,7 @@ export = { test.throws(() => { app.synth(); // eslint-disable-next-line max-len - }, "'Stack2' depends on 'Stack1' (Stack2/SomeParameter -> Stack1.AWS::AccountId). Adding this dependency (Stack1/SomeParameter -> Stack2.AWS::AccountId) would create a cyclic reference."); + }, "'Stack1' depends on 'Stack2' (Stack1 -> Stack2.AWS::AccountId). Adding this dependency (Stack2 -> Stack1.AWS::AccountId) would create a cyclic reference."); test.done(); }, @@ -1011,7 +1011,7 @@ export = { test.ok(new Stack(app, 'Stack', { analyticsReporting: true })._versionReportingEnabled); test.done(); }, -}; +}); class StackWithPostProcessor extends Stack { diff --git a/packages/@aws-cdk/core/test/test.stage.ts b/packages/@aws-cdk/core/test/stage.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.stage.ts rename to packages/@aws-cdk/core/test/stage.test.ts index 52fe1c14c4d21..c878c1485d6ce 100644 --- a/packages/@aws-cdk/core/test/test.stage.ts +++ b/packages/@aws-cdk/core/test/stage.test.ts @@ -1,8 +1,8 @@ import * as cxapi from '@aws-cdk/cx-api'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { App, CfnResource, Construct, IAspect, IConstruct, Stack, Stage, Aspects } from '../lib'; -export = { +nodeunitShim({ 'Stack inherits unspecified part of the env from Stage'(test: Test) { // GIVEN const app = new App(); @@ -280,7 +280,7 @@ export = { test.throws(() => new Stage(app, 'mystage', { outdir: '/tmp/foo/bar' }), /"outdir" cannot be specified for nested stages/); test.done(); }, -}; +}); class TouchingAspect implements IAspect { public readonly visits = new Array(); @@ -301,4 +301,4 @@ class BogusStack extends Stack { function acctRegion(s: Stack) { return [s.account, s.region]; -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/core/test/test.staging.ts b/packages/@aws-cdk/core/test/staging.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.staging.ts rename to packages/@aws-cdk/core/test/staging.test.ts index 6d649325db94e..0ab19b3f26074 100644 --- a/packages/@aws-cdk/core/test/test.staging.ts +++ b/packages/@aws-cdk/core/test/staging.test.ts @@ -2,7 +2,7 @@ import * as os from 'os'; import * as path from 'path'; import * as cxapi from '@aws-cdk/cx-api'; import * as fs from 'fs-extra'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import * as sinon from 'sinon'; import { App, AssetHashType, AssetStaging, BundlingDockerImage, BundlingOptions, Stack } from '../lib'; @@ -21,7 +21,7 @@ const USER_ARG = `-u ${userInfo.uid}:${userInfo.gid}`; // this is a way to provide a custom "docker" command for staging. process.env.CDK_DOCKER = `${__dirname}/docker-stub.sh`; -export = { +nodeunitShim({ 'tearDown'(cb: any) { if (fs.existsSync(STUB_INPUT_FILE)) { @@ -651,7 +651,7 @@ export = { test.done(); }, -}; +}); // Reads a docker stub and cleans the volume paths out of the stub. function readAndCleanDockerStubInput(file: string) { diff --git a/packages/@aws-cdk/core/test/test.synthesis.ts b/packages/@aws-cdk/core/test/synthesis.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.synthesis.ts rename to packages/@aws-cdk/core/test/synthesis.test.ts index 3d8c0fad35cf1..464e544cc562a 100644 --- a/packages/@aws-cdk/core/test/test.synthesis.ts +++ b/packages/@aws-cdk/core/test/synthesis.test.ts @@ -2,14 +2,14 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import * as cdk from '../lib'; function createModernApp() { return new cdk.App(); } -export = { +nodeunitShim({ 'synthesis with an empty app'(test: Test) { // GIVEN const app = createModernApp(); @@ -158,7 +158,7 @@ export = { test.deepEqual(stack.environment, { region: 'us-east-1', account: 'unknown-account', name: 'aws://unknown-account/us-east-1' }); test.done(); }, -}; +}); function list(outdir: string) { return fs.readdirSync(outdir).sort(); diff --git a/packages/@aws-cdk/core/test/test.tag-aspect.ts b/packages/@aws-cdk/core/test/tag-aspect.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.tag-aspect.ts rename to packages/@aws-cdk/core/test/tag-aspect.test.ts index a2c90275eb54d..cb2c5363e2153 100644 --- a/packages/@aws-cdk/core/test/test.tag-aspect.ts +++ b/packages/@aws-cdk/core/test/tag-aspect.test.ts @@ -1,4 +1,4 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnResource, CfnResourceProps, Construct, RemoveTag, Stack, Tag, TagManager, TagType, Aspects, Tags } from '../lib'; import { synthesize } from '../lib/private/synthesis'; @@ -38,7 +38,7 @@ class MapTaggableResource extends CfnResource { } } -export = { +nodeunitShim({ 'Tag visit all children of the applied node'(test: Test) { const root = new Stack(); const res = new TaggableResource(root, 'FakeResource', { @@ -276,4 +276,4 @@ export = { test.done(); }, }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.tag-manager.ts b/packages/@aws-cdk/core/test/tag-manager.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.tag-manager.ts rename to packages/@aws-cdk/core/test/tag-manager.test.ts index 235d7b8b0fbe4..7e9e448e97434 100644 --- a/packages/@aws-cdk/core/test/test.tag-manager.ts +++ b/packages/@aws-cdk/core/test/tag-manager.test.ts @@ -1,8 +1,8 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { TagType } from '../lib/cfn-resource'; import { TagManager } from '../lib/tag-manager'; -export = { +nodeunitShim({ 'TagManagerOptions can set tagPropertyName'(test: Test) { const tagPropName = 'specialName'; const mgr = new TagManager(TagType.MAP, 'Foo', undefined, { tagPropertyName: tagPropName }); @@ -146,4 +146,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/core/test/test.tokens.ts b/packages/@aws-cdk/core/test/tokens.test.ts similarity index 99% rename from packages/@aws-cdk/core/test/test.tokens.ts rename to packages/@aws-cdk/core/test/tokens.test.ts index 9356cbad9b49b..28d70be77e53a 100644 --- a/packages/@aws-cdk/core/test/test.tokens.ts +++ b/packages/@aws-cdk/core/test/tokens.test.ts @@ -1,4 +1,4 @@ -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { Fn, isResolvableObject, Lazy, Stack, Token, Tokenization } from '../lib'; import { createTokenDouble, extractTokenDouble } from '../lib/private/encoding'; import { Intrinsic } from '../lib/private/intrinsic'; @@ -7,7 +7,7 @@ import { IResolvable } from '../lib/resolvable'; import { evaluateCFN } from './evaluate-cfn'; import { reEnableStackTraceCollection, restoreStackTraceColection } from './util'; -export = { +nodeunitShim({ 'resolve a plain old object should just return the object'(test: Test) { const obj = { PlainOldObject: 123, Array: [1, 2, 3] }; test.deepEqual(resolve(obj), obj); @@ -327,7 +327,7 @@ export = { }; // THEN - test.throws(() => resolve(s), 'The key "${Token[TOKEN.19]}" has been resolved to {"Ref":"Other"} but must be resolvable to a string'); + test.throws(() => resolve(s), 'is used as the key in a map so must resolve to a string, but it resolves to:'); test.done(); }, @@ -653,7 +653,7 @@ export = { test.done(); }, }, -}; +}); class Promise2 implements IResolvable { public readonly creationStack = []; diff --git a/packages/@aws-cdk/core/test/test.util.ts b/packages/@aws-cdk/core/test/util.test.ts similarity index 98% rename from packages/@aws-cdk/core/test/test.util.ts rename to packages/@aws-cdk/core/test/util.test.ts index e573cde4bb1ae..3b9c33f14c9f4 100644 --- a/packages/@aws-cdk/core/test/test.util.ts +++ b/packages/@aws-cdk/core/test/util.test.ts @@ -1,8 +1,8 @@ -import { Test, testCase } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnResource, Construct, Stack } from '../lib'; import { capitalizePropertyNames, filterUndefined, findLastCommonElement, ignoreEmpty, pathToTopLevelStack } from '../lib/util'; -export = testCase({ +nodeunitShim({ 'capitalizeResourceProperties capitalizes all keys of an object (recursively) from camelCase to PascalCase'(test: Test) { const c = new Stack(); diff --git a/tools/nodeunit-shim/index.ts b/tools/nodeunit-shim/index.ts index e6f0fe91da5a7..8ba50bedefefd 100644 --- a/tools/nodeunit-shim/index.ts +++ b/tools/nodeunit-shim/index.ts @@ -15,6 +15,10 @@ export class Test { expect(a).toEqual(b); } + public notEqual(a: any, b: any, _message?: string) { + expect(a).not.toEqual(b); + } + public equals(a: any, b: any, _message?: string) { expect(a).toEqual(b); } @@ -23,10 +27,14 @@ export class Test { expect(a).toEqual(b); } - public deepEqual(a: any, b: any) { + public deepEqual(a: any, b: any, _message?: string) { expect(a).toEqual(b); } + public notDeepEqual(a: any, b: any, _message?: string) { + expect(a).not.toEqual(b); + } + public ok(a: any, _message?: string) { expect(a).toBeTruthy(); } From de9d2f77779f16ead3ab871b8d4a51d12c700ea2 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 5 Oct 2020 11:34:55 +0200 Subject: [PATCH 08/47] fix(ec2): `InitCommand.shellCommand()` renders an argv command instead (#10691) `InitCommand.shellCommand('abc xyz')` renders to `['abc xyz']` which actually represents an `argv` command of one element, which is treated differently. For example, spaces in it are not parsed, which would be expected for a shell command. The correct rendering for a shell command is a plain string in the `command` property. Fixes #10684. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../@aws-cdk/aws-ec2/lib/cfn-init-elements.ts | 4 ++-- .../aws-ec2/test/cfn-init-element.test.ts | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/lib/cfn-init-elements.ts b/packages/@aws-cdk/aws-ec2/lib/cfn-init-elements.ts index ed2aef6fb14ed..a190c17d7aa20 100644 --- a/packages/@aws-cdk/aws-ec2/lib/cfn-init-elements.ts +++ b/packages/@aws-cdk/aws-ec2/lib/cfn-init-elements.ts @@ -211,7 +211,7 @@ export class InitCommand extends InitElement { * need to be preceded by a `\` if you want to treat them as part of a filename. */ public static shellCommand(shellCommand: string, options: InitCommandOptions = {}): InitCommand { - return new InitCommand([shellCommand], options); + return new InitCommand(shellCommand, options); } /** @@ -228,7 +228,7 @@ export class InitCommand extends InitElement { public readonly elementType = InitElementType.COMMAND.toString(); - private constructor(private readonly command: string[], private readonly options: InitCommandOptions) { + private constructor(private readonly command: string[] | string, private readonly options: InitCommandOptions) { super(); } diff --git a/packages/@aws-cdk/aws-ec2/test/cfn-init-element.test.ts b/packages/@aws-cdk/aws-ec2/test/cfn-init-element.test.ts index 2f81ff04acbbe..e794021c46b8f 100644 --- a/packages/@aws-cdk/aws-ec2/test/cfn-init-element.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/cfn-init-element.test.ts @@ -44,7 +44,20 @@ describe('InitCommand', () => { // THEN expect(rendered).toEqual({ - '000': { command: ['/bin/sh'] }, + '000': { command: '/bin/sh' }, + }); + }); + + test('shell command is rendered as string', () => { + // GIVEN + const command = ec2.InitCommand.shellCommand('/bin/sh -c "echo hello"'); + + // WHEN + const rendered = getElementConfig(command, InitPlatform.LINUX); + + // THEN + expect(rendered).toEqual({ + '000': { command: '/bin/sh -c "echo hello"' }, }); }); @@ -65,7 +78,7 @@ describe('InitCommand', () => { // THEN expect(rendered).toEqual({ command_0: { - command: ['/bin/sh'], + command: '/bin/sh', env: { SECRETS_FILE: '/tmp/secrets' }, cwd: '/home/myUser', test: 'test -d /home/myUser', From 7178374a3e545083724af70fbd777fbaabd33b1c Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 5 Oct 2020 12:02:34 +0200 Subject: [PATCH 09/47] fix(ec2): `addExecuteFileCommand` arguments cannot be omitted (#10692) If they are left out, they render as `undefined` which is definitely not what's intended. What's worse, this behavior was even encoded into our unit tests `>_<`. Fixes #10687. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-ec2/lib/user-data.ts | 4 ++-- packages/@aws-cdk/aws-ec2/test/userdata.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/lib/user-data.ts b/packages/@aws-cdk/aws-ec2/lib/user-data.ts index 18435785318a5..21727212948c0 100644 --- a/packages/@aws-cdk/aws-ec2/lib/user-data.ts +++ b/packages/@aws-cdk/aws-ec2/lib/user-data.ts @@ -166,7 +166,7 @@ class LinuxUserData extends UserData { this.addCommands( 'set -e', `chmod +x '${params.filePath}'`, - `'${params.filePath}' ${params.arguments}`, + `'${params.filePath}' ${params.arguments ?? ''}`.trim(), ); } @@ -222,7 +222,7 @@ class WindowsUserData extends UserData { public addExecuteFileCommand( params: ExecuteFileOptions): void { this.addCommands( - `&'${params.filePath}' ${params.arguments}`, + `&'${params.filePath}' ${params.arguments ?? ''}`.trim(), `if (!$?) { Write-Error 'Failed to execute the file "${params.filePath}"' -ErrorAction Stop }`, ); } diff --git a/packages/@aws-cdk/aws-ec2/test/userdata.test.ts b/packages/@aws-cdk/aws-ec2/test/userdata.test.ts index bda3c6cc71ddc..b674e72abac68 100644 --- a/packages/@aws-cdk/aws-ec2/test/userdata.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/userdata.test.ts @@ -102,7 +102,7 @@ nodeunitShim({ // THEN const rendered = userData.render(); - test.equals(rendered, '&\'C:\\test\\filename.bat\' undefined\n' + + test.equals(rendered, '&\'C:\\test\\filename.bat\'\n' + 'if (!$?) { Write-Error \'Failed to execute the file "C:\\test\\filename.bat"\' -ErrorAction Stop }\n' + '&\'C:\\test\\filename2.bat\' arg1 arg2 -arg $variable\n' + 'if (!$?) { Write-Error \'Failed to execute the file "C:\\test\\filename2.bat"\' -ErrorAction Stop }', @@ -209,7 +209,7 @@ nodeunitShim({ test.equals(rendered, '#!/bin/bash\n' + 'set -e\n' + 'chmod +x \'/tmp/filename.sh\'\n' + - '\'/tmp/filename.sh\' undefined\n' + + '\'/tmp/filename.sh\'\n' + 'set -e\n' + 'chmod +x \'/test/filename2.sh\'\n' + '\'/test/filename2.sh\' arg1 arg2 -arg $variable', From a72cfbd5d0f9af87aacf0657a6fc370ce2a23c55 Mon Sep 17 00:00:00 2001 From: Mate Gabri Date: Mon, 5 Oct 2020 21:28:54 +1100 Subject: [PATCH 10/47] fix(ec2): memory optimised graviton2 instance type (#10615) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-ec2/lib/instance-types.ts | 10 ++++++++++ packages/@aws-cdk/aws-ec2/test/instance.test.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/lib/instance-types.ts b/packages/@aws-cdk/aws-ec2/lib/instance-types.ts index 7ad1d2420aa26..d6ce443bb6291 100644 --- a/packages/@aws-cdk/aws-ec2/lib/instance-types.ts +++ b/packages/@aws-cdk/aws-ec2/lib/instance-types.ts @@ -148,6 +148,16 @@ export enum InstanceClass { */ R5AD = 'r5a', + /** + * Memory optimized instances, 6th generation with Graviton2 processors + */ + MEMORY6_GRAVITON = 'r6g', + + /** + * Memory optimized instances, 6th generation with Graviton2 processors + */ + R6G = 'r6g', + /** * Compute optimized instances, 3rd generation */ diff --git a/packages/@aws-cdk/aws-ec2/test/instance.test.ts b/packages/@aws-cdk/aws-ec2/test/instance.test.ts index f1a0da3ba62f9..286c732e09db3 100644 --- a/packages/@aws-cdk/aws-ec2/test/instance.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/instance.test.ts @@ -19,12 +19,12 @@ nodeunitShim({ new Instance(stack, 'Instance', { vpc, machineImage: new AmazonLinuxImage(), - instanceType: InstanceType.of(InstanceClass.COMPUTE6_GRAVITON2, InstanceSize.LARGE), + instanceType: InstanceType.of(InstanceClass.MEMORY6_GRAVITON, InstanceSize.LARGE), }); // THEN cdkExpect(stack).to(haveResource('AWS::EC2::Instance', { - InstanceType: 'c6g.large', + InstanceType: 'r6g.large', })); test.done(); From 3f6275265f84cbc04e12660496e9d9eb7cd65354 Mon Sep 17 00:00:00 2001 From: Dylan Lundy Date: Mon, 5 Oct 2020 23:37:16 +1030 Subject: [PATCH 11/47] fix(cli): `cdk context --reset ` does not work (#10619) *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* Fixes #3033 --- packages/aws-cdk/lib/commands/context.ts | 4 ++-- .../test/commands/context-command.test.ts | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/commands/context.ts b/packages/aws-cdk/lib/commands/context.ts index 748e72ba4aabe..994bb7c675636 100644 --- a/packages/aws-cdk/lib/commands/context.ts +++ b/packages/aws-cdk/lib/commands/context.ts @@ -106,8 +106,8 @@ function keyByNumber(context: any, n: number) { /** * Return enumerated keys in a definitive order */ -function contextKeys(context: any) { - const keys = Object.keys(context); +function contextKeys(context: Context): [number, string][] { + const keys = context.keys; keys.sort(); return enumerate1(keys); } diff --git a/packages/aws-cdk/test/commands/context-command.test.ts b/packages/aws-cdk/test/commands/context-command.test.ts index 69bf7f5705491..47b9ffc070f82 100644 --- a/packages/aws-cdk/test/commands/context-command.test.ts +++ b/packages/aws-cdk/test/commands/context-command.test.ts @@ -23,3 +23,26 @@ test('context reset can remove a context key', async () => { baz: 'quux', }); }); + +test('context reset can remove a context key using number', async () => { + // GIVEN + const configuration = new Configuration(); + configuration.context.set('foo', 'bar'); + configuration.context.set('baz', 'quux'); + + expect(configuration.context.all).toEqual({ + foo: 'bar', + baz: 'quux', + }); + + // WHEN + await realHandler({ + configuration, + args: { reset: '1' }, + } as any); + + // THEN + expect(configuration.context.all).toEqual({ + foo: 'bar', + }); +}); From 317d9cf7ada2663e88f3bd3185f64e6c28d663ae Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 5 Oct 2020 15:34:35 +0200 Subject: [PATCH 12/47] chore(core): cache asset hashes (#10478) Cache asset hashes. This avoids file system and bundling operations when the same asset with the same configuration is used in multiple stacks in an app. Closes #9424 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../@aws-cdk/aws-ec2/test/cfn-init.test.ts | 4 +- packages/@aws-cdk/core/lib/asset-staging.ts | 87 ++++++++++++++++--- packages/@aws-cdk/core/test/staging.test.ts | 57 +++++++++++- 3 files changed, 133 insertions(+), 15 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts b/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts index 38270500d4a9e..af354a0712cf4 100644 --- a/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts @@ -6,7 +6,7 @@ import '@aws-cdk/assert/jest'; import * as iam from '@aws-cdk/aws-iam'; import * as s3 from '@aws-cdk/aws-s3'; import { Asset } from '@aws-cdk/aws-s3-assets'; -import { App, Aws, CfnResource, Stack, DefaultStackSynthesizer, IStackSynthesizer, FileAssetSource, FileAssetLocation } from '@aws-cdk/core'; +import { AssetStaging, App, Aws, CfnResource, Stack, DefaultStackSynthesizer, IStackSynthesizer, FileAssetSource, FileAssetLocation } from '@aws-cdk/core'; import * as ec2 from '../lib'; let app: App; @@ -485,6 +485,7 @@ describe('assets n buckets', () => { test('fingerprint data changes on asset hash update', () => { function calculateFingerprint(assetFilePath: string): string | undefined { resetState(); // Needed so the same resources/assets/filenames can be used. + AssetStaging.clearAssetHashCache(); // Needed so changing the content of the file will update the hash const init = ec2.CloudFormationInit.fromElements( ec2.InitFile.fromAsset('/etc/myFile', assetFilePath), ); @@ -514,6 +515,7 @@ describe('assets n buckets', () => { test('fingerprint data changes on existing asset update, even for assets with unchanging URLs', () => { function calculateFingerprint(assetFilePath: string): string | undefined { resetStateWithSynthesizer(new SingletonLocationSythesizer()); + AssetStaging.clearAssetHashCache(); // Needed so changing the content of the file will update the hash const init = ec2.CloudFormationInit.fromElements( ec2.InitFile.fromExistingAsset('/etc/myFile', new Asset(stack, 'FileAsset', { path: assetFilePath })), ); diff --git a/packages/@aws-cdk/core/lib/asset-staging.ts b/packages/@aws-cdk/core/lib/asset-staging.ts index ca051c2c48165..70444124de25a 100644 --- a/packages/@aws-cdk/core/lib/asset-staging.ts +++ b/packages/@aws-cdk/core/lib/asset-staging.ts @@ -55,6 +55,27 @@ export class AssetStaging extends CoreConstruct { */ public static readonly BUNDLING_OUTPUT_DIR = '/asset-output'; + /** + * Clears the asset hash cache + */ + public static clearAssetHashCache() { + this.assetHashCache = {}; + } + + /** + * Cache of asset hashes based on asset configuration to avoid repeated file + * system and bundling operations. + */ + private static assetHashCache: { [key: string]: string } = {}; + + /** + * Get asset hash from cache or calculate it in case of cache miss. + */ + private static getOrCalcAssetHash(cacheKey: string, calcFn: () => string) { + this.assetHashCache[cacheKey] = this.assetHashCache[cacheKey] ?? calcFn(); + return this.assetHashCache[cacheKey]; + } + /** * The path to the asset (stringinfied token). * @@ -84,7 +105,7 @@ export class AssetStaging extends CoreConstruct { private readonly relativePath?: string; - private readonly bundleDir?: string; + private bundleDir?: string; constructor(scope: Construct, id: string, props: AssetStagingProps) { super(scope, id); @@ -101,29 +122,45 @@ export class AssetStaging extends CoreConstruct { // optional from a caller perspective. const hashType = determineHashType(props.assetHashType, props.assetHash); + // Calculate a cache key from the props. This way we can check if we already + // staged this asset (e.g. the same asset with the same configuration is used + // in multiple stacks). In this case we can completely skip file system and + // bundling operations. + const cacheKey = calculateCacheKey({ + sourcePath: path.resolve(props.sourcePath), + bundling: props.bundling, + assetHashType: hashType, + extraHash: props.extraHash, + exclude: props.exclude, + }); + if (props.bundling) { // Check if we actually have to bundle for this stack const bundlingStacks: string[] = this.node.tryGetContext(cxapi.BUNDLING_STACKS) ?? ['*']; const runBundling = bundlingStacks.includes(Stack.of(this).stackName) || bundlingStacks.includes('*'); if (runBundling) { - // Determine the source hash in advance of bundling if the asset hash type - // is SOURCE so that the bundler can opt to re-use its previous output. - const sourceHash = hashType === AssetHashType.SOURCE - ? this.calculateHash(hashType, props.assetHash, props.bundling) - : undefined; - - this.bundleDir = this.bundle(props.bundling, outdir, sourceHash); - this.assetHash = sourceHash ?? this.calculateHash(hashType, props.assetHash, props.bundling); + const bundling = props.bundling; + this.assetHash = AssetStaging.getOrCalcAssetHash(cacheKey, () => { + // Determine the source hash in advance of bundling if the asset hash type + // is SOURCE so that the bundler can opt to re-use its previous output. + const sourceHash = hashType === AssetHashType.SOURCE + ? this.calculateHash(hashType, props.assetHash, props.bundling) + : undefined; + this.bundleDir = this.bundle(bundling, outdir, sourceHash); + return sourceHash ?? this.calculateHash(hashType, props.assetHash, props.bundling); + }); this.relativePath = renderAssetFilename(this.assetHash); this.stagedPath = this.relativePath; } else { // Bundling is skipped - this.assetHash = props.assetHashType === AssetHashType.BUNDLE || props.assetHashType === AssetHashType.OUTPUT - ? this.calculateHash(AssetHashType.CUSTOM, this.node.path) // Use node path as dummy hash because we're not bundling - : this.calculateHash(hashType, props.assetHash); + this.assetHash = AssetStaging.getOrCalcAssetHash(cacheKey, () => { + return props.assetHashType === AssetHashType.BUNDLE || props.assetHashType === AssetHashType.OUTPUT + ? this.calculateHash(AssetHashType.CUSTOM, this.node.path) // Use node path as dummy hash because we're not bundling + : this.calculateHash(hashType, props.assetHash); + }); this.stagedPath = this.sourcePath; } } else { - this.assetHash = this.calculateHash(hashType, props.assetHash); + this.assetHash = AssetStaging.getOrCalcAssetHash(cacheKey, () => this.calculateHash(hashType, props.assetHash)); this.relativePath = renderAssetFilename(this.assetHash, path.extname(this.sourcePath)); this.stagedPath = this.relativePath; } @@ -332,3 +369,27 @@ function determineHashType(assetHashType?: AssetHashType, assetHash?: string) { return AssetHashType.SOURCE; } } + +/** + * Calculates a cache key from the props. Normalize by sorting keys. + */ +function calculateCacheKey(props: AssetStagingProps): string { + return crypto.createHash('sha256') + .update(JSON.stringify(sortObject(props))) + .digest('hex'); +} + +/** + * Recursively sort object keys + */ +function sortObject(object: { [key: string]: any }): { [key: string]: any } { + if (typeof object !== 'object' || object instanceof Array) { + return object; + } + const ret: { [key: string]: any } = {}; + for (const key of Object.keys(object).sort()) { + ret[key] = sortObject(object[key]); + } + return ret; +} + diff --git a/packages/@aws-cdk/core/test/staging.test.ts b/packages/@aws-cdk/core/test/staging.test.ts index 0ab19b3f26074..a40e67edbfd96 100644 --- a/packages/@aws-cdk/core/test/staging.test.ts +++ b/packages/@aws-cdk/core/test/staging.test.ts @@ -4,7 +4,7 @@ import * as cxapi from '@aws-cdk/cx-api'; import * as fs from 'fs-extra'; import { nodeunitShim, Test } from 'nodeunit-shim'; import * as sinon from 'sinon'; -import { App, AssetHashType, AssetStaging, BundlingDockerImage, BundlingOptions, Stack } from '../lib'; +import { App, AssetHashType, AssetStaging, BundlingDockerImage, BundlingOptions, FileSystem, Stack } from '../lib'; const STUB_INPUT_FILE = '/tmp/docker-stub.input'; const STUB_INPUT_CONCAT_FILE = '/tmp/docker-stub.input.concat'; @@ -24,6 +24,7 @@ process.env.CDK_DOCKER = `${__dirname}/docker-stub.sh`; nodeunitShim({ 'tearDown'(cb: any) { + AssetStaging.clearAssetHashCache(); if (fs.existsSync(STUB_INPUT_FILE)) { fs.unlinkSync(STUB_INPUT_FILE); } @@ -221,6 +222,56 @@ nodeunitShim({ test.done(); }, + 'uses asset hash cache with AssetHashType.OUTPUT'(test: Test) { + // GIVEN + const app = new App(); + const stack = new Stack(app, 'stack'); + const directory = path.join(__dirname, 'fs', 'fixtures', 'test1'); + const fingerPrintSpy = sinon.spy(FileSystem, 'fingerprint'); + + // WHEN + new AssetStaging(stack, 'Asset', { + sourcePath: directory, + assetHashType: AssetHashType.OUTPUT, + bundling: { + image: BundlingDockerImage.fromRegistry('alpine'), + command: [DockerStubCommand.SUCCESS], + }, + }); + + new AssetStaging(stack, 'AssetDuplicate', { + sourcePath: directory, + assetHashType: AssetHashType.OUTPUT, + bundling: { // Same bundling but with keys ordered differently + command: [DockerStubCommand.SUCCESS], + image: BundlingDockerImage.fromRegistry('alpine'), + }, + }); + + // THEN + const assembly = app.synth(); + + // We're testing that docker was run exactly once even though there are two bundling assets + // and that the hash is based on the output + test.deepEqual( + readDockerStubInputConcat(), + `run --rm ${USER_ARG} -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS`, + ); + + test.deepEqual(fs.readdirSync(assembly.directory), [ + 'asset.33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f', + 'cdk.out', + 'manifest.json', + 'stack.template.json', + 'tree.json', + ]); + + // Only one fingerprinting + test.ok(fingerPrintSpy.calledOnce); + + test.done(); + }, + 'bundler considers its options when reusing bundle output'(test: Test) { // GIVEN const app = new App(); @@ -351,6 +402,10 @@ nodeunitShim({ }, }); + // Clear asset hash cache to show that during the second synth bundling + // will consider the existing bundling dir (file system cache). + AssetStaging.clearAssetHashCache(); + // GIVEN const app2 = new App({ outdir: TEST_OUTDIR }); const stack2 = new Stack(app2, 'stack'); From 9444399b08825b4d1c5dce58e3c396c9941724c4 Mon Sep 17 00:00:00 2001 From: Nick Lynch Date: Mon, 5 Oct 2020 15:01:58 +0100 Subject: [PATCH 13/47] fix(elbv2): metric(Un)HealthyHostCount don't use TargetGroup dimension (#10697) Both the HealthyHostCount and UnHealthyHostCount metrics require the TargetGroup as a dimension, in addition to the LoadBalancer dimension. The current `NetworkLoadBalancer.metric(Un)HealthyHostCount` methods don't account for this, and return broken metrics. The methods can't even be properly fixed to do the right thing, because the proper solution results in one metric per TargetGroup, whereas the current signature returns a single `IMetric`. Moving the metrics to the TargetGroup will provide a way to get at these metrics. fixes #5046 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../lib/nlb/network-load-balancer.ts | 2 + .../lib/nlb/network-target-group.ts | 38 +++++++++++- .../test/nlb/target-group.test.ts | 61 +++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts index 40743f03464a4..d8ba0a8b77506 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts @@ -185,6 +185,7 @@ export class NetworkLoadBalancer extends BaseLoadBalancer implements INetworkLoa * The number of targets that are considered healthy. * * @default Average over 5 minutes + * @deprecated use ``NetworkTargetGroup.metricHealthyHostCount`` instead */ public metricHealthyHostCount(props?: cloudwatch.MetricOptions) { return this.metric('HealthyHostCount', { @@ -197,6 +198,7 @@ export class NetworkLoadBalancer extends BaseLoadBalancer implements INetworkLoa * The number of targets that are considered unhealthy. * * @default Average over 5 minutes + * @deprecated use ``NetworkTargetGroup.metricUnHealthyHostCount`` instead */ public metricUnHealthyHostCount(props?: cloudwatch.MetricOptions) { return this.metric('UnHealthyHostCount', { diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-target-group.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-target-group.ts index 8ac9769995dda..3c2e3cb574609 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-target-group.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-target-group.ts @@ -1,3 +1,4 @@ +import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { @@ -104,6 +105,30 @@ export class NetworkTargetGroup extends TargetGroupBase implements INetworkTarge this.listeners.push(listener); } + /** + * The number of targets that are considered healthy. + * + * @default Average over 5 minutes + */ + public metricHealthyHostCount(props?: cloudwatch.MetricOptions) { + return this.metric('HealthyHostCount', { + statistic: 'Average', + ...props, + }); + } + + /** + * The number of targets that are considered unhealthy. + * + * @default Average over 5 minutes + */ + public metricUnHealthyHostCount(props?: cloudwatch.MetricOptions) { + return this.metric('UnHealthyHostCount', { + statistic: 'Average', + ...props, + }); + } + /** * Full name of first load balancer */ @@ -142,7 +167,7 @@ export class NetworkTargetGroup extends TargetGroupBase implements INetworkTarge } if (healthCheck.healthyThresholdCount && healthCheck.unhealthyThresholdCount && - healthCheck.healthyThresholdCount !== healthCheck.unhealthyThresholdCount) { + healthCheck.healthyThresholdCount !== healthCheck.unhealthyThresholdCount) { ret.push([ `Healthy and Unhealthy Threshold Counts must be the same: ${healthCheck.healthyThresholdCount}`, `is not equal to ${healthCheck.unhealthyThresholdCount}.`, @@ -171,6 +196,15 @@ export class NetworkTargetGroup extends TargetGroupBase implements INetworkTarge return ret; } + + private metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric { + return new cloudwatch.Metric({ + namespace: 'AWS/NetworkELB', + metricName, + dimensions: { LoadBalancer: this.firstLoadBalancerFullName, TargetGroup: this.targetGroupFullName }, + ...props, + }).attachTo(this); + } } /** @@ -223,7 +257,7 @@ export interface INetworkLoadBalancerTarget { const NLB_HEALTH_CHECK_PROTOCOLS = [Protocol.HTTP, Protocol.HTTPS, Protocol.TCP]; const NLB_PATH_HEALTH_CHECK_PROTOCOLS = [Protocol.HTTP, Protocol.HTTPS]; -const NLB_HEALTH_CHECK_TIMEOUTS: {[protocol in Protocol]?: number} = { +const NLB_HEALTH_CHECK_TIMEOUTS: { [protocol in Protocol]?: number } = { [Protocol.HTTP]: 6, [Protocol.HTTPS]: 10, [Protocol.TCP]: 10, diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts index 6f50cd19be618..d267d2cdafa90 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts @@ -1,4 +1,5 @@ import '@aws-cdk/assert/jest'; +import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; import * as elbv2 from '../../lib'; @@ -204,4 +205,64 @@ describe('tests', () => { app.synth(); }).toThrow(/Healthy and Unhealthy Threshold Counts must be the same: 5 is not equal to 3./); }); + + test('Exercise metrics', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'Stack'); + const lb = new elbv2.NetworkLoadBalancer(stack, 'LB', { vpc }); + const listener = new elbv2.NetworkListener(stack, 'Listener', { + loadBalancer: lb, + port: 80, + }); + const targetGroup = new elbv2.NetworkTargetGroup(stack, 'Group', { + vpc, + port: 80, + }); + listener.addTargetGroups('unused', targetGroup); + + // WHEN + const metrics = new Array(); + metrics.push(targetGroup.metricHealthyHostCount()); + metrics.push(targetGroup.metricUnHealthyHostCount()); + + // THEN + + // Ideally, this would just be a GetAtt of the LB name, but the target group + // doesn't have a direct reference to the LB, and instead builds up the LB name + // from the listener ARN. + const splitListenerName = { 'Fn::Split': ['/', { Ref: 'Listener828B0E81' }] }; + const loadBalancerNameFromListener = { + 'Fn::Join': ['', + [ + { 'Fn::Select': [1, splitListenerName] }, + '/', + { 'Fn::Select': [2, splitListenerName] }, + '/', + { 'Fn::Select': [3, splitListenerName] }, + ]], + }; + + for (const metric of metrics) { + expect(metric.namespace).toEqual('AWS/NetworkELB'); + expect(stack.resolve(metric.dimensions)).toEqual({ + LoadBalancer: loadBalancerNameFromListener, + TargetGroup: { 'Fn::GetAtt': ['GroupC77FDACD', 'TargetGroupFullName'] }, + }); + } + }); + + test('Metrics requires a listener to be present', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'Stack'); + const targetGroup = new elbv2.NetworkTargetGroup(stack, 'Group', { + vpc, + port: 80, + }); + + // THEN + expect(() => targetGroup.metricHealthyHostCount()).toThrow(/The TargetGroup needs to be attached to a LoadBalancer/); + expect(() => targetGroup.metricUnHealthyHostCount()).toThrow(/The TargetGroup needs to be attached to a LoadBalancer/); + }); }); From 0ec45881e66f598ec37bb772cd01c30be4da96f8 Mon Sep 17 00:00:00 2001 From: Nick Lynch Date: Mon, 5 Oct 2020 15:27:54 +0100 Subject: [PATCH 14/47] fix(cloudfront-origins): S3Origins with cross-stack buckets cause cyclic references (#10696) An S3Origin creates an OriginAccessIdentity, and grants that identity read permissions on the bucket. This creates cyclic references when the bucket is located in a different stack than the distribution. The bucket has a dependency on the generated OAI user for the BucketPolicy, and the Distribution has a dependency on the bucket's domain name for the origin. The fix detects a cross-stack bucket and re-parents the OAI in the bucket's stack to prevent cyclic references. fixes #10399 --- .../aws-cloudfront-origins/lib/s3-origin.ts | 11 ++++++- .../test/s3-origin.test.ts | 31 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts b/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts index 04c3d5175cace..9159bc1f545ed 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts +++ b/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts @@ -58,7 +58,16 @@ class S3BucketOrigin extends cloudfront.OriginBase { public bind(scope: cdk.Construct, options: cloudfront.OriginBindOptions): cloudfront.OriginBindConfig { if (!this.originAccessIdentity) { - this.originAccessIdentity = new cloudfront.OriginAccessIdentity(scope, 'S3Origin', { + // Using a bucket from another stack creates a cyclic reference with + // the bucket taking a dependency on the generated S3CanonicalUserId when `grantRead` is called, + // and the distribution having a dependency on the bucket's domain name. + // Fix this by parenting the OAI in the bucket's stack when cross-stack usage is detected. + const bucketStack = cdk.Stack.of(this.bucket); + const bucketInDifferentStack = bucketStack !== cdk.Stack.of(scope); + const oaiScope = bucketInDifferentStack ? bucketStack : scope; + const oaiId = bucketInDifferentStack ? `${scope.node.uniqueId}S3Origin` : 'S3Origin'; + + this.originAccessIdentity = new cloudfront.OriginAccessIdentity(oaiScope, oaiId, { comment: `Identity for ${options.originId}`, }); this.bucket.grantRead(this.originAccessIdentity); diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts b/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts index 1d99534652d23..84aacc84916d6 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts @@ -9,9 +9,7 @@ let stack: Stack; beforeEach(() => { app = new App(); - stack = new Stack(app, 'Stack', { - env: { account: '1234', region: 'testregion' }, - }); + stack = new Stack(app, 'Stack'); }); describe('With bucket', () => { @@ -67,6 +65,33 @@ describe('With bucket', () => { }, }); }); + + test('as a cross-stack reference', () => { + // Bucket stack and bucket + const bucketStack = new Stack(app, 'BucketStack'); + const bucket = new s3.Bucket(bucketStack, 'Bucket'); + + // Distribution stack and distribution + const origin = new S3Origin(bucket); + new cloudfront.Distribution(stack, 'Dist', { defaultBehavior: { origin } }); + + expect(stack).toHaveResource('AWS::CloudFront::Distribution'); + expect(bucketStack).toHaveResource('AWS::S3::Bucket'); + expect(bucketStack).toHaveResourceLike('AWS::CloudFront::CloudFrontOriginAccessIdentity', { + CloudFrontOriginAccessIdentityConfig: { + Comment: 'Identity for StackDistOrigin15754CE84', + }, + }); + expect(bucketStack).toHaveResourceLike('AWS::S3::BucketPolicy', { + PolicyDocument: { + Statement: [{ + Principal: { + CanonicalUser: { 'Fn::GetAtt': ['StackDistOrigin15754CE84S3Origin25582A25', 'S3CanonicalUserId'] }, + }, + }], + }, + }); + }); }); describe('With website-configured bucket', () => { From e0b55086cf9061e579c3c804b4d2e169ec9d7ae2 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 5 Oct 2020 16:54:42 +0200 Subject: [PATCH 15/47] fix(cli): 'stack already contains Metadata resource' warning (#10695) This warning was added to detect an inability to add the metadata resource in the CLI, before the framework started emitting the metadata resource by default. Now it's expected, and the warning doesn't make any sense anymore. Fixes #10625. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/lib/api/cxapp/cloud-executable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts index 859bf10c6e2e6..9f3e32ddb2389 100644 --- a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts +++ b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts @@ -131,7 +131,7 @@ export class CloudExecutable { stack.template.Resources = {}; } if (stack.template.Resources.CDKMetadata) { - warning(`The stack ${stack.id} already includes a CDKMetadata resource`); + // Already added by framework, this is expected. return; } From 7bb5cf43113db76d7e5e0fec5643e2e4cd64d289 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 5 Oct 2020 17:21:31 +0200 Subject: [PATCH 16/47] fix(core): Stacks from 3rd-party libraries do not synthesize correctly (#10690) Even though this is arguably somewhat of an antipattern and user error: - You should not be vending `Stack`s from libraries. - All libraries should be using a single version of the CDK so that NPM can dedupe it (or use `peerDependencies` to avoid this altogether) This is still a sharp edge that we can blunt a little by not using the `instanceof` language feature. No test because it needs a second copy of the CDK to expose it. Fixes #10671. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/core/lib/private/synthesis.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/core/lib/private/synthesis.ts b/packages/@aws-cdk/core/lib/private/synthesis.ts index c8243ec03c763..bcc6ddc94dbc8 100644 --- a/packages/@aws-cdk/core/lib/private/synthesis.ts +++ b/packages/@aws-cdk/core/lib/private/synthesis.ts @@ -153,7 +153,7 @@ function synthesizeTree(root: IConstruct, builder: cxapi.CloudAssemblyBuilder) { assembly: builder, }; - if (construct instanceof Stack) { + if (Stack.isStack(construct)) { construct.synthesizer.synthesize(session); } else if (construct instanceof TreeMetadata) { construct._synthesizeTree(session); From 3da6420607ce0898654c474cba6498fe0b3d27cf Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Mon, 5 Oct 2020 16:48:27 +0100 Subject: [PATCH 17/47] chore(cdk-build-tools): print build times for all packages (#10681) Print the build times for all packages, irrespective of their success or failure. The motivation is to gather package build times and their contribution to the total build time of the repo. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- tools/cdk-build-tools/bin/cdk-build.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/cdk-build-tools/bin/cdk-build.ts b/tools/cdk-build-tools/bin/cdk-build.ts index 185811c6b0658..96039a2d5b6ea 100644 --- a/tools/cdk-build-tools/bin/cdk-build.ts +++ b/tools/cdk-build-tools/bin/cdk-build.ts @@ -2,7 +2,7 @@ import * as yargs from 'yargs'; import { compileCurrentPackage } from '../lib/compile'; import { lintCurrentPackage } from '../lib/lint'; import { shell } from '../lib/os'; -import { cdkBuildOptions, CompilerOverrides } from '../lib/package-info'; +import { cdkBuildOptions, currentPackageJson, CompilerOverrides } from '../lib/package-info'; import { Timers } from '../lib/timer'; async function main() { @@ -54,12 +54,12 @@ async function main() { const timers = new Timers(); const buildTimer = timers.start('Total time'); -main().then(() => { - buildTimer.end(); -}).catch(e => { - buildTimer.end(); +main().catch(e => { process.stderr.write(`${e.toString()}\n`); - process.stderr.write(`Build failed. ${timers.display()}\n`); + process.stderr.write('Build failed.'); process.stderr.write('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'); process.exit(1); +}).finally(() => { + buildTimer.end(); + process.stdout.write(`Build times for ${currentPackageJson().name}: ${timers.display()}\n`); }); From c60764e28ddc93e5a6f818fdc8e6ae3c0aa09f91 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 5 Oct 2020 19:34:44 +0300 Subject: [PATCH 18/47] feat(readme): deprecate Gitter in favor of cdk.dev Slack (#10700) Shift community chat from Gitter to the cdk.dev Slack workspace ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .github/ISSUE_TEMPLATE.md | 2 +- .github/ISSUE_TEMPLATE/bug.md | 2 +- .github/ISSUE_TEMPLATE/feature-request.md | 2 +- .github/ISSUE_TEMPLATE/general-issues.md | 2 +- README.md | 5 +---- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 3e08711b183e4..5371d422793e3 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -31,4 +31,4 @@ falling prey to the [X/Y problem][2]! ### Other information - + diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index cd536e7a33898..2ad0217714a88 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -41,7 +41,7 @@ What is the unexpected behavior you were seeing? If you got an error, paste it h ### Other - + diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md index 5fecac4f7ce57..c2d12b48d5750 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -31,7 +31,7 @@ labels: feature-request, needs-triage diff --git a/.github/ISSUE_TEMPLATE/general-issues.md b/.github/ISSUE_TEMPLATE/general-issues.md index 64cdaee0da43a..372cb49eb540c 100644 --- a/.github/ISSUE_TEMPLATE/general-issues.md +++ b/.github/ISSUE_TEMPLATE/general-issues.md @@ -32,4 +32,4 @@ falling prey to the [X/Y problem][2]! ### Other information - + diff --git a/README.md b/README.md index 8979eef888e5b..701efa30200be 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # AWS Cloud Development Kit (AWS CDK) ![Build Status](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiSy9rWmVENzRDbXBoVlhYaHBsNks4OGJDRXFtV1IySmhCVjJoaytDU2dtVWhhVys3NS9Odk5DbC9lR2JUTkRvSWlHSXZrNVhYQ3ZsaUJFY3o4OERQY1pnPSIsIml2UGFyYW1ldGVyU3BlYyI6IlB3ODEyRW9KdU0yaEp6NDkiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master) -[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/awslabs/aws-cdk) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/aws/aws-cdk) [![NPM version](https://badge.fury.io/js/aws-cdk.svg)](https://badge.fury.io/js/aws-cdk) [![PyPI version](https://badge.fury.io/py/aws-cdk.core.svg)](https://badge.fury.io/py/aws-cdk.core) @@ -130,11 +129,9 @@ If you have a support plan with AWS Support, you can also create a new [support You may also find help on these community resources: * Look through the [API Reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html) or [Developer Guide](https://docs.aws.amazon.com/cdk/latest/guide) +* The #aws-cdk Slack channel in [cdk.dev](https://cdk.dev) * Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/aws-cdk) and tag it with `aws-cdk` -* Come join the AWS CDK community on [Gitter](https://gitter.im/awslabs/aws-cdk) -* Talk in the CDK channel of the [AWS Developers Slack workspace](https://awsdevelopers.slack.com) (invite required) -* A community-driven Slack channel is also available, invite at [cdk.dev](https://cdk.dev) ### Roadmap From 3cbb86321269b43b22580921b8a41c2af1172512 Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Mon, 5 Oct 2020 18:15:10 +0100 Subject: [PATCH 19/47] chore: migrate all tests off compat layer and use "constructs" module (#10698) Switching all tests and test utilities to use the "constructs" module as preparation for v2 branch. As part of CDKv2, the construct compat layer in the "@aws-cdk/core" module will be removed. This change pre-migrates tests to the new module so as to reduce code divergence between the 'v1' and 'v2' code branches. This will in turn reduce the number of merge conflicts when changes are forward merged from the 'v1' branch onto the 'v2' branch. This change also adds a new private tools module - eslint-plugin-cdk - where CDK specific eslint rules can be added. The first rule now is to ensure that tests and test related utilities do not use the construct compat layer. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/app-delivery/package.json | 1 + .../test/test.pipeline-deploy-stack-action.ts | 3 +- .../@aws-cdk/assert/test/assertions.test.ts | 5 +- .../aws-amplify/test/integ.app-codecommit.ts | 3 +- .../@aws-cdk/aws-amplify/test/integ.app.ts | 3 +- .../aws-apigateway/test/integ.cors.ts | 3 +- ...eg.lambda-api.latebound-deploymentstage.ts | 3 +- .../test/integ.restapi-import.lit.ts | 3 +- .../test/integ.restapi.multistack.ts | 5 +- .../aws-applicationautoscaling/test/util.ts | 4 +- .../test/appsync-directives.test.ts | 2 +- .../test/lifecyclehooks.test.ts | 3 +- .../aws-autoscaling/test/scaling.test.ts | 3 +- .../test/scheduled-action.test.ts | 3 +- .../@aws-cdk/aws-backup/test/integ.backup.ts | 3 +- .../aws-backup/test/selection.test.ts | 11 +- .../test/example.dns-validated-request.lit.ts | 3 +- .../@aws-cdk/aws-cloud9/test/integ.cloud9.ts | 3 +- .../test/integ.core-custom-resources.ts | 2 + .../test/integ.nested-stack.ts | 2 + .../test/integ.nested-stacks-assets.ts | 2 + .../test/integ.nested-stacks-multi.ts | 2 + .../test/integ.nested-stacks-refs1.ts | 2 + .../test/integ.nested-stacks-refs2.ts | 2 + .../test/integ.nested-stacks-refs3.ts | 2 + .../test/integ.trivial-lambda-resource.ts | 2 + .../test/test.nested-stack.ts | 1 + .../aws-cloudformation/test/test.resource.ts | 1 + .../test/example.acm-cert-alias.lit.ts | 3 +- .../test/example.default-cert-alias.lit.ts | 3 +- .../test/example.iam-cert-alias.lit.ts | 3 +- .../test/integ.cloudfront-custom-s3.ts | 3 +- .../aws-cloudwatch/test/test.alarm.ts | 3 +- .../cloudformation/test.pipeline-actions.ts | 7 +- .../aws-codepipeline/test/artifacts.test.ts | 2 + .../test/fake-build-action.ts | 3 +- .../test/fake-source-action.ts | 3 +- .../aws-cognito/test/user-pool.test.ts | 3 +- .../@aws-cdk/aws-docdb/test/instance.test.ts | 3 +- .../@aws-cdk/aws-docdb/test/integ.cluster.ts | 3 +- .../aws-dynamodb/test/integ.global.ts | 3 +- .../aws-ec2/test/integ.share-vpcs.lit.ts | 3 +- .../aws-ec2/test/vpc.from-lookup.test.ts | 3 +- .../test/integ.nested-stacks-docker.ts | 3 +- .../aws-eks-legacy/test/integ.eks-helm.lit.ts | 3 +- .../test/integ.eks-kubectl.lit.ts | 3 +- .../aws-eks-legacy/test/integ.eks-spot.ts | 3 +- packages/@aws-cdk/aws-eks-legacy/test/util.ts | 3 +- .../@aws-cdk/aws-eks/test/pinger/pinger.ts | 9 +- .../@aws-cdk/aws-eks/test/test.cluster.ts | 25 +-- packages/@aws-cdk/aws-eks/test/util.ts | 3 +- .../test/integ.cognito.lit.ts | 3 +- .../test/integ.lambda-target.ts | 3 +- .../test/alb/listener.test.ts | 3 +- .../test/helpers.ts | 3 +- .../test/nlb/listener.test.ts | 3 +- .../integ.elasticsearch.advancedsecurity.ts | 3 +- .../test/integ.elasticsearch.ts | 3 +- .../integ.elasticsearch.unsignedbasicauth.ts | 3 +- .../integ.pipeline-event-target.ts | 3 +- .../test/codepipeline/pipeline.test.ts | 3 +- .../test/lambda/lambda.test.ts | 3 +- .../@aws-cdk/aws-events/test/test.rule.ts | 1 + .../test/integ.globalaccelerator.ts | 3 +- .../aws-globalaccelerator/test/util.ts | 3 +- .../aws-iam/test/cross-account.test.ts | 3 +- .../aws-iam/test/example.attaching.lit.ts | 3 +- .../aws-iam/test/example.external-id.lit.ts | 3 +- .../aws-iam/test/example.managedpolicy.lit.ts | 3 +- .../@aws-cdk/aws-iam/test/example.role.lit.ts | 3 +- packages/@aws-cdk/aws-iam/test/grant.test.ts | 3 +- .../aws-iam/test/integ.condition-with-ref.ts | 3 +- packages/@aws-cdk/aws-kms/test/test.alias.ts | 4 + .../test/integ.destinations.ts | 3 +- .../test/integ.lambda-chain.ts | 3 +- .../test/test-function.ts | 4 +- .../test/integ.dependencies.ts | 3 +- .../aws-lambda-nodejs/test/integ.function.ts | 3 +- .../test/integ.function.py38.ts | 3 +- .../aws-lambda-python/test/integ.function.ts | 3 +- .../test/integ.function.vpc.ts | 3 +- .../aws-lambda/test/integ.bundling.ts | 3 +- .../@aws-cdk/aws-lambda/test/test.lambda.ts | 3 +- .../aws-logs/test/test.subscriptionfilter.ts | 3 +- .../test/integ.api-gateway-domain-name.ts | 3 +- .../test/integ.assets.bundling.lit.ts | 3 +- .../test/bucket-deployment.test.ts | 2 +- .../test/integ.start-execution.ts | 3 +- .../stepfunctions/integ.start-execution.ts | 3 +- .../test/states-language.test.ts | 5 +- .../aws-stepfunctions/test/task-base.test.ts | 3 +- .../cloudformation-include/lib/cfn-include.ts | 27 ++- .../cloudformation-include/package.json | 8 +- .../test/invalid-templates.test.ts | 3 +- .../test/serverless-transform.test.ts | 3 +- .../test/valid-templates.test.ts | 3 +- .../test/yaml-templates.test.ts | 3 +- .../test/provider-framework/integ.provider.ts | 5 +- .../integration-test-fixtures/s3-assert.ts | 13 +- .../integration-test-fixtures/s3-file.ts | 13 +- .../test/cross-environment-infra.test.ts | 3 +- .../test/integ.pipeline-with-assets.ts | 3 +- .../@aws-cdk/pipelines/test/integ.pipeline.ts | 3 +- .../pipelines/test/pipeline-assets.test.ts | 3 +- .../@aws-cdk/pipelines/test/pipeline.test.ts | 3 +- .../pipelines/test/stack-ordering.test.ts | 3 +- packages/@aws-cdk/pipelines/test/testutil.ts | 3 +- .../pipelines/test/validation.test.ts | 3 +- packages/decdk/test/fixture/tsconfig.json | 1 + tools/cdk-build-tools/config/eslintrc.js | 2 + tools/cdk-build-tools/package.json | 1 + tools/eslint-plugin-cdk/.gitignore | 14 ++ tools/eslint-plugin-cdk/LICENSE | 201 ++++++++++++++++++ tools/eslint-plugin-cdk/NOTICE | 2 + tools/eslint-plugin-cdk/README.md | 9 + tools/eslint-plugin-cdk/lib/index.ts | 3 + .../lib/private/import-cache.ts | 38 ++++ .../lib/rules/no-core-construct.ts | 144 +++++++++++++ tools/eslint-plugin-cdk/package.json | 36 ++++ .../eslint-plugin-cdk/test/rules/eslintrc.js | 12 ++ .../aliased-import.expected.ts | 4 + .../no-core-construct/aliased-import.ts | 3 + .../barrel-import.expected.ts | 10 + .../no-core-construct/barrel-import.ts | 9 + .../named-import-not-tail.expected.ts | 10 + .../named-import-not-tail.ts | 9 + .../named-import-tail.expected.ts | 5 + .../no-core-construct/named-import-tail.ts | 4 + .../named-import.expected.ts | 8 + .../no-core-construct/named-import.ts | 7 + .../test/rules/no-core-construct.test.ts | 44 ++++ tools/eslint-plugin-cdk/tsconfig.json | 21 ++ yarn.lock | 20 +- 133 files changed, 888 insertions(+), 134 deletions(-) create mode 100644 tools/eslint-plugin-cdk/.gitignore create mode 100644 tools/eslint-plugin-cdk/LICENSE create mode 100644 tools/eslint-plugin-cdk/NOTICE create mode 100644 tools/eslint-plugin-cdk/README.md create mode 100644 tools/eslint-plugin-cdk/lib/index.ts create mode 100644 tools/eslint-plugin-cdk/lib/private/import-cache.ts create mode 100644 tools/eslint-plugin-cdk/lib/rules/no-core-construct.ts create mode 100644 tools/eslint-plugin-cdk/package.json create mode 100644 tools/eslint-plugin-cdk/test/rules/eslintrc.js create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.expected.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.expected.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.expected.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.expected.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.expected.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.ts create mode 100644 tools/eslint-plugin-cdk/test/rules/no-core-construct.test.ts create mode 100644 tools/eslint-plugin-cdk/tsconfig.json diff --git a/packages/@aws-cdk/app-delivery/package.json b/packages/@aws-cdk/app-delivery/package.json index bb2b578a1720f..08df2cbb16a29 100644 --- a/packages/@aws-cdk/app-delivery/package.json +++ b/packages/@aws-cdk/app-delivery/package.json @@ -38,6 +38,7 @@ "pkglint": "pkglint -f", "test": "cdk-test", "watch": "cdk-watch", + "lint": "cdk-lint", "integ": "cdk-integ", "awslint": "cdk-awslint", "build+test+package": "npm run build+test && npm run package", diff --git a/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts b/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts index 7cb661c8601f7..d63ddbf6acb50 100644 --- a/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts +++ b/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts @@ -8,6 +8,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as s3 from '@aws-cdk/aws-s3'; import * as cxschema from '@aws-cdk/cloud-assembly-schema'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as fc from 'fast-check'; import * as nodeunit from 'nodeunit'; import { PipelineDeployStackAction } from '../lib/pipeline-deploy-stack-action'; @@ -459,7 +460,7 @@ class FakeAction implements codepipeline.IAction { this.outputArtifact = new codepipeline.Artifact('OutputArtifact'); } - public bind(_scope: cdk.Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions): + public bind(_scope: constructs.Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { return {}; } diff --git a/packages/@aws-cdk/assert/test/assertions.test.ts b/packages/@aws-cdk/assert/test/assertions.test.ts index a73b64aaf0329..bd20d60032d76 100644 --- a/packages/@aws-cdk/assert/test/assertions.test.ts +++ b/packages/@aws-cdk/assert/test/assertions.test.ts @@ -1,5 +1,6 @@ import * as cdk from '@aws-cdk/core'; import * as cx from '@aws-cdk/cx-api'; +import * as constructs from 'constructs'; import { countResources, countResourcesLike, exist, expect as cdkExpect, haveType, MatchStyle, matchTemplate } from '../lib/index'; @@ -332,7 +333,7 @@ interface TestResourceProps extends cdk.CfnResourceProps { } class TestResource extends cdk.CfnResource { - constructor(scope: cdk.Construct, id: string, props: TestResourceProps) { + constructor(scope: constructs.Construct, id: string, props: TestResourceProps) { super(scope, id, props); } } @@ -342,7 +343,7 @@ interface TestParameterProps extends cdk.CfnParameterProps { } class TestParameter extends cdk.CfnParameter { - constructor(scope: cdk.Construct, id: string, props: TestParameterProps) { + constructor(scope: constructs.Construct, id: string, props: TestParameterProps) { super(scope, id, props); } } diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.ts b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.ts index 9274cb4b734ef..dce7f81b21e8d 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.ts +++ b/packages/@aws-cdk/aws-amplify/test/integ.app-codecommit.ts @@ -1,5 +1,6 @@ import * as codecommit from '@aws-cdk/aws-codecommit'; -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as amplify from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-amplify/test/integ.app.ts b/packages/@aws-cdk/aws-amplify/test/integ.app.ts index 867aa1fb6638a..83ff527a292e2 100644 --- a/packages/@aws-cdk/aws-amplify/test/integ.app.ts +++ b/packages/@aws-cdk/aws-amplify/test/integ.app.ts @@ -1,4 +1,5 @@ -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as amplify from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-apigateway/test/integ.cors.ts b/packages/@aws-cdk/aws-apigateway/test/integ.cors.ts index 68bf2732cbe2d..5b3fc8bdc36c2 100644 --- a/packages/@aws-cdk/aws-apigateway/test/integ.cors.ts +++ b/packages/@aws-cdk/aws-apigateway/test/integ.cors.ts @@ -1,7 +1,8 @@ /// !cdk-integ pragma:ignore-assets import * as path from 'path'; import * as lambda from '@aws-cdk/aws-lambda'; -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as apigw from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-apigateway/test/integ.lambda-api.latebound-deploymentstage.ts b/packages/@aws-cdk/aws-apigateway/test/integ.lambda-api.latebound-deploymentstage.ts index 31b947921f382..d6176fdb78301 100644 --- a/packages/@aws-cdk/aws-apigateway/test/integ.lambda-api.latebound-deploymentstage.ts +++ b/packages/@aws-cdk/aws-apigateway/test/integ.lambda-api.latebound-deploymentstage.ts @@ -1,5 +1,6 @@ import { Code, Function, Runtime } from '@aws-cdk/aws-lambda'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Deployment, LambdaRestApi, Stage } from '../lib'; class LateBoundDeploymentStageStack extends Stack { diff --git a/packages/@aws-cdk/aws-apigateway/test/integ.restapi-import.lit.ts b/packages/@aws-cdk/aws-apigateway/test/integ.restapi-import.lit.ts index eeb92e9b96813..2607281fbc923 100644 --- a/packages/@aws-cdk/aws-apigateway/test/integ.restapi-import.lit.ts +++ b/packages/@aws-cdk/aws-apigateway/test/integ.restapi-import.lit.ts @@ -1,4 +1,5 @@ -import { App, CfnOutput, Construct, NestedStack, NestedStackProps, Stack } from '@aws-cdk/core'; +import { App, CfnOutput, NestedStack, NestedStackProps, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Deployment, Method, MockIntegration, PassthroughBehavior, RestApi, Stage } from '../lib'; /** diff --git a/packages/@aws-cdk/aws-apigateway/test/integ.restapi.multistack.ts b/packages/@aws-cdk/aws-apigateway/test/integ.restapi.multistack.ts index 86012911a589d..0ac4e01241eba 100644 --- a/packages/@aws-cdk/aws-apigateway/test/integ.restapi.multistack.ts +++ b/packages/@aws-cdk/aws-apigateway/test/integ.restapi.multistack.ts @@ -2,12 +2,13 @@ import * as lambda from '@aws-cdk/aws-lambda'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as apig from '../lib'; class FirstStack extends cdk.Stack { public readonly firstLambda: lambda.Function; - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); this.firstLambda = new lambda.Function(this, 'firstLambda', { @@ -29,7 +30,7 @@ interface SecondStackProps extends cdk.StackProps { } class SecondStack extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props: SecondStackProps) { + constructor(scope: constructs.Construct, id: string, props: SecondStackProps) { super(scope, id, props); const api = new apig.RestApi(this, 'BooksApi', { diff --git a/packages/@aws-cdk/aws-applicationautoscaling/test/util.ts b/packages/@aws-cdk/aws-applicationautoscaling/test/util.ts index 7fd2b95a8a1d6..36929eb527e0f 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/test/util.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/test/util.ts @@ -1,9 +1,9 @@ import * as scalingcommon from '@aws-cdk/aws-autoscaling-common'; -import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as fc from 'fast-check'; import * as appscaling from '../lib'; -export function createScalableTarget(scope: cdk.Construct) { +export function createScalableTarget(scope: constructs.Construct) { return new appscaling.ScalableTarget(scope, 'Target', { serviceNamespace: appscaling.ServiceNamespace.DYNAMODB, scalableDimension: 'test:TestCount', diff --git a/packages/@aws-cdk/aws-appsync/test/appsync-directives.test.ts b/packages/@aws-cdk/aws-appsync/test/appsync-directives.test.ts index 3c47e0b63cf6d..7c0c792be1606 100644 --- a/packages/@aws-cdk/aws-appsync/test/appsync-directives.test.ts +++ b/packages/@aws-cdk/aws-appsync/test/appsync-directives.test.ts @@ -1,6 +1,6 @@ import '@aws-cdk/assert/jest'; -import * as cdk from '@aws-cdk/core'; import * as cognito from '@aws-cdk/aws-cognito'; +import * as cdk from '@aws-cdk/core'; import * as appsync from '../lib'; import * as t from './scalar-type-defintions'; diff --git a/packages/@aws-cdk/aws-autoscaling/test/lifecyclehooks.test.ts b/packages/@aws-cdk/aws-autoscaling/test/lifecyclehooks.test.ts index afea5c3fb1b44..ffa727d6e86a9 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/lifecyclehooks.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/lifecyclehooks.test.ts @@ -2,6 +2,7 @@ import { expect, haveResource, ResourcePart } from '@aws-cdk/assert'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { nodeunitShim, Test } from 'nodeunit-shim'; import * as autoscaling from '../lib'; @@ -71,7 +72,7 @@ nodeunitShim({ }); class FakeNotificationTarget implements autoscaling.ILifecycleHookTarget { - public bind(_scope: cdk.Construct, lifecycleHook: autoscaling.ILifecycleHook): autoscaling.LifecycleHookTargetConfig { + public bind(_scope: constructs.Construct, lifecycleHook: autoscaling.ILifecycleHook): autoscaling.LifecycleHookTargetConfig { lifecycleHook.role.addToPolicy(new iam.PolicyStatement({ actions: ['action:Work'], resources: ['*'], diff --git a/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts b/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts index cf1a7f5590729..10687702a56b1 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts @@ -3,6 +3,7 @@ import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { nodeunitShim, Test } from 'nodeunit-shim'; import * as autoscaling from '../lib'; @@ -228,7 +229,7 @@ class ASGFixture extends cdk.Construct { public readonly vpc: ec2.Vpc; public readonly asg: autoscaling.AutoScalingGroup; - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); this.vpc = new ec2.Vpc(this, 'VPC'); diff --git a/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts b/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts index 185c1b56d3b10..47e2e36f4b119 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts @@ -1,6 +1,7 @@ import { expect, haveResource, MatchStyle } from '@aws-cdk/assert'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { nodeunitShim, Test } from 'nodeunit-shim'; import * as autoscaling from '../lib'; @@ -107,7 +108,7 @@ nodeunitShim({ }, }); -function makeAutoScalingGroup(scope: cdk.Construct) { +function makeAutoScalingGroup(scope: constructs.Construct) { const vpc = new ec2.Vpc(scope, 'VPC'); return new autoscaling.AutoScalingGroup(scope, 'ASG', { vpc, diff --git a/packages/@aws-cdk/aws-backup/test/integ.backup.ts b/packages/@aws-cdk/aws-backup/test/integ.backup.ts index a45a5abbfa077..bf71de03a1cb8 100644 --- a/packages/@aws-cdk/aws-backup/test/integ.backup.ts +++ b/packages/@aws-cdk/aws-backup/test/integ.backup.ts @@ -1,6 +1,7 @@ import * as dynamodb from '@aws-cdk/aws-dynamodb'; import * as efs from '@aws-cdk/aws-efs'; -import { App, Construct, RemovalPolicy, Stack, StackProps } from '@aws-cdk/core'; +import { App, RemovalPolicy, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as backup from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-backup/test/selection.test.ts b/packages/@aws-cdk/aws-backup/test/selection.test.ts index 75d1f6e6eade8..b5523b963c20e 100644 --- a/packages/@aws-cdk/aws-backup/test/selection.test.ts +++ b/packages/@aws-cdk/aws-backup/test/selection.test.ts @@ -2,9 +2,14 @@ import '@aws-cdk/assert/jest'; import * as dynamodb from '@aws-cdk/aws-dynamodb'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as efs from '@aws-cdk/aws-efs'; -import { Construct, Stack } from '@aws-cdk/core'; +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { BackupPlan, BackupResource, BackupSelection } from '../lib'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from '@aws-cdk/core'; + let stack: Stack; let plan: BackupPlan; beforeEach(() => { @@ -120,13 +125,13 @@ test('allow restores', () => { test('fromConstruct', () => { // GIVEN - class EfsConstruct extends Construct { + class EfsConstruct extends CoreConstruct { constructor(scope: Construct, id: string) { super(scope, id); new efs.CfnFileSystem(this, 'FileSystem'); } } - class MyConstruct extends Construct { + class MyConstruct extends CoreConstruct { constructor(scope: Construct, id: string) { super(scope, id); diff --git a/packages/@aws-cdk/aws-certificatemanager/test/example.dns-validated-request.lit.ts b/packages/@aws-cdk/aws-certificatemanager/test/example.dns-validated-request.lit.ts index 3852b9ea8ac6c..b30827a63173d 100644 --- a/packages/@aws-cdk/aws-certificatemanager/test/example.dns-validated-request.lit.ts +++ b/packages/@aws-cdk/aws-certificatemanager/test/example.dns-validated-request.lit.ts @@ -1,5 +1,6 @@ import * as route53 from '@aws-cdk/aws-route53'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as certmgr from '../lib'; class CertStack extends Stack { diff --git a/packages/@aws-cdk/aws-cloud9/test/integ.cloud9.ts b/packages/@aws-cdk/aws-cloud9/test/integ.cloud9.ts index d2d008687f429..0975a83603262 100644 --- a/packages/@aws-cdk/aws-cloud9/test/integ.cloud9.ts +++ b/packages/@aws-cdk/aws-cloud9/test/integ.cloud9.ts @@ -1,10 +1,11 @@ import * as codecommit from '@aws-cdk/aws-codecommit'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as cloud9 from '../lib'; export class Cloud9Env extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); const vpc = new ec2.Vpc(this, 'VPC', { diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.core-custom-resources.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.core-custom-resources.ts index 084e661b5c0b1..41029448ec1dc 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.core-custom-resources.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.core-custom-resources.ts @@ -9,6 +9,8 @@ */ import { App, CfnOutput, Construct, CustomResource, CustomResourceProvider, CustomResourceProviderRuntime, Stack, Token } from '@aws-cdk/core'; +/* eslint-disable cdk/no-core-construct */ + class TestStack extends Stack { constructor(scope: Construct, id: string) { super(scope, id); diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts index ab0df12061264..650609c0e6d40 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stack.ts @@ -5,6 +5,8 @@ import * as sqs from '@aws-cdk/aws-sqs'; import { App, CfnParameter, Construct, Stack } from '@aws-cdk/core'; import * as cfn from '../lib'; +/* eslint-disable cdk/no-core-construct */ + interface MyNestedStackProps { readonly subscriber?: sqs.Queue; readonly siblingTopic?: sns.Topic; // a topic defined in a sibling nested stack diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-assets.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-assets.ts index 5a8cb30a3a333..4a6599c289928 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-assets.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-assets.ts @@ -4,6 +4,8 @@ import * as lambda from '@aws-cdk/aws-lambda'; import { App, Construct, Stack } from '@aws-cdk/core'; import * as cfn from '../lib'; +/* eslint-disable cdk/no-core-construct */ + class NestedStack extends cfn.NestedStack { constructor(scope: Construct, id: string) { super(scope, id); diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-multi.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-multi.ts index 160fa076e7b01..b3e51a8c049f1 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-multi.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-multi.ts @@ -2,6 +2,8 @@ import * as sns from '@aws-cdk/aws-sns'; import { App, Construct, Stack } from '@aws-cdk/core'; import * as cfn from '../lib'; +/* eslint-disable cdk/no-core-construct */ + class YourNestedStack extends cfn.NestedStack { constructor(scope: Construct, id: string) { super(scope, id); diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs1.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs1.ts index a563445adaedd..b6ca8b087f7ad 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs1.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs1.ts @@ -2,6 +2,8 @@ // nested stack references a resource from a non-nested non-parent stack +/* eslint-disable cdk/no-core-construct */ + import * as sns from '@aws-cdk/aws-sns'; import { App, Construct, Stack } from '@aws-cdk/core'; import * as cfn from '../lib'; diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs2.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs2.ts index 74efee0c43e85..5b884b209786b 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs2.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs2.ts @@ -5,6 +5,8 @@ import * as cfn from '../lib'; // non-nested non-parent stack consumes a resource from a nested stack +/* eslint-disable cdk/no-core-construct */ + class ProducerNestedStack extends cfn.NestedStack { public readonly topic: sns.Topic; diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs3.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs3.ts index 87b6f587a5ef5..ab1f51be91330 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs3.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.nested-stacks-refs3.ts @@ -5,6 +5,8 @@ import * as cfn from '../lib'; // references between siblings +/* eslint-disable cdk/no-core-construct */ + class ProducerNestedStack extends cfn.NestedStack { public readonly topic: sns.Topic; diff --git a/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts b/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts index 71e17bd365867..e18bafe3736a8 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.ts @@ -3,6 +3,8 @@ import * as lambda from '@aws-cdk/aws-lambda'; import * as cdk from '@aws-cdk/core'; import { CustomResource, CustomResourceProvider } from '../lib'; +/* eslint-disable cdk/no-core-construct */ + interface DemoResourceProps { /** * Message to echo diff --git a/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts b/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts index 4d01cd68d1da7..de102b4b1cf51 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts @@ -7,6 +7,7 @@ import { App, CfnParameter, CfnResource, Construct, ContextProvider, Stack } fro import { Test } from 'nodeunit'; import { NestedStack } from '../lib/nested-stack'; +/* eslint-disable cdk/no-core-construct */ /* eslint-disable max-len */ export = { diff --git a/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts b/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts index b5b50aef61c5d..9f90779190d71 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts @@ -5,6 +5,7 @@ import * as cdk from '@aws-cdk/core'; import { Test, testCase } from 'nodeunit'; import { CustomResource, CustomResourceProvider } from '../lib'; +/* eslint-disable cdk/no-core-construct */ /* eslint-disable quote-props */ export = testCase({ diff --git a/packages/@aws-cdk/aws-cloudfront/test/example.acm-cert-alias.lit.ts b/packages/@aws-cdk/aws-cloudfront/test/example.acm-cert-alias.lit.ts index 6980e248e7c27..861df3df10bdd 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/example.acm-cert-alias.lit.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/example.acm-cert-alias.lit.ts @@ -1,6 +1,7 @@ import * as certificatemanager from '@aws-cdk/aws-certificatemanager'; import * as s3 from '@aws-cdk/aws-s3'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cloudfront from '../lib'; class AcmCertificateAliasStack extends Stack { diff --git a/packages/@aws-cdk/aws-cloudfront/test/example.default-cert-alias.lit.ts b/packages/@aws-cdk/aws-cloudfront/test/example.default-cert-alias.lit.ts index 8b1e24e88addb..68882bcb9b7ee 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/example.default-cert-alias.lit.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/example.default-cert-alias.lit.ts @@ -1,5 +1,6 @@ import * as s3 from '@aws-cdk/aws-s3'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cloudfront from '../lib'; class AcmCertificateAliasStack extends Stack { diff --git a/packages/@aws-cdk/aws-cloudfront/test/example.iam-cert-alias.lit.ts b/packages/@aws-cdk/aws-cloudfront/test/example.iam-cert-alias.lit.ts index 36ee43e180771..9c8f50f191c9f 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/example.iam-cert-alias.lit.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/example.iam-cert-alias.lit.ts @@ -1,5 +1,6 @@ import * as s3 from '@aws-cdk/aws-s3'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cloudfront from '../lib'; class AcmCertificateAliasStack extends Stack { diff --git a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-custom-s3.ts b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-custom-s3.ts index 9eccc5c2c2712..c3fd14a25c45b 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-custom-s3.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-custom-s3.ts @@ -1,5 +1,6 @@ import * as s3 from '@aws-cdk/aws-s3'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cloudfront from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.alarm.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.alarm.ts index c86fca7f6a22d..6b863af88b1cd 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.alarm.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.alarm.ts @@ -1,5 +1,6 @@ import { ABSENT, expect, haveResource } from '@aws-cdk/assert'; -import { Construct, Duration, Stack } from '@aws-cdk/core'; +import { Duration, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Test } from 'nodeunit'; import { Alarm, IAlarm, IAlarmAction, Metric } from '../lib'; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.pipeline-actions.ts index 3853486f2a193..66e23dcfe0584 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.pipeline-actions.ts @@ -3,6 +3,7 @@ import * as events from '@aws-cdk/aws-events'; import * as iam from '@aws-cdk/aws-iam'; import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as _ from 'lodash'; import * as nodeunit from 'nodeunit'; import * as cpactions from '../../lib'; @@ -314,7 +315,7 @@ function _isOrContains(stack: cdk.Stack, entity: string | string[], value: strin return false; } -function _stackArn(stackName: string, scope: cdk.IConstruct): string { +function _stackArn(stackName: string, scope: constructs.IConstruct): string { return cdk.Stack.of(scope).formatArn({ service: 'cloudformation', resource: 'stack', @@ -328,7 +329,7 @@ class PipelineDouble extends cdk.Resource implements codepipeline.IPipeline { public readonly role: iam.Role; public readonly artifactBucket: s3.IBucket; - constructor(scope: cdk.Construct, id: string, { pipelineName, role }: { pipelineName?: string, role: iam.Role }) { + constructor(scope: constructs.Construct, id: string, { pipelineName, role }: { pipelineName?: string, role: iam.Role }) { super(scope, id); this.pipelineName = pipelineName || 'TestPipeline'; this.pipelineArn = cdk.Stack.of(this).formatArn({ service: 'codepipeline', resource: 'pipeline', resourceName: this.pipelineName }); @@ -391,7 +392,7 @@ class StageDouble implements codepipeline.IStage { class RoleDouble extends iam.Role { public readonly statements = new Array(); - constructor(scope: cdk.Construct, id: string, props: iam.RoleProps = { assumedBy: new iam.ServicePrincipal('test') }) { + constructor(scope: constructs.Construct, id: string, props: iam.RoleProps = { assumedBy: new iam.ServicePrincipal('test') }) { super(scope, id, props); } diff --git a/packages/@aws-cdk/aws-codepipeline/test/artifacts.test.ts b/packages/@aws-cdk/aws-codepipeline/test/artifacts.test.ts index 3c900cf566af1..c67176d1e13ae 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/artifacts.test.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/artifacts.test.ts @@ -285,7 +285,9 @@ nodeunitShim({ }, }); +/* eslint-disable cdk/no-core-construct */ function validate(construct: cdk.IConstruct): cdk.ValidationError[] { cdk.ConstructNode.prepare(construct.node); return cdk.ConstructNode.validate(construct.node); } +/* eslint-enable cdk/no-core-construct */ diff --git a/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts b/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts index 741fd2d188dec..53cec90d55267 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts @@ -1,6 +1,7 @@ import * as events from '@aws-cdk/aws-events'; import * as iam from '@aws-cdk/aws-iam'; -import { Construct, IResource } from '@aws-cdk/core'; +import { IResource } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as codepipeline from '../lib'; export interface FakeBuildActionProps extends codepipeline.CommonActionProps { diff --git a/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts b/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts index 2c198c365410c..ab2f56471f1dd 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts @@ -1,5 +1,6 @@ import * as events from '@aws-cdk/aws-events'; -import { Construct, Lazy } from '@aws-cdk/core'; +import { Lazy } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as codepipeline from '../lib'; export interface IFakeSourceActionVariables { diff --git a/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts b/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts index 7576dacdf1c65..c4cb35832925c 100644 --- a/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts +++ b/packages/@aws-cdk/aws-cognito/test/user-pool.test.ts @@ -2,7 +2,8 @@ import '@aws-cdk/assert/jest'; import { ABSENT } from '@aws-cdk/assert/lib/assertions/have-resource'; import { Role, ServicePrincipal } from '@aws-cdk/aws-iam'; import * as lambda from '@aws-cdk/aws-lambda'; -import { CfnParameter, Construct, Duration, Stack, Tags } from '@aws-cdk/core'; +import { CfnParameter, Duration, Stack, Tags } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { AccountRecovery, Mfa, NumberAttribute, StringAttribute, UserPool, UserPoolIdentityProvider, UserPoolOperation, VerificationEmailStyle } from '../lib'; describe('User Pool', () => { diff --git a/packages/@aws-cdk/aws-docdb/test/instance.test.ts b/packages/@aws-cdk/aws-docdb/test/instance.test.ts index 64b1c4313e174..b3785e700ca01 100644 --- a/packages/@aws-cdk/aws-docdb/test/instance.test.ts +++ b/packages/@aws-cdk/aws-docdb/test/instance.test.ts @@ -1,6 +1,7 @@ import { expect as expectCDK, haveOutput, haveResource, ResourcePart } from '@aws-cdk/assert'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { DatabaseCluster, DatabaseInstance } from '../lib'; @@ -170,7 +171,7 @@ class TestStack extends cdk.Stack { public readonly vpc: ec2.Vpc; public readonly cluster: DatabaseCluster; - constructor(scope?: cdk.Construct, id?: string, props: cdk.StackProps = {}) { + constructor(scope?: constructs.Construct, id?: string, props: cdk.StackProps = {}) { super(scope, id, props); this.node.setContext('availability-zones:12345:us-test-1', ['us-test-1a', 'us-test-1b']); diff --git a/packages/@aws-cdk/aws-docdb/test/integ.cluster.ts b/packages/@aws-cdk/aws-docdb/test/integ.cluster.ts index e90cb8ec4af14..5e7b2049507aa 100644 --- a/packages/@aws-cdk/aws-docdb/test/integ.cluster.ts +++ b/packages/@aws-cdk/aws-docdb/test/integ.cluster.ts @@ -1,6 +1,7 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as kms from '@aws-cdk/aws-kms'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { DatabaseCluster } from '../lib'; import { ClusterParameterGroup } from '../lib/parameter-group'; @@ -10,7 +11,7 @@ import { ClusterParameterGroup } from '../lib/parameter-group'; */ class TestStack extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2 }); diff --git a/packages/@aws-cdk/aws-dynamodb/test/integ.global.ts b/packages/@aws-cdk/aws-dynamodb/test/integ.global.ts index b4ae5d01abccb..27150cf3b5b6d 100644 --- a/packages/@aws-cdk/aws-dynamodb/test/integ.global.ts +++ b/packages/@aws-cdk/aws-dynamodb/test/integ.global.ts @@ -1,5 +1,6 @@ /// !cdk-integ pragma:ignore-assets -import { App, Construct, RemovalPolicy, Stack, StackProps } from '@aws-cdk/core'; +import { App, RemovalPolicy, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as dynamodb from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-ec2/test/integ.share-vpcs.lit.ts b/packages/@aws-cdk/aws-ec2/test/integ.share-vpcs.lit.ts index cbf79ac7a4944..0ea254d29afa7 100644 --- a/packages/@aws-cdk/aws-ec2/test/integ.share-vpcs.lit.ts +++ b/packages/@aws-cdk/aws-ec2/test/integ.share-vpcs.lit.ts @@ -1,5 +1,6 @@ /// !cdk-integ * import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as ec2 from '../lib'; const app = new cdk.App(); @@ -9,7 +10,7 @@ interface ConstructThatTakesAVpcProps { } class ConstructThatTakesAVpc extends cdk.Construct { - constructor(scope: cdk.Construct, id: string, _props: ConstructThatTakesAVpcProps) { + constructor(scope: constructs.Construct, id: string, _props: ConstructThatTakesAVpcProps) { super(scope, id); // new ec2.CfnInstance(this, 'Instance', { diff --git a/packages/@aws-cdk/aws-ec2/test/vpc.from-lookup.test.ts b/packages/@aws-cdk/aws-ec2/test/vpc.from-lookup.test.ts index fb86fb5f2550e..766a16dea0b1d 100644 --- a/packages/@aws-cdk/aws-ec2/test/vpc.from-lookup.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/vpc.from-lookup.test.ts @@ -1,6 +1,7 @@ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Construct, ContextProvider, GetContextValueOptions, GetContextValueResult, Lazy, Stack } from '@aws-cdk/core'; +import { ContextProvider, GetContextValueOptions, GetContextValueResult, Lazy, Stack } from '@aws-cdk/core'; import * as cxapi from '@aws-cdk/cx-api'; +import { Construct } from 'constructs'; import { nodeunitShim, Test } from 'nodeunit-shim'; import { GenericLinuxImage, Instance, InstanceType, SubnetType, Vpc } from '../lib'; diff --git a/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts b/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts index b9bef7bdb18e3..83d71192e18f4 100644 --- a/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts +++ b/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import * as iam from '@aws-cdk/aws-iam'; -import { App, CfnOutput, Construct, NestedStack, NestedStackProps, Stack, StackProps } from '@aws-cdk/core'; +import { App, CfnOutput, NestedStack, NestedStackProps, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as ecr_assets from '../lib'; class TheNestedStack extends NestedStack { diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.ts b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.ts index 35113435a740b..0aaa4fe8c50cf 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.ts +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-helm.lit.ts @@ -2,7 +2,8 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; -import { App, Construct } from '@aws-cdk/core'; +import { App } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Cluster } from '../lib'; import { TestStack } from './util'; diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.ts b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.ts index 1e995733ccab0..2e49c9a2f568e 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.ts +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-kubectl.lit.ts @@ -2,7 +2,8 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; -import { App, Construct } from '@aws-cdk/core'; +import { App } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Cluster } from '../lib'; import { TestStack } from './util'; diff --git a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.ts b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.ts index ee0e8b01de4bf..07a599a4a8756 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.ts +++ b/packages/@aws-cdk/aws-eks-legacy/test/integ.eks-spot.ts @@ -1,5 +1,6 @@ import * as ec2 from '@aws-cdk/aws-ec2'; -import { App, Construct } from '@aws-cdk/core'; +import { App } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as eks from '../lib'; import { TestStack } from './util'; diff --git a/packages/@aws-cdk/aws-eks-legacy/test/util.ts b/packages/@aws-cdk/aws-eks-legacy/test/util.ts index e8ce94592d79a..8912dccc638ed 100644 --- a/packages/@aws-cdk/aws-eks-legacy/test/util.ts +++ b/packages/@aws-cdk/aws-eks-legacy/test/util.ts @@ -1,5 +1,6 @@ import * as ec2 from '@aws-cdk/aws-ec2'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Cluster } from '../lib'; export function testFixture() { diff --git a/packages/@aws-cdk/aws-eks/test/pinger/pinger.ts b/packages/@aws-cdk/aws-eks/test/pinger/pinger.ts index 42ad368667a66..1165da1ca90df 100644 --- a/packages/@aws-cdk/aws-eks/test/pinger/pinger.ts +++ b/packages/@aws-cdk/aws-eks/test/pinger/pinger.ts @@ -1,14 +1,19 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as lambda from '@aws-cdk/aws-lambda'; -import { Construct, CustomResource, Token, Duration } from '@aws-cdk/core'; +import { CustomResource, Token, Duration } from '@aws-cdk/core'; import * as cr from '@aws-cdk/custom-resources'; +import { Construct } from 'constructs'; + +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from '@aws-cdk/core'; export interface PingerProps { readonly url: string; readonly securityGroup?: ec2.SecurityGroup; readonly vpc?: ec2.IVpc; } -export class Pinger extends Construct { +export class Pinger extends CoreConstruct { private _resource: CustomResource; diff --git a/packages/@aws-cdk/aws-eks/test/test.cluster.ts b/packages/@aws-cdk/aws-eks/test/test.cluster.ts index c8b646b059012..afd71faa9c308 100644 --- a/packages/@aws-cdk/aws-eks/test/test.cluster.ts +++ b/packages/@aws-cdk/aws-eks/test/test.cluster.ts @@ -7,6 +7,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as kms from '@aws-cdk/aws-kms'; import * as lambda from '@aws-cdk/aws-lambda'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { Test } from 'nodeunit'; import * as YAML from 'yaml'; import * as eks from '../lib'; @@ -42,7 +43,7 @@ export = { class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; - constructor(scope: cdk.Construct, id: string, props: { sg: ec2.ISecurityGroup, vpc: ec2.IVpc }) { + constructor(scope: constructs.Construct, id: string, props: { sg: ec2.ISecurityGroup, vpc: ec2.IVpc }) { super(scope, id); this.eksCluster = new eks.Cluster(this, 'Cluster', { version: eks.KubernetesVersion.V1_17, @@ -57,7 +58,7 @@ export = { public readonly securityGroup: ec2.ISecurityGroup; public readonly vpc: ec2.IVpc; - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); this.vpc = new ec2.Vpc(this, 'Vpc'); this.securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { vpc: this.vpc }); @@ -80,7 +81,7 @@ export = { class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); this.eksCluster = new eks.Cluster(this, 'Cluster', { version: eks.KubernetesVersion.V1_17, @@ -89,7 +90,7 @@ export = { } class ManifestStack extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { + constructor(scope: constructs.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { super(scope, id, props); // this role creates a dependency between this stack and the cluster stack @@ -131,7 +132,7 @@ export = { class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); this.eksCluster = new eks.Cluster(this, 'Cluster', { version: eks.KubernetesVersion.V1_17, @@ -140,7 +141,7 @@ export = { } class ChartStack extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { + constructor(scope: constructs.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { super(scope, id, props); // this role creates a dependency between this stack and the cluster stack @@ -173,7 +174,7 @@ export = { class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); this.eksCluster = new eks.Cluster(this, 'Cluster', { version: eks.KubernetesVersion.V1_17, @@ -182,7 +183,7 @@ export = { } class ChartStack extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { + constructor(scope: constructs.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { super(scope, id, props); const resource = new cdk.CfnResource(this, 'resource', { type: 'MyType' }); @@ -206,7 +207,7 @@ export = { class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); this.eksCluster = new eks.Cluster(this, 'Cluster', { version: eks.KubernetesVersion.V1_17, @@ -218,7 +219,7 @@ export = { public group: asg.AutoScalingGroup; - constructor(scope: cdk.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { + constructor(scope: constructs.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { super(scope, id, props); // the role is create in this stack implicitly by the ASG @@ -253,7 +254,7 @@ export = { class ClusterStack extends cdk.Stack { public eksCluster: eks.Cluster; - constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { + constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); this.eksCluster = new eks.Cluster(this, 'EKSCluster', { version: eks.KubernetesVersion.V1_17, @@ -262,7 +263,7 @@ export = { } class AppStack extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { + constructor(scope: constructs.Construct, id: string, props: cdk.StackProps & { cluster: eks.Cluster }) { super(scope, id, props); new eks.ServiceAccount(this, 'testAccount', { cluster: props.cluster, name: 'test-account', namespace: 'test' }); diff --git a/packages/@aws-cdk/aws-eks/test/util.ts b/packages/@aws-cdk/aws-eks/test/util.ts index 6176ea5ad100c..2d1490e79d62f 100644 --- a/packages/@aws-cdk/aws-eks/test/util.ts +++ b/packages/@aws-cdk/aws-eks/test/util.ts @@ -1,5 +1,6 @@ import * as ec2 from '@aws-cdk/aws-ec2'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Cluster, KubernetesVersion } from '../lib'; const CLUSTER_VERSION = KubernetesVersion.V1_16; diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/test/integ.cognito.lit.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/test/integ.cognito.lit.ts index c68562ee6ffcb..3516dbf269ea4 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/test/integ.cognito.lit.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/test/integ.cognito.lit.ts @@ -1,7 +1,8 @@ import * as cognito from '@aws-cdk/aws-cognito'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; -import { App, CfnOutput, Construct, Stack } from '@aws-cdk/core'; +import { App, CfnOutput, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as actions from '../lib'; class CognitoStack extends Stack { diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/test/integ.lambda-target.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/test/integ.lambda-target.ts index 912b75066f830..405fa22d03f82 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/test/integ.lambda-target.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/test/integ.lambda-target.ts @@ -1,7 +1,8 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; import * as lambda from '@aws-cdk/aws-lambda'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as targets from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts index 906f3d3d4a339..18f162b1f8210 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts @@ -3,6 +3,7 @@ import '@aws-cdk/assert/jest'; import { Metric } from '@aws-cdk/aws-cloudwatch'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as elbv2 from '../../lib'; import { FakeSelfRegisteringTarget } from '../helpers'; @@ -1366,7 +1367,7 @@ describe('tests', () => { }); class ResourceWithLBDependency extends cdk.CfnResource { - constructor(scope: cdk.Construct, id: string, targetGroup: elbv2.ITargetGroup) { + constructor(scope: constructs.Construct, id: string, targetGroup: elbv2.ITargetGroup) { super(scope, id, { type: 'Test::Resource' }); this.node.addDependency(targetGroup.loadBalancerAttached); } diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts index 8b54f66d6e81b..8fa9d3361db33 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts @@ -1,5 +1,6 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as elbv2 from '../lib'; export class FakeSelfRegisteringTarget extends cdk.Construct implements elbv2.IApplicationLoadBalancerTarget, elbv2.INetworkLoadBalancerTarget, @@ -7,7 +8,7 @@ export class FakeSelfRegisteringTarget extends cdk.Construct implements elbv2.IA public readonly securityGroup: ec2.SecurityGroup; public readonly connections: ec2.Connections; - constructor(scope: cdk.Construct, id: string, vpc: ec2.Vpc) { + constructor(scope: constructs.Construct, id: string, vpc: ec2.Vpc) { super(scope, id); this.securityGroup = new ec2.SecurityGroup(this, 'SG', { vpc }); this.connections = new ec2.Connections({ diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts index 7a41b94efb6aa..4d3573c24d96e 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts @@ -3,6 +3,7 @@ import '@aws-cdk/assert/jest'; import * as acm from '@aws-cdk/aws-certificatemanager'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as elbv2 from '../../lib'; import { FakeSelfRegisteringTarget } from '../helpers'; @@ -390,7 +391,7 @@ describe('tests', () => { }); class ResourceWithLBDependency extends cdk.CfnResource { - constructor(scope: cdk.Construct, id: string, targetGroup: elbv2.ITargetGroup) { + constructor(scope: constructs.Construct, id: string, targetGroup: elbv2.ITargetGroup) { super(scope, id, { type: 'Test::Resource' }); this.node.addDependency(targetGroup.loadBalancerAttached); } diff --git a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.advancedsecurity.ts b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.advancedsecurity.ts index e31fc1ecec6f4..5baf8f4e1b99d 100644 --- a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.advancedsecurity.ts +++ b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.advancedsecurity.ts @@ -1,5 +1,6 @@ import { User } from '@aws-cdk/aws-iam'; -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as es from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.ts b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.ts index 876b2ec4bd139..cb4937b1d5c29 100644 --- a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.ts +++ b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.ts @@ -1,5 +1,6 @@ import { EbsDeviceVolumeType } from '@aws-cdk/aws-ec2'; -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as es from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.ts b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.ts index 4fb2e382f9537..8844e5937305c 100644 --- a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.ts +++ b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.ts @@ -1,4 +1,5 @@ -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as es from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-events-targets/test/codepipeline/integ.pipeline-event-target.ts b/packages/@aws-cdk/aws-events-targets/test/codepipeline/integ.pipeline-event-target.ts index ed9b699e5eea4..b4f321230234f 100644 --- a/packages/@aws-cdk/aws-events-targets/test/codepipeline/integ.pipeline-event-target.ts +++ b/packages/@aws-cdk/aws-events-targets/test/codepipeline/integ.pipeline-event-target.ts @@ -2,6 +2,7 @@ import * as codecommit from '@aws-cdk/aws-codecommit'; import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as events from '@aws-cdk/aws-events'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as targets from '../../lib'; interface MockActionProps extends codepipeline.ActionProperties { @@ -17,7 +18,7 @@ class MockAction implements codepipeline.IAction { this.configuration = props.configuration; } - public bind(_scope: cdk.Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions): + public bind(_scope: constructs.Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { return { configuration: this.configuration, diff --git a/packages/@aws-cdk/aws-events-targets/test/codepipeline/pipeline.test.ts b/packages/@aws-cdk/aws-events-targets/test/codepipeline/pipeline.test.ts index 4540238c3e7fd..68ee1a10ae449 100644 --- a/packages/@aws-cdk/aws-events-targets/test/codepipeline/pipeline.test.ts +++ b/packages/@aws-cdk/aws-events-targets/test/codepipeline/pipeline.test.ts @@ -2,7 +2,8 @@ import { expect, haveResource, haveResourceLike } from '@aws-cdk/assert'; import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as events from '@aws-cdk/aws-events'; import * as iam from '@aws-cdk/aws-iam'; -import { CfnElement, Construct, Stack } from '@aws-cdk/core'; +import { CfnElement, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as targets from '../../lib'; describe('CodePipeline event target', () => { diff --git a/packages/@aws-cdk/aws-events-targets/test/lambda/lambda.test.ts b/packages/@aws-cdk/aws-events-targets/test/lambda/lambda.test.ts index 4d0feb07671bd..ff171b6ee5a80 100644 --- a/packages/@aws-cdk/aws-events-targets/test/lambda/lambda.test.ts +++ b/packages/@aws-cdk/aws-events-targets/test/lambda/lambda.test.ts @@ -2,6 +2,7 @@ import { countResources, expect, haveResource } from '@aws-cdk/assert'; import * as events from '@aws-cdk/aws-events'; import * as lambda from '@aws-cdk/aws-lambda'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as targets from '../../lib'; test('use lambda as an event rule target', () => { @@ -102,7 +103,7 @@ test('adding same singleton lambda function as target mutiple times creates perm expect(stack).to(countResources('AWS::Lambda::Permission', 1)); }); -function newTestLambda(scope: cdk.Construct) { +function newTestLambda(scope: constructs.Construct) { return new lambda.Function(scope, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'bar', diff --git a/packages/@aws-cdk/aws-events/test/test.rule.ts b/packages/@aws-cdk/aws-events/test/test.rule.ts index c22bfb4c2d55d..be9d4b86ff5e4 100644 --- a/packages/@aws-cdk/aws-events/test/test.rule.ts +++ b/packages/@aws-cdk/aws-events/test/test.rule.ts @@ -737,6 +737,7 @@ export = { }; class SomeTarget implements IRuleTarget { + // eslint-disable-next-line cdk/no-core-construct public constructor(private readonly id?: string, private readonly resource?: cdk.IConstruct) { } diff --git a/packages/@aws-cdk/aws-globalaccelerator/test/integ.globalaccelerator.ts b/packages/@aws-cdk/aws-globalaccelerator/test/integ.globalaccelerator.ts index 805d13e14ecca..bee56b820d7ec 100644 --- a/packages/@aws-cdk/aws-globalaccelerator/test/integ.globalaccelerator.ts +++ b/packages/@aws-cdk/aws-globalaccelerator/test/integ.globalaccelerator.ts @@ -2,11 +2,12 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as ga from '../lib'; import * as testfixture from './util'; class GaStack extends testfixture.TestStack { - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 3, natGateways: 1 }); diff --git a/packages/@aws-cdk/aws-globalaccelerator/test/util.ts b/packages/@aws-cdk/aws-globalaccelerator/test/util.ts index 56e7561565c1a..9cf60a33a2064 100644 --- a/packages/@aws-cdk/aws-globalaccelerator/test/util.ts +++ b/packages/@aws-cdk/aws-globalaccelerator/test/util.ts @@ -1,6 +1,7 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; export function testFixture() { const { stack, app } = testFixtureNoVpc(); diff --git a/packages/@aws-cdk/aws-iam/test/cross-account.test.ts b/packages/@aws-cdk/aws-iam/test/cross-account.test.ts index 619a3bf5b5b34..f3e8a7769d6cf 100644 --- a/packages/@aws-cdk/aws-iam/test/cross-account.test.ts +++ b/packages/@aws-cdk/aws-iam/test/cross-account.test.ts @@ -1,5 +1,6 @@ import '@aws-cdk/assert/jest'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as iam from '../lib'; // Test cross-account grant scenario's for principals @@ -163,7 +164,7 @@ class FakeResource extends cdk.Resource implements iam.IResourceWithPolicy { public readonly arn = 'arn:aws:resource'; private readonly policy = new iam.PolicyDocument(); - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); new cdk.CfnResource(this, 'Default', { diff --git a/packages/@aws-cdk/aws-iam/test/example.attaching.lit.ts b/packages/@aws-cdk/aws-iam/test/example.attaching.lit.ts index ac229c84f9fa1..5b04bac60cd3f 100644 --- a/packages/@aws-cdk/aws-iam/test/example.attaching.lit.ts +++ b/packages/@aws-cdk/aws-iam/test/example.attaching.lit.ts @@ -1,8 +1,9 @@ import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { Group, Policy, User } from '../lib'; export class ExampleConstruct extends cdk.Construct { - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); /// !show diff --git a/packages/@aws-cdk/aws-iam/test/example.external-id.lit.ts b/packages/@aws-cdk/aws-iam/test/example.external-id.lit.ts index 05ef3d44dad35..ddbcb4cd5ea07 100644 --- a/packages/@aws-cdk/aws-iam/test/example.external-id.lit.ts +++ b/packages/@aws-cdk/aws-iam/test/example.external-id.lit.ts @@ -1,8 +1,9 @@ import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as iam from '../lib'; export class ExampleConstruct extends cdk.Construct { - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); /// !show diff --git a/packages/@aws-cdk/aws-iam/test/example.managedpolicy.lit.ts b/packages/@aws-cdk/aws-iam/test/example.managedpolicy.lit.ts index ec2b4bd2d2943..8eb514aae90da 100644 --- a/packages/@aws-cdk/aws-iam/test/example.managedpolicy.lit.ts +++ b/packages/@aws-cdk/aws-iam/test/example.managedpolicy.lit.ts @@ -1,8 +1,9 @@ import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { Group, ManagedPolicy } from '../lib'; export class ExampleConstruct extends cdk.Construct { - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); /// !show diff --git a/packages/@aws-cdk/aws-iam/test/example.role.lit.ts b/packages/@aws-cdk/aws-iam/test/example.role.lit.ts index fab98a8e32961..92ff9d2a96127 100644 --- a/packages/@aws-cdk/aws-iam/test/example.role.lit.ts +++ b/packages/@aws-cdk/aws-iam/test/example.role.lit.ts @@ -1,8 +1,9 @@ import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { PolicyStatement, Role, ServicePrincipal } from '../lib'; export class ExampleConstruct extends cdk.Construct { - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); /// !show diff --git a/packages/@aws-cdk/aws-iam/test/grant.test.ts b/packages/@aws-cdk/aws-iam/test/grant.test.ts index 3a1d7d580fcb0..d9b6131dc967d 100644 --- a/packages/@aws-cdk/aws-iam/test/grant.test.ts +++ b/packages/@aws-cdk/aws-iam/test/grant.test.ts @@ -1,6 +1,7 @@ import { ResourcePart } from '@aws-cdk/assert'; import '@aws-cdk/assert/jest'; -import { CfnResource, Construct, Resource, Stack } from '@aws-cdk/core'; +import { CfnResource, Resource, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as iam from '../lib'; let stack: Stack; diff --git a/packages/@aws-cdk/aws-iam/test/integ.condition-with-ref.ts b/packages/@aws-cdk/aws-iam/test/integ.condition-with-ref.ts index 3a8efb6f1ecb5..69fe09d6cc3a5 100644 --- a/packages/@aws-cdk/aws-iam/test/integ.condition-with-ref.ts +++ b/packages/@aws-cdk/aws-iam/test/integ.condition-with-ref.ts @@ -1,5 +1,6 @@ /// !cdk-integ pragma:ignore-assets -import { App, CfnJson, CfnParameter, Construct, Stack } from '@aws-cdk/core'; +import { App, CfnJson, CfnParameter, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { AccountRootPrincipal, Role } from '../lib'; class MyStack extends Stack { diff --git a/packages/@aws-cdk/aws-kms/test/test.alias.ts b/packages/@aws-cdk/aws-kms/test/test.alias.ts index 057311b6cff66..7d10d326ebf96 100644 --- a/packages/@aws-cdk/aws-kms/test/test.alias.ts +++ b/packages/@aws-cdk/aws-kms/test/test.alias.ts @@ -136,6 +136,7 @@ export = { aliasName: 'alias/myAlias', }); + /* eslint-disable cdk/no-core-construct */ class MyConstruct extends Construct { constructor(scope: Construct, id: string, key: IKey) { super(scope, id); @@ -148,6 +149,7 @@ export = { }); } } + /* eslint-enable cdk/no-core-construct */ new MyConstruct(stack, 'MyConstruct', myAlias); @@ -180,6 +182,7 @@ export = { const myAlias = Alias.fromAliasName(stack, 'MyAlias', 'alias/myAlias'); + /* eslint-disable cdk/no-core-construct */ class MyConstruct extends Construct { constructor(scope: Construct, id: string, key: IKey) { super(scope, id); @@ -192,6 +195,7 @@ export = { }); } } + /* eslint-enable cdk/no-core-construct */ new MyConstruct(stack, 'MyConstruct', myAlias); diff --git a/packages/@aws-cdk/aws-lambda-destinations/test/integ.destinations.ts b/packages/@aws-cdk/aws-lambda-destinations/test/integ.destinations.ts index 90c0c678efd78..d67957f7d28c9 100644 --- a/packages/@aws-cdk/aws-lambda-destinations/test/integ.destinations.ts +++ b/packages/@aws-cdk/aws-lambda-destinations/test/integ.destinations.ts @@ -1,7 +1,8 @@ import * as lambda from '@aws-cdk/aws-lambda'; import * as sns from '@aws-cdk/aws-sns'; import * as sqs from '@aws-cdk/aws-sqs'; -import { App, Construct, Duration, Stack, StackProps } from '@aws-cdk/core'; +import { App, Duration, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as destinations from '../lib'; /* diff --git a/packages/@aws-cdk/aws-lambda-destinations/test/integ.lambda-chain.ts b/packages/@aws-cdk/aws-lambda-destinations/test/integ.lambda-chain.ts index c205ad155bd28..546e238ed86f2 100644 --- a/packages/@aws-cdk/aws-lambda-destinations/test/integ.lambda-chain.ts +++ b/packages/@aws-cdk/aws-lambda-destinations/test/integ.lambda-chain.ts @@ -1,5 +1,6 @@ import * as lambda from '@aws-cdk/aws-lambda'; -import { App, CfnOutput, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as destinations from '../lib'; // Test success case with: diff --git a/packages/@aws-cdk/aws-lambda-event-sources/test/test-function.ts b/packages/@aws-cdk/aws-lambda-event-sources/test/test-function.ts index ab686f17a1185..f5ef254ed6eb2 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/test/test-function.ts +++ b/packages/@aws-cdk/aws-lambda-event-sources/test/test-function.ts @@ -1,8 +1,8 @@ import * as lambda from '@aws-cdk/aws-lambda'; -import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; export class TestFunction extends lambda.Function { - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id, { handler: 'index.handler', code: lambda.Code.fromInline(`exports.handler = ${handler.toString()}`), diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies.ts index 58c9dfa7eb425..2fe38367a1347 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/integ.dependencies.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as lambda from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/integ.function.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/integ.function.ts index 2299dafbc5c9b..1befb89d3af9b 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/integ.function.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/integ.function.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as lambda from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.py38.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.py38.ts index 0e6546d2ecbbb..22bcba46a270f 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.py38.ts +++ b/packages/@aws-cdk/aws-lambda-python/test/integ.function.py38.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, CfnOutput, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as lambda from '../lib'; /* diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.ts index 8da5f2a82e12d..7279c54b56bdc 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.ts +++ b/packages/@aws-cdk/aws-lambda-python/test/integ.function.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, CfnOutput, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as lambda from '../lib'; /* diff --git a/packages/@aws-cdk/aws-lambda-python/test/integ.function.vpc.ts b/packages/@aws-cdk/aws-lambda-python/test/integ.function.vpc.ts index 1584208b2335d..f89fa07dc19c7 100644 --- a/packages/@aws-cdk/aws-lambda-python/test/integ.function.vpc.ts +++ b/packages/@aws-cdk/aws-lambda-python/test/integ.function.vpc.ts @@ -1,7 +1,8 @@ import * as path from 'path'; import { Vpc, SubnetType } from '@aws-cdk/aws-ec2'; import { Runtime } from '@aws-cdk/aws-lambda'; -import { App, CfnOutput, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as lambda from '../lib'; /* diff --git a/packages/@aws-cdk/aws-lambda/test/integ.bundling.ts b/packages/@aws-cdk/aws-lambda/test/integ.bundling.ts index c59d1eb85dcc9..6dfd3be463caf 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.bundling.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.bundling.ts @@ -1,5 +1,6 @@ import * as path from 'path'; -import { App, CfnOutput, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, CfnOutput, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as lambda from '../lib'; /** diff --git a/packages/@aws-cdk/aws-lambda/test/test.lambda.ts b/packages/@aws-cdk/aws-lambda/test/test.lambda.ts index 69309e609517f..3678ba37069e0 100644 --- a/packages/@aws-cdk/aws-lambda/test/test.lambda.ts +++ b/packages/@aws-cdk/aws-lambda/test/test.lambda.ts @@ -5,6 +5,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as logs from '@aws-cdk/aws-logs'; import * as sqs from '@aws-cdk/aws-sqs'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import { Test } from 'nodeunit'; import * as lambda from '../lib'; @@ -1712,7 +1713,7 @@ export = { }, }; -function newTestLambda(scope: cdk.Construct) { +function newTestLambda(scope: constructs.Construct) { return new lambda.Function(scope, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'bar', diff --git a/packages/@aws-cdk/aws-logs/test/test.subscriptionfilter.ts b/packages/@aws-cdk/aws-logs/test/test.subscriptionfilter.ts index d769300d0869b..0aef93813a7b7 100644 --- a/packages/@aws-cdk/aws-logs/test/test.subscriptionfilter.ts +++ b/packages/@aws-cdk/aws-logs/test/test.subscriptionfilter.ts @@ -1,5 +1,6 @@ import { expect, haveResource } from '@aws-cdk/assert'; -import { Construct, Stack } from '@aws-cdk/core'; +import { Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { Test } from 'nodeunit'; import { FilterPattern, ILogGroup, ILogSubscriptionDestination, LogGroup, SubscriptionFilter } from '../lib'; diff --git a/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts b/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts index 0379294a59e9e..ce8246d7955f7 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts @@ -3,7 +3,8 @@ import * as apig from '@aws-cdk/aws-apigateway'; import * as acm from '@aws-cdk/aws-certificatemanager'; import * as lambda from '@aws-cdk/aws-lambda'; import * as route53 from '@aws-cdk/aws-route53'; -import { App, Construct, Stack } from '@aws-cdk/core'; +import { App, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as targets from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-s3-assets/test/integ.assets.bundling.lit.ts b/packages/@aws-cdk/aws-s3-assets/test/integ.assets.bundling.lit.ts index 1ba1ad26deee2..38cfe5c2d1e46 100644 --- a/packages/@aws-cdk/aws-s3-assets/test/integ.assets.bundling.lit.ts +++ b/packages/@aws-cdk/aws-s3-assets/test/integ.assets.bundling.lit.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import * as iam from '@aws-cdk/aws-iam'; -import { App, BundlingDockerImage, Construct, Stack, StackProps } from '@aws-cdk/core'; +import { App, BundlingDockerImage, Stack, StackProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as assets from '../lib'; class TestStack extends Stack { diff --git a/packages/@aws-cdk/aws-s3-deployment/test/bucket-deployment.test.ts b/packages/@aws-cdk/aws-s3-deployment/test/bucket-deployment.test.ts index 3ba33793ab8b3..974ee1c363461 100644 --- a/packages/@aws-cdk/aws-s3-deployment/test/bucket-deployment.test.ts +++ b/packages/@aws-cdk/aws-s3-deployment/test/bucket-deployment.test.ts @@ -1,9 +1,9 @@ import '@aws-cdk/assert/jest'; +import * as path from 'path'; import * as cloudfront from '@aws-cdk/aws-cloudfront'; import * as iam from '@aws-cdk/aws-iam'; import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; -import * as path from 'path'; import * as s3deploy from '../lib'; /* eslint-disable max-len */ diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.start-execution.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.start-execution.ts index 865e42e9033c5..31f0f08f54e89 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.start-execution.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.start-execution.ts @@ -1,5 +1,6 @@ import * as sfn from '@aws-cdk/aws-stepfunctions'; -import { App, CfnOutput, Construct, Stack } from '@aws-cdk/core'; +import { App, CfnOutput, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as tasks from '../lib'; /* diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.ts index f103d41da4a7c..b0582cee76ce4 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.ts @@ -1,5 +1,6 @@ import * as sfn from '@aws-cdk/aws-stepfunctions'; -import { App, CfnOutput, Construct, Stack } from '@aws-cdk/core'; +import { App, CfnOutput, Stack } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import { StepFunctionsStartExecution } from '../../lib/stepfunctions/start-execution'; /* diff --git a/packages/@aws-cdk/aws-stepfunctions/test/states-language.test.ts b/packages/@aws-cdk/aws-stepfunctions/test/states-language.test.ts index 887f71177d118..326bfeaf17ba1 100644 --- a/packages/@aws-cdk/aws-stepfunctions/test/states-language.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions/test/states-language.test.ts @@ -1,5 +1,6 @@ import '@aws-cdk/assert/jest'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as stepfunctions from '../lib'; describe('States Language', () => { @@ -692,7 +693,7 @@ describe('States Language', () => { class ReusableStateMachine extends stepfunctions.StateMachineFragment { public readonly startState: stepfunctions.State; public readonly endStates: stepfunctions.INextable[]; - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); const choice = new stepfunctions.Choice(this, 'Choice') @@ -709,7 +710,7 @@ class SimpleChain extends stepfunctions.StateMachineFragment { public readonly endStates: stepfunctions.INextable[]; private readonly task2: stepfunctions.Task; - constructor(scope: cdk.Construct, id: string) { + constructor(scope: constructs.Construct, id: string) { super(scope, id); const task1 = new stepfunctions.Task(this, 'Task1', { task: new FakeTask() }); diff --git a/packages/@aws-cdk/aws-stepfunctions/test/task-base.test.ts b/packages/@aws-cdk/aws-stepfunctions/test/task-base.test.ts index eb14a414e20fc..c88540bb8f1e3 100644 --- a/packages/@aws-cdk/aws-stepfunctions/test/task-base.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions/test/task-base.test.ts @@ -2,6 +2,7 @@ import '@aws-cdk/assert/jest'; import { Metric } from '@aws-cdk/aws-cloudwatch'; import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as sfn from '../lib'; describe('Task base', () => { @@ -387,7 +388,7 @@ class FakeTask extends sfn.TaskStateBase { protected readonly taskMetrics?: sfn.TaskMetricsConfig; protected readonly taskPolicies?: iam.PolicyStatement[]; - constructor(scope: cdk.Construct, id: string, props: FakeTaskProps = {}) { + constructor(scope: constructs.Construct, id: string, props: FakeTaskProps = {}) { super(scope, id, props); this.taskMetrics = props.metrics; } diff --git a/packages/@aws-cdk/cloudformation-include/lib/cfn-include.ts b/packages/@aws-cdk/cloudformation-include/lib/cfn-include.ts index becb5666c3653..7c3c36de9196a 100644 --- a/packages/@aws-cdk/cloudformation-include/lib/cfn-include.ts +++ b/packages/@aws-cdk/cloudformation-include/lib/cfn-include.ts @@ -1,8 +1,13 @@ import * as core from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cfn_parse from '@aws-cdk/core/lib/cfn-parse'; import * as cfn_type_to_l1_mapping from './cfn-type-to-l1-mapping'; import * as futils from './file-utils'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Construction properties of {@link CfnInclude}. */ @@ -79,23 +84,23 @@ export interface IncludedNestedStack { */ export class CfnInclude extends core.CfnElement { private readonly conditions: { [conditionName: string]: core.CfnCondition } = {}; - private readonly conditionsScope: core.Construct; + private readonly conditionsScope: Construct; private readonly resources: { [logicalId: string]: core.CfnResource } = {}; private readonly parameters: { [logicalId: string]: core.CfnParameter } = {}; private readonly parametersToReplace: { [parameterName: string]: any }; - private readonly mappingsScope: core.Construct; + private readonly mappingsScope: Construct; private readonly mappings: { [mappingName: string]: core.CfnMapping } = {}; private readonly rules: { [ruleName: string]: core.CfnRule } = {}; - private readonly rulesScope: core.Construct; + private readonly rulesScope: Construct; private readonly hooks: { [hookName: string]: core.CfnHook } = {}; - private readonly hooksScope: core.Construct; + private readonly hooksScope: Construct; private readonly outputs: { [logicalId: string]: core.CfnOutput } = {}; private readonly nestedStacks: { [logicalId: string]: IncludedNestedStack } = {}; private readonly nestedStacksToInclude: { [name: string]: CfnIncludeProps }; private readonly template: any; private readonly preserveLogicalIds: boolean; - constructor(scope: core.Construct, id: string, props: CfnIncludeProps) { + constructor(scope: Construct, id: string, props: CfnIncludeProps) { super(scope, id); this.parametersToReplace = props.parameters || {}; @@ -113,7 +118,7 @@ export class CfnInclude extends core.CfnElement { } // instantiate the Mappings - this.mappingsScope = new core.Construct(this, '$Mappings'); + this.mappingsScope = new CoreConstruct(this, '$Mappings'); for (const mappingName of Object.keys(this.template.Mappings || {})) { this.createMapping(mappingName); } @@ -124,13 +129,13 @@ export class CfnInclude extends core.CfnElement { } // instantiate the conditions - this.conditionsScope = new core.Construct(this, '$Conditions'); + this.conditionsScope = new CoreConstruct(this, '$Conditions'); for (const conditionName of Object.keys(this.template.Conditions || {})) { this.getOrCreateCondition(conditionName); } // instantiate the rules - this.rulesScope = new core.Construct(this, '$Rules'); + this.rulesScope = new CoreConstruct(this, '$Rules'); for (const ruleName of Object.keys(this.template.Rules || {})) { this.createRule(ruleName); } @@ -148,12 +153,12 @@ export class CfnInclude extends core.CfnElement { } // instantiate the Hooks - this.hooksScope = new core.Construct(this, '$Hooks'); + this.hooksScope = new CoreConstruct(this, '$Hooks'); for (const hookName of Object.keys(this.template.Hooks || {})) { this.createHook(hookName); } - const outputScope = new core.Construct(this, '$Ouputs'); + const outputScope = new CoreConstruct(this, '$Ouputs'); for (const logicalId of Object.keys(this.template.Outputs || {})) { this.createOutput(logicalId, outputScope); } @@ -506,7 +511,7 @@ export class CfnInclude extends core.CfnElement { this.overrideLogicalIdIfNeeded(hook, hookName); } - private createOutput(logicalId: string, scope: core.Construct): void { + private createOutput(logicalId: string, scope: Construct): void { const self = this; const outputAttributes = new cfn_parse.CfnParser({ finder: { diff --git a/packages/@aws-cdk/cloudformation-include/package.json b/packages/@aws-cdk/cloudformation-include/package.json index ca5540a2fd70d..336f213dcbe3e 100644 --- a/packages/@aws-cdk/cloudformation-include/package.json +++ b/packages/@aws-cdk/cloudformation-include/package.json @@ -54,7 +54,10 @@ "pre": [ "node ./build.js" ], - "jest": true + "jest": true, + "env": { + "AWSLINT_BASE_CONSTRUCT": "true" + } }, "author": { "name": "Amazon Web Services", @@ -187,7 +190,8 @@ "@aws-cdk/aws-wafv2": "0.0.0", "@aws-cdk/aws-workspaces": "0.0.0", "@aws-cdk/core": "0.0.0", - "@aws-cdk/yaml-cfn": "0.0.0" + "@aws-cdk/yaml-cfn": "0.0.0", + "constructs": "^3.0.4" }, "peerDependencies": { "@aws-cdk/alexa-ask": "0.0.0", diff --git a/packages/@aws-cdk/cloudformation-include/test/invalid-templates.test.ts b/packages/@aws-cdk/cloudformation-include/test/invalid-templates.test.ts index 5c901dc3f1bf2..a81f01f03fabb 100644 --- a/packages/@aws-cdk/cloudformation-include/test/invalid-templates.test.ts +++ b/packages/@aws-cdk/cloudformation-include/test/invalid-templates.test.ts @@ -2,6 +2,7 @@ import * as path from 'path'; import { SynthUtils } from '@aws-cdk/assert'; import '@aws-cdk/assert/jest'; import * as core from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as inc from '../lib'; describe('CDK Include', () => { @@ -140,7 +141,7 @@ describe('CDK Include', () => { }); }); -function includeTestTemplate(scope: core.Construct, testTemplate: string): inc.CfnInclude { +function includeTestTemplate(scope: constructs.Construct, testTemplate: string): inc.CfnInclude { return new inc.CfnInclude(scope, 'MyScope', { templateFile: _testTemplateFilePath(testTemplate), }); diff --git a/packages/@aws-cdk/cloudformation-include/test/serverless-transform.test.ts b/packages/@aws-cdk/cloudformation-include/test/serverless-transform.test.ts index 3d4d0f977893d..54f5b28b7fed3 100644 --- a/packages/@aws-cdk/cloudformation-include/test/serverless-transform.test.ts +++ b/packages/@aws-cdk/cloudformation-include/test/serverless-transform.test.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import '@aws-cdk/assert/jest'; import * as core from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as inc from '../lib'; import * as futils from '../lib/file-utils'; @@ -55,7 +56,7 @@ describe('CDK Include for templates with SAM transform', () => { }); }); -function includeTestTemplate(scope: core.Construct, testTemplate: string): inc.CfnInclude { +function includeTestTemplate(scope: constructs.Construct, testTemplate: string): inc.CfnInclude { return new inc.CfnInclude(scope, 'MyScope', { templateFile: _testTemplateFilePath(testTemplate), }); diff --git a/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts b/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts index 3072ca6844214..fce331ca452eb 100644 --- a/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts +++ b/packages/@aws-cdk/cloudformation-include/test/valid-templates.test.ts @@ -5,6 +5,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as s3 from '@aws-cdk/aws-s3'; import * as ssm from '@aws-cdk/aws-ssm'; import * as core from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as inc from '../lib'; import * as futils from '../lib/file-utils'; @@ -1000,7 +1001,7 @@ interface IncludeTestTemplateProps { readonly parameters?: { [parameterName: string]: any } } -function includeTestTemplate(scope: core.Construct, testTemplate: string, props: IncludeTestTemplateProps = {}): inc.CfnInclude { +function includeTestTemplate(scope: constructs.Construct, testTemplate: string, props: IncludeTestTemplateProps = {}): inc.CfnInclude { return new inc.CfnInclude(scope, 'MyScope', { templateFile: _testTemplateFilePath(testTemplate), parameters: props.parameters, diff --git a/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts b/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts index 664b558841832..5faf8bd1a5e1c 100644 --- a/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts +++ b/packages/@aws-cdk/cloudformation-include/test/yaml-templates.test.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import '@aws-cdk/assert/jest'; import * as core from '@aws-cdk/core'; +import * as constructs from 'constructs'; import * as inc from '../lib'; import * as futils from '../lib/file-utils'; @@ -392,7 +393,7 @@ describe('CDK Include', () => { }); }); -function includeTestTemplate(scope: core.Construct, testTemplate: string): inc.CfnInclude { +function includeTestTemplate(scope: constructs.Construct, testTemplate: string): inc.CfnInclude { return new inc.CfnInclude(scope, 'MyScope', { templateFile: _testTemplateFilePath(testTemplate), }); diff --git a/packages/@aws-cdk/custom-resources/test/provider-framework/integ.provider.ts b/packages/@aws-cdk/custom-resources/test/provider-framework/integ.provider.ts index 01ccd37e89d89..64ec2bbb33987 100644 --- a/packages/@aws-cdk/custom-resources/test/provider-framework/integ.provider.ts +++ b/packages/@aws-cdk/custom-resources/test/provider-framework/integ.provider.ts @@ -1,6 +1,7 @@ /// !cdk-integ * pragma:ignore-assets import * as s3 from '@aws-cdk/aws-s3'; -import { App, CfnOutput, Construct, Stack } from '@aws-cdk/core'; +import { App, CfnOutput, Stack } from '@aws-cdk/core'; +import { Construct, Node } from 'constructs'; import { S3Assert } from './integration-test-fixtures/s3-assert'; import { S3File } from './integration-test-fixtures/s3-file'; @@ -30,7 +31,7 @@ class TestStack extends Stack { }); // delay file2 updates so we can test async assertions - file2.node.addDependency(file1); + Node.of(file2).addDependency(file1); new CfnOutput(this, 'file1-url', { value: file1.url }); new CfnOutput(this, 'file2-url', { value: file2.url }); diff --git a/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-assert.ts b/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-assert.ts index 6c98c6cfd4fc6..369369945632f 100644 --- a/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-assert.ts +++ b/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-assert.ts @@ -2,9 +2,14 @@ import * as path from 'path'; import * as iam from '@aws-cdk/aws-iam'; import * as lambda from '@aws-cdk/aws-lambda'; import * as s3 from '@aws-cdk/aws-s3'; -import { Construct, CustomResource, Duration, Stack } from '@aws-cdk/core'; +import { CustomResource, Duration, Stack } from '@aws-cdk/core'; +import { Construct, Node } from 'constructs'; import * as cr from '../../../lib'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from '@aws-cdk/core'; + export interface S3AssertProps { /** * The s3 bucket to query. @@ -29,7 +34,7 @@ export interface S3AssertProps { * * Code is written in Python because why not. */ -export class S3Assert extends Construct { +export class S3Assert extends CoreConstruct { constructor(scope: Construct, id: string, props: S3AssertProps) { super(scope, id); @@ -46,7 +51,7 @@ export class S3Assert extends Construct { } } -class S3AssertProvider extends Construct { +class S3AssertProvider extends CoreConstruct { /** * Returns the singleton provider. @@ -54,7 +59,7 @@ class S3AssertProvider extends Construct { public static getOrCreate(scope: Construct) { const providerId = 'com.amazonaws.cdk.custom-resources.s3assert-provider'; const stack = Stack.of(scope); - const group = stack.node.tryFindChild(providerId) as S3AssertProvider || new S3AssertProvider(stack, providerId); + const group = Node.of(stack).tryFindChild(providerId) as S3AssertProvider || new S3AssertProvider(stack, providerId); return group.provider.serviceToken; } diff --git a/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-file.ts b/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-file.ts index 3bb9af4486fb1..d70759be12b79 100644 --- a/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-file.ts +++ b/packages/@aws-cdk/custom-resources/test/provider-framework/integration-test-fixtures/s3-file.ts @@ -2,10 +2,15 @@ import * as path from 'path'; import * as iam from '@aws-cdk/aws-iam'; import * as lambda from '@aws-cdk/aws-lambda'; import * as s3 from '@aws-cdk/aws-s3'; -import { Construct, CustomResource, Stack } from '@aws-cdk/core'; +import { CustomResource, Stack } from '@aws-cdk/core'; +import { Construct, Node } from 'constructs'; import * as cr from '../../../lib'; import * as api from './s3-file-handler/api'; +// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch. +// eslint-disable-next-line +import { Construct as CoreConstruct } from '@aws-cdk/core'; + interface S3FileProps { /** * The bucket in which the file will be created. @@ -32,7 +37,7 @@ interface S3FileProps { readonly public?: boolean; } -export class S3File extends Construct { +export class S3File extends CoreConstruct { public readonly objectKey: string; public readonly url: string; public readonly etag: string; @@ -57,7 +62,7 @@ export class S3File extends Construct { } } -class S3FileProvider extends Construct { +class S3FileProvider extends CoreConstruct { /** * Returns the singleton provider. @@ -65,7 +70,7 @@ class S3FileProvider extends Construct { public static getOrCreate(scope: Construct) { const stack = Stack.of(scope); const id = 'com.amazonaws.cdk.custom-resources.s3file-provider'; - const x = stack.node.tryFindChild(id) as S3FileProvider || new S3FileProvider(stack, id); + const x = Node.of(stack).tryFindChild(id) as S3FileProvider || new S3FileProvider(stack, id); return x.provider.serviceToken; } diff --git a/packages/@aws-cdk/pipelines/test/cross-environment-infra.test.ts b/packages/@aws-cdk/pipelines/test/cross-environment-infra.test.ts index dac6ebb595f0b..f9b100802036c 100644 --- a/packages/@aws-cdk/pipelines/test/cross-environment-infra.test.ts +++ b/packages/@aws-cdk/pipelines/test/cross-environment-infra.test.ts @@ -1,6 +1,7 @@ import { arrayWith, objectLike, stringLike } from '@aws-cdk/assert'; import '@aws-cdk/assert/jest'; -import { Construct, Stack, Stage, StageProps } from '@aws-cdk/core'; +import { Stack, Stage, StageProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; import { BucketStack, PIPELINE_ENV, TestApp, TestGitHubNpmPipeline } from './testutil'; diff --git a/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.ts b/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.ts index 07a59ce4370eb..ae9f5046137d4 100644 --- a/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.ts +++ b/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.ts @@ -3,7 +3,8 @@ import * as path from 'path'; import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as codepipeline_actions from '@aws-cdk/aws-codepipeline-actions'; import * as s3_assets from '@aws-cdk/aws-s3-assets'; -import { App, CfnResource, Construct, SecretValue, Stack, StackProps, Stage, StageProps } from '@aws-cdk/core'; +import { App, CfnResource, SecretValue, Stack, StackProps, Stage, StageProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; class MyStage extends Stage { diff --git a/packages/@aws-cdk/pipelines/test/integ.pipeline.ts b/packages/@aws-cdk/pipelines/test/integ.pipeline.ts index e901758cde4e9..b79dd24841472 100644 --- a/packages/@aws-cdk/pipelines/test/integ.pipeline.ts +++ b/packages/@aws-cdk/pipelines/test/integ.pipeline.ts @@ -1,7 +1,8 @@ /// !cdk-integ PipelineStack import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as codepipeline_actions from '@aws-cdk/aws-codepipeline-actions'; -import { App, CfnResource, Construct, SecretValue, Stack, StackProps, Stage, StageProps } from '@aws-cdk/core'; +import { App, CfnResource, SecretValue, Stack, StackProps, Stage, StageProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; class MyStage extends Stage { diff --git a/packages/@aws-cdk/pipelines/test/pipeline-assets.test.ts b/packages/@aws-cdk/pipelines/test/pipeline-assets.test.ts index 13ae9fcceda87..3605c830529a5 100644 --- a/packages/@aws-cdk/pipelines/test/pipeline-assets.test.ts +++ b/packages/@aws-cdk/pipelines/test/pipeline-assets.test.ts @@ -3,7 +3,8 @@ import { arrayWith, deepObjectLike, encodedJson, notMatching, objectLike, string import '@aws-cdk/assert/jest'; import * as ecr_assets from '@aws-cdk/aws-ecr-assets'; import * as s3_assets from '@aws-cdk/aws-s3-assets'; -import { Construct, Stack, Stage, StageProps } from '@aws-cdk/core'; +import { Stack, Stage, StageProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; import { BucketStack, PIPELINE_ENV, TestApp, TestGitHubNpmPipeline } from './testutil'; diff --git a/packages/@aws-cdk/pipelines/test/pipeline.test.ts b/packages/@aws-cdk/pipelines/test/pipeline.test.ts index f47149e5f8395..8fa56d50f3ea0 100644 --- a/packages/@aws-cdk/pipelines/test/pipeline.test.ts +++ b/packages/@aws-cdk/pipelines/test/pipeline.test.ts @@ -4,7 +4,8 @@ import { anything, arrayWith, Capture, deepObjectLike, encodedJson, objectLike, import '@aws-cdk/assert/jest'; import * as cp from '@aws-cdk/aws-codepipeline'; import * as cpa from '@aws-cdk/aws-codepipeline-actions'; -import { Construct, Stack, Stage, StageProps, SecretValue, Tags } from '@aws-cdk/core'; +import { Stack, Stage, StageProps, SecretValue, Tags } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; import { BucketStack, PIPELINE_ENV, stackTemplate, TestApp, TestGitHubNpmPipeline } from './testutil'; diff --git a/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts b/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts index 45d0cb76bf6b8..ddd38e7a3a9c2 100644 --- a/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts +++ b/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts @@ -1,6 +1,7 @@ import { arrayWith, objectLike } from '@aws-cdk/assert'; import '@aws-cdk/assert/jest'; -import { App, Construct, Stack, Stage, StageProps } from '@aws-cdk/core'; +import { App, Stack, Stage, StageProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; import { sortedByRunOrder } from './testmatchers'; import { BucketStack, PIPELINE_ENV, TestApp, TestGitHubNpmPipeline } from './testutil'; diff --git a/packages/@aws-cdk/pipelines/test/testutil.ts b/packages/@aws-cdk/pipelines/test/testutil.ts index d0573130e3ede..40135256b39d7 100644 --- a/packages/@aws-cdk/pipelines/test/testutil.ts +++ b/packages/@aws-cdk/pipelines/test/testutil.ts @@ -4,7 +4,8 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as codepipeline_actions from '@aws-cdk/aws-codepipeline-actions'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as s3 from '@aws-cdk/aws-s3'; -import { App, AppProps, Construct, Environment, SecretValue, Stack, StackProps, Stage } from '@aws-cdk/core'; +import { App, AppProps, Environment, SecretValue, Stack, StackProps, Stage } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; import { assemblyBuilderOf } from '../lib/private/construct-internals'; diff --git a/packages/@aws-cdk/pipelines/test/validation.test.ts b/packages/@aws-cdk/pipelines/test/validation.test.ts index 6dc5247b22452..2f22bb055ad4a 100644 --- a/packages/@aws-cdk/pipelines/test/validation.test.ts +++ b/packages/@aws-cdk/pipelines/test/validation.test.ts @@ -4,7 +4,8 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as s3 from '@aws-cdk/aws-s3'; -import { CfnOutput, Construct, Stack, Stage, StageProps } from '@aws-cdk/core'; +import { CfnOutput, Stack, Stage, StageProps } from '@aws-cdk/core'; +import { Construct } from 'constructs'; import * as cdkp from '../lib'; import { } from './testmatchers'; import { BucketStack, PIPELINE_ENV, TestApp, TestGitHubNpmPipeline } from './testutil'; diff --git a/packages/decdk/test/fixture/tsconfig.json b/packages/decdk/test/fixture/tsconfig.json index 07afb1f64860c..44dbf4775b1a7 100644 --- a/packages/decdk/test/fixture/tsconfig.json +++ b/packages/decdk/test/fixture/tsconfig.json @@ -10,6 +10,7 @@ "es2018" ], "module": "CommonJS", + "newLine": "lf", "noEmitOnError": true, "noFallthroughCasesInSwitch": true, "noImplicitAny": true, diff --git a/tools/cdk-build-tools/config/eslintrc.js b/tools/cdk-build-tools/config/eslintrc.js index 4b6c03c16f815..51be4eac2e4c2 100644 --- a/tools/cdk-build-tools/config/eslintrc.js +++ b/tools/cdk-build-tools/config/eslintrc.js @@ -15,6 +15,7 @@ module.exports = { plugins: [ '@typescript-eslint', 'import', + 'cdk', ], parser: '@typescript-eslint/parser', parserOptions: { @@ -38,6 +39,7 @@ module.exports = { }, ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'], rules: { + 'cdk/no-core-construct': [ 'error' ], // Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');` '@typescript-eslint/no-require-imports': ['error'], '@typescript-eslint/indent': ['error', 2], diff --git a/tools/cdk-build-tools/package.json b/tools/cdk-build-tools/package.json index d1dd06e9b013f..dee0bc8c47031 100644 --- a/tools/cdk-build-tools/package.json +++ b/tools/cdk-build-tools/package.json @@ -41,6 +41,7 @@ "dependencies": { "@typescript-eslint/eslint-plugin": "^4.3.0", "@typescript-eslint/parser": "^4.3.0", + "eslint-plugin-cdk": "0.0.0", "awslint": "0.0.0", "colors": "^1.4.0", "eslint": "^7.10.0", diff --git a/tools/eslint-plugin-cdk/.gitignore b/tools/eslint-plugin-cdk/.gitignore new file mode 100644 index 0000000000000..f3984b8c7bb62 --- /dev/null +++ b/tools/eslint-plugin-cdk/.gitignore @@ -0,0 +1,14 @@ +*.js +*.js.map +*.d.ts +dist + +.LAST_BUILD +*.snk +!jest.config.js + +.nyc_output +coverage +nyc.config.js +!.eslintrc.js +!eslintrc.js \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/LICENSE b/tools/eslint-plugin-cdk/LICENSE new file mode 100644 index 0000000000000..b71ec1688783a --- /dev/null +++ b/tools/eslint-plugin-cdk/LICENSE @@ -0,0 +1,201 @@ + 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-2020 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/tools/eslint-plugin-cdk/NOTICE b/tools/eslint-plugin-cdk/NOTICE new file mode 100644 index 0000000000000..bfccac9a7f69c --- /dev/null +++ b/tools/eslint-plugin-cdk/NOTICE @@ -0,0 +1,2 @@ +AWS Cloud Development Kit (AWS CDK) +Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/tools/eslint-plugin-cdk/README.md b/tools/eslint-plugin-cdk/README.md new file mode 100644 index 0000000000000..667a417f1ef36 --- /dev/null +++ b/tools/eslint-plugin-cdk/README.md @@ -0,0 +1,9 @@ +# eslint-plugin-cdk + +Eslint plugin for the CDK repository. Contains rules that need to be applied specific to the CDK repository. + +## Rules + +* `no-core-construct`: Forbid the use of `Construct` and `IConstruct` from the "@aws-cdk/core" module. + Instead use `Construct` and `IConstruct` from the "constructs" module. + Rule only applies to typescript files under the `test/` folder. \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/lib/index.ts b/tools/eslint-plugin-cdk/lib/index.ts new file mode 100644 index 0000000000000..aae510df35d54 --- /dev/null +++ b/tools/eslint-plugin-cdk/lib/index.ts @@ -0,0 +1,3 @@ +export const rules = { + 'no-core-construct': require('./rules/no-core-construct'), +}; diff --git a/tools/eslint-plugin-cdk/lib/private/import-cache.ts b/tools/eslint-plugin-cdk/lib/private/import-cache.ts new file mode 100644 index 0000000000000..7d78b2a421e93 --- /dev/null +++ b/tools/eslint-plugin-cdk/lib/private/import-cache.ts @@ -0,0 +1,38 @@ +import * as crypto from 'crypto'; + +export interface ImportCacheKey { + readonly fileName: string; + readonly typeName: string; +} + +// `node` is a type from @typescript-eslint/typescript-estree, but using 'any' for now +// since it's incompatible with eslint.Rule namespace. Waiting for better compatibility in +// https://github.com/typescript-eslint/typescript-eslint/tree/1765a178e456b152bd48192eb5db7e8541e2adf2/packages/experimental-utils#note +export type Node = any; + +export interface ImportCacheRecord extends ImportCacheKey { + readonly importNode: Node; + readonly localName: string +} + +export class ImportCache { + private records: { [key: string]: ImportCacheRecord } = {}; + + public record(record: ImportCacheRecord): void { + const key: ImportCacheKey = { + fileName: record.fileName, + typeName: record.typeName, + }; + this.records[hashed(key)] = record; + } + + public find(key: ImportCacheKey): ImportCacheRecord | undefined { + return this.records[hashed(key)]; + } +} + +function hashed(key: {}): string { + const hash = crypto.createHash('md5'); + hash.update(JSON.stringify(key)); + return hash.digest('hex'); +} \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/lib/rules/no-core-construct.ts b/tools/eslint-plugin-cdk/lib/rules/no-core-construct.ts new file mode 100644 index 0000000000000..d74988b4f1f07 --- /dev/null +++ b/tools/eslint-plugin-cdk/lib/rules/no-core-construct.ts @@ -0,0 +1,144 @@ +import { Rule } from 'eslint'; +import { ImportCache, Node } from '../private/import-cache'; + +let importCache: ImportCache; +let importsFixed: boolean; + +const BANNED_TYPES = [ 'IConstruct', 'Construct' ]; + +export function create(context: Rule.RuleContext): Rule.NodeListener { + return { + + // `node` is a type from @typescript-eslint/typescript-estree, but using 'any' for now + // since it's incompatible with eslint.Rule namespace. Waiting for better compatibility in + // https://github.com/typescript-eslint/typescript-eslint/tree/1765a178e456b152bd48192eb5db7e8541e2adf2/packages/experimental-utils#note + // Meanwhile, use a debugger to explore the AST node. + + Program(_node: any) { + if (!isTestFile(context.getFilename())) { + return; + } + importCache = new ImportCache(); + importsFixed = false; + }, + + ImportDeclaration(node: any) { + if (!isTestFile(context.getFilename())) { + return; + } + if (node.source.value === '@aws-cdk/core') { + node.specifiers.forEach((s: any) => { + if (s.type === 'ImportSpecifier' && BANNED_TYPES.includes(s.imported.name)) { + // named import + importCache.record({ + fileName: context.getFilename(), + typeName: s.imported.name, + importNode: node, + localName: s.local.name + }); + } else if (s.type === 'ImportNamespaceSpecifier') { + // barrel import + BANNED_TYPES.forEach(typeName => { + importCache.record({ + fileName: context.getFilename(), + typeName, + importNode: node, + localName: `${s.local.name}.${typeName}` + }); + }); + } + }); + } + }, + + Identifier(node: any) { + if (!isTestFile(context.getFilename())) { + return; + } + const typeAnnotation = node.typeAnnotation?.typeAnnotation + if (!typeAnnotation) { + return; + } + const type = typeAnnotation.typeName; + if (!type) { return; } + if (type.type === 'TSQualifiedName') { + // barrel import + const qualifier = type.left.name; + const typename = type.right.name; + const importNode = findImportNode(`${qualifier}.${typename}`); + if (!importNode) { + return; + } + context.report({ + node, + message: 'avoid Construct and IConstruct from "@aws-cdk/core"', + fix: (fixer: Rule.RuleFixer) => { + const fixes: Rule.Fix[] = []; + if (!importsFixed) { + fixes.push(fixer.insertTextAfter(importNode, "\nimport * as constructs from 'constructs';")); + importsFixed = true; + } + fixes.push(fixer.replaceTextRange(typeAnnotation.range, `constructs.${typename}`)); + return fixes; + } + }); + } else if (type.type === 'Identifier') { + // named imports + const importNode = findImportNode(type.name); + if (!importNode) { + return; + } + context.report({ + node, + message: 'avoid Construct and IConstruct from "@aws-cdk/core"', + fix: (fixer: Rule.RuleFixer) => { + const fixes: Rule.Fix[] = []; + if (!importsFixed) { + const typesToImport = BANNED_TYPES.map(typeName => { + const val = importCache.find({ fileName: context.getFilename(), typeName }); + if (!val) { return undefined; } + if (typeName === val.localName) { return typeName; } + return `${typeName} as ${val.localName}`; + }).filter(x => x !== undefined); + fixes.push(fixer.insertTextAfter(importNode, `\nimport { ${typesToImport.join(', ')} } from 'constructs';`)); + + const specifiers = importNode.specifiers; + if (specifiers.length === typesToImport.length) { + fixes.push(fixer.removeRange(importNode.range)); + } else { + for (let i = 0; i < specifiers.length; i++) { + const s = specifiers[i]; + if (typesToImport.includes(s.imported.name)) { + if (i === specifiers.length - 1) { + fixes.push(fixer.removeRange([s.range[0] - 2, s.range[1]])); // include the leading comma + } else { + fixes.push(fixer.removeRange([s.range[0], s.range[1] + 2])); // include the trailing comma + } + } + } + } + importsFixed = true; + } + return fixes; + } + }); + } else { + return; + } + + function findImportNode(locaName: string): Node | undefined { + return BANNED_TYPES.map(typeName => { + const val = importCache.find({ fileName: context.getFilename(), typeName }); + if (val && val.localName === locaName) { + return val.importNode; + } + return undefined; + }).find(x => x !== undefined); + } + }, + } +} + +function isTestFile(filename: string) { + return new RegExp(/\/test\//).test(filename); +} \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/package.json b/tools/eslint-plugin-cdk/package.json new file mode 100644 index 0000000000000..4615b43cd6e63 --- /dev/null +++ b/tools/eslint-plugin-cdk/package.json @@ -0,0 +1,36 @@ +{ + "name": "eslint-plugin-cdk", + "private": true, + "version": "0.0.0", + "description": "ESLint plugin for private use within the AWS CDK repo", + "main": "lib/index.js", + "scripts": { + "build": "tsc --build", + "watch": "tsc -w", + "test": "jest", + "build+test+package": "npm run build+test", + "build+test": "npm run build && npm test" + }, + "devDependencies": { + "@types/eslint": "^7.2.3", + "@types/fs-extra": "^8.1.1", + "@types/jest": "^26.0.14", + "@types/node": "^10.17.35", + "eslint-plugin-rulesdir": "^0.1.0", + "jest": "^26.4.2", + "typescript": "~3.9.7" + }, + "dependencies": { + "@typescript-eslint/parser": "^4.3.0", + "eslint": "^7.10.0", + "fs-extra": "^9.0.1" + }, + "jest": { + "testMatch": [ + "**/*.test.js" + ] + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/tools/eslint-plugin-cdk/test/rules/eslintrc.js b/tools/eslint-plugin-cdk/test/rules/eslintrc.js new file mode 100644 index 0000000000000..c68b2066acce3 --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/eslintrc.js @@ -0,0 +1,12 @@ +const path = require('path'); +const rulesDirPlugin = require('eslint-plugin-rulesdir'); +rulesDirPlugin.RULES_DIR = path.join(__dirname, '../../lib/rules'); + +module.exports = { + parser: '@typescript-eslint/parser', + plugins: ['rulesdir'], + rules: { + quotes: [ 'error', 'single', { avoidEscape: true }], + 'rulesdir/no-core-construct': [ 'error' ], + } +} diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.expected.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.expected.ts new file mode 100644 index 0000000000000..372f4d582d94c --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.expected.ts @@ -0,0 +1,4 @@ + +import { Construct as CoreConstruct } from 'constructs'; + +const x: CoreConstruct; \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.ts new file mode 100644 index 0000000000000..110b268e5e71e --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/aliased-import.ts @@ -0,0 +1,3 @@ +import { Construct as CoreConstruct } from '@aws-cdk/core'; + +const x: CoreConstruct; \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.expected.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.expected.ts new file mode 100644 index 0000000000000..5512432ebde45 --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.expected.ts @@ -0,0 +1,10 @@ +import * as cdk from '@aws-cdk/core' +import * as constructs from 'constructs'; +import * as somethingElse from 'somewhereElse'; + +const x: constructs.Construct; +const y: somethingElse.Things; +function fn1(z: constructs.Construct) {} + +const p: constructs.IConstruct; +function fn2(p: constructs.IConstruct) {} \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.ts new file mode 100644 index 0000000000000..1dacae5a5ed3d --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/barrel-import.ts @@ -0,0 +1,9 @@ +import * as cdk from '@aws-cdk/core' +import * as somethingElse from 'somewhereElse'; + +const x: cdk.Construct; +const y: somethingElse.Things; +function fn1(z: cdk.Construct) {} + +const p: cdk.IConstruct; +function fn2(p: cdk.IConstruct) {} \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.expected.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.expected.ts new file mode 100644 index 0000000000000..b6a0f17b4cd54 --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.expected.ts @@ -0,0 +1,10 @@ +import { AnImport } from '@aws-cdk/core'; +import { IConstruct, Construct } from 'constructs'; + +const x: Construct; +const y: Construct; + +const p: IConstruct; +function fn2(q: IConstruct); + +const a: AnImport; \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.ts new file mode 100644 index 0000000000000..e1754569c45de --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-not-tail.ts @@ -0,0 +1,9 @@ +import { IConstruct, Construct, AnImport } from '@aws-cdk/core'; + +const x: Construct; +const y: Construct; + +const p: IConstruct; +function fn2(q: IConstruct); + +const a: AnImport; \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.expected.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.expected.ts new file mode 100644 index 0000000000000..364cede2b9871 --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.expected.ts @@ -0,0 +1,5 @@ +import { AnImport } from '@aws-cdk/core'; +import { Construct } from 'constructs'; + +const x: Construct; +const y: Construct \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.ts new file mode 100644 index 0000000000000..31ea93947685b --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import-tail.ts @@ -0,0 +1,4 @@ +import { AnImport, Construct } from '@aws-cdk/core'; + +const x: Construct; +const y: Construct \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.expected.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.expected.ts new file mode 100644 index 0000000000000..e30eedc9d7a68 --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.expected.ts @@ -0,0 +1,8 @@ + +import { IConstruct, Construct } from 'constructs'; + +const x: Construct; +function fn1(y: Construct) {} + +const p: IConstruct; +function fn2(q: IConstruct); \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.ts b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.ts new file mode 100644 index 0000000000000..4e2df727269c4 --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/fixtures/no-core-construct/named-import.ts @@ -0,0 +1,7 @@ +import { IConstruct, Construct } from '@aws-cdk/core'; + +const x: Construct; +function fn1(y: Construct) {} + +const p: IConstruct; +function fn2(q: IConstruct); \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/test/rules/no-core-construct.test.ts b/tools/eslint-plugin-cdk/test/rules/no-core-construct.test.ts new file mode 100644 index 0000000000000..c0d1d4b3ec35b --- /dev/null +++ b/tools/eslint-plugin-cdk/test/rules/no-core-construct.test.ts @@ -0,0 +1,44 @@ +import { ESLint } from 'eslint'; +import * as fs from 'fs-extra'; +import * as path from 'path'; +import * as os from 'os'; + +const linter = new ESLint({ + overrideConfigFile: path.join(__dirname, 'eslintrc.js'), + rulePaths: [ + path.join(__dirname, '../../lib/rules'), + ], + fix: true, +}); + +const outputDir = fs.mkdtempSync(os.tmpdir()) +const fixturesDir = path.join(__dirname, 'fixtures', 'no-core-construct'); + +describe('no-core-construct', () => { + const fixtureFiles = fs.readdirSync(fixturesDir).filter(f => f.endsWith('.ts') && !f.endsWith('.expected.ts')); + fixtureFiles.forEach(f => { + test(f, async (done) => { + const actualFile = await lintAndFix(path.join(fixturesDir, f)); + const expectedFile = path.join(fixturesDir, `${path.basename(f, '.ts')}.expected.ts`); + if (!fs.existsSync(expectedFile)) { + done.fail(`Expected file not found. Generated output at ${actualFile}`); + } + const actual = await fs.readFile(actualFile, { encoding: 'utf8' }); + const expected = await fs.readFile(expectedFile, { encoding: 'utf8' }); + if (actual !== expected) { + done.fail(`Linted file did not match expectations. Expected: ${expectedFile}. Actual: ${actualFile}`); + } + done(); + }); + }); +}); + +async function lintAndFix(file: string) { + const newPath = path.join(outputDir, path.basename(file)) + let result = await linter.lintFiles(file); + await ESLint.outputFixes(result.map(r => { + r.filePath = newPath; + return r; + })); + return newPath; +} \ No newline at end of file diff --git a/tools/eslint-plugin-cdk/tsconfig.json b/tools/eslint-plugin-cdk/tsconfig.json new file mode 100644 index 0000000000000..aea4e63c9206c --- /dev/null +++ b/tools/eslint-plugin-cdk/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "lib": ["es2018"], + "strict": true, + "alwaysStrict": true, + "declaration": true, + "inlineSourceMap": true, + "inlineSources": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "resolveJsonModule": true, + "composite": true, + "incremental": true + }, + "include": ["**/*.ts"], + "exclude": ["node_modules", "**/fixtures"] +} diff --git a/yarn.lock b/yarn.lock index 9ddc857a9f1ab..03e7e46a0c496 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3094,6 +3094,19 @@ resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== +"@types/eslint@^7.2.3": + version "7.2.3" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.3.tgz#a3731b7584fe1a847a34e67ac57a556afd9b0c0e" + integrity sha512-SPBkpC+awgFfyAn4sjt0JBZ3vzACoSp2zhGBJkkrs09EzPqLbxkzaE8kJs3EsRRgkZwWk9zyXT/swvhnJYX8pQ== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*": + version "0.0.45" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884" + integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g== + "@types/fs-extra@^8.1.1": version "8.1.1" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.1.tgz#1e49f22d09aa46e19b51c0b013cb63d0d923a068" @@ -3151,7 +3164,7 @@ jest-diff "^25.2.1" pretty-format "^25.2.1" -"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5": +"@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5": version "7.0.6" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== @@ -6201,6 +6214,11 @@ eslint-plugin-promise@^4.2.1: resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz#845fd8b2260ad8f82564c1222fce44ad71d9418a" integrity sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw== +eslint-plugin-rulesdir@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-rulesdir/-/eslint-plugin-rulesdir-0.1.0.tgz#ad144d7e98464fda82963eff3fab331aecb2bf08" + integrity sha1-rRRNfphGT9qClj7/P6szGuyyvwg= + eslint-plugin-standard@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-4.0.1.tgz#ff0519f7ffaff114f76d1bd7c3996eef0f6e20b4" From ff3a69285f1f3ae1ff6c6b1495192ce54e46d2fc Mon Sep 17 00:00:00 2001 From: geduld Date: Tue, 6 Oct 2020 04:33:42 +0900 Subject: [PATCH 20/47] fix(codepipeline-actions): correctly name the triggering Event in CodeCommitSourceAction (#10706) Use backticks instead of single quotes for template strings. Fixes #10665 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-codepipeline-actions/lib/codecommit/source-action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts index 8f33d16ac8c41..62e8b83ba3424 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts @@ -165,7 +165,7 @@ export class CodeCommitSourceAction extends Action { } while (this.props.repository.node.tryFindChild(candidate) !== undefined); return candidate; } else { - const branchIdDisambiguator = this.branch === 'master' ? '' : '-${this.branch}-'; + const branchIdDisambiguator = this.branch === 'master' ? '' : `-${this.branch}-`; return this.eventIdFromPrefix(`${baseId}${branchIdDisambiguator}`); } } From 7dd80f13763b2459bbd102e17316024f5dec979a Mon Sep 17 00:00:00 2001 From: Shiv Lakshminarayan Date: Mon, 5 Oct 2020 22:51:52 -0700 Subject: [PATCH 21/47] chore(config): add features to represent initial set-up and rules (#10707) Rationale: Rules have been in developer preview for ~6 months We will add support for the initial set-up through L2s, but they will likely need to be marked as experimental and iterated on before reaching a stable state. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-config/README.md | 68 +++++++++++++++++------ packages/@aws-cdk/aws-config/lib/rule.ts | 14 ++--- packages/@aws-cdk/aws-config/package.json | 10 ++++ 3 files changed, 67 insertions(+), 25 deletions(-) diff --git a/packages/@aws-cdk/aws-config/README.md b/packages/@aws-cdk/aws-config/README.md index c2fbf8b3722b3..c4dfa580b49e3 100644 --- a/packages/@aws-cdk/aws-config/README.md +++ b/packages/@aws-cdk/aws-config/README.md @@ -2,31 +2,26 @@ --- -![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge) +| Features | Stability | +| --- | --- | +| CFN Resources | ![Stable](https://img.shields.io/badge/stable-success.svg?style=for-the-badge) | +| Higher level constructs for Config Rules | ![Developer Preview](https://img.shields.io/badge/developer--preview-informational.svg?style=for-the-badge) | +| Higher level constructs for initial set-up (delivery channel & configuration recorder) | ![Not Implemented](https://img.shields.io/badge/not--implemented-black.svg?style=for-the-badge) | -> All classes with the `Cfn` prefix in this module ([CFN Resources](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) are always stable and safe to use. +> **CFN Resources:** All classes with the `Cfn` prefix in this module ([CFN Resources](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) are always stable and safe to use. -![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. +> **Developer Preview:** Higher level constructs in this module that are marked as developer preview have completed their phase of active development and are looking for adoption and feedback. While the same caveats around non-backward compatible as Experimental constructs apply, they will undergo fewer breaking changes. Just as with Experimental constructs, these are not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be announced in the release notes. --- This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. -Supported: -* Config rules - -Not supported -* Configuration recorder -* Delivery channel -* Aggregation - ### Initial Setup -Before using the constructs provided in this module, you need to setup -AWS Config in the region you plan on using it in. This setup includes: +Before using the constructs provided in this module, you need to set up AWS Config +in the region in which it will be used. This setup includes the one-time creation of the +following resources per region: - `ConfigurationRecorder`: Configure which resources will be recorded for config changes. - `DeliveryChannel`: Configure where to store the recorded data. @@ -39,6 +34,7 @@ Following are the guides to setup AWS Config: ### Rules #### AWS managed rules + To set up a managed rule, define a `ManagedRule` and specify its identifier: ```ts @@ -53,6 +49,7 @@ Available identifiers and parameters are listed in the [List of AWS Config Manag Higher level constructs for managed rules are available, see [Managed Rules](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-config/lib/managed-rules.ts). Prefer to use those constructs when available (PRs welcome to add more of those). #### Custom rules + To set up a custom rule, define a `CustomRule` and specify the Lambda Function to run and the trigger types: ```ts @@ -64,7 +61,11 @@ new CustomRule(this, 'CustomRule', { ``` #### Restricting the scope -By default rules are triggered by changes to all [resources](https://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources). Use the `scopeToResource()`, `scopeToResources()` or `scopeToTag()` methods to restrict the scope of both managed and custom rules: + +By default rules are triggered by changes to all [resources](https://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources). + +Use the `scopeToResource()`, `scopeToResources()` or `scopeToTag()` APIs to restrict +the scope of both managed and custom rules: ```ts const sshRule = new ManagedRule(this, 'SSH', { @@ -86,6 +87,7 @@ customRule.scopeToTag('Cost Center', 'MyApp'); Only one type of scope restriction can be added to a rule (the last call to `scopeToXxx()` sets the scope). #### Events + To define Amazon CloudWatch event rules, use the `onComplianceChange()` or `onReEvaluationStatus()` methods: ```ts @@ -96,6 +98,36 @@ rule.onComplianceChange('TopicEvent', { ``` #### Example -Creating custom and managed rules with scope restriction and events: -[example of setting up rules](test/integ.rule.lit.ts) +The following example creates a custom rule that runs on configuration changes to EC2 instances and publishes +compliance events to an SNS topic. + +```ts +import * as config from '@aws-cdk/aws-config'; +import * as lambda from '@aws-cdk/aws-lambda'; + +// A custom rule that runs on configuration changes of EC2 instances +const fn = new lambda.Function(this, 'CustomFunction', { + code: lambda.AssetCode.fromInline('exports.handler = (event) => console.log(event);'), + handler: 'index.handler', + runtime: lambda.Runtime.NODEJS_10_X, +}); + +const customRule = new config.CustomRule(this, 'Custom', { + configurationChanges: true, + lambdaFunction: fn, +}); + +customRule.scopeToResource('AWS::EC2::Instance'); + +// A rule to detect stack drifts +const driftRule = new config.CloudFormationStackDriftDetectionCheck(this, 'Drift'); + +// Topic to which compliance notification events will be published +const complianceTopic = new sns.Topic(this, 'ComplianceTopic'); + +// Send notification on compliance change +driftRule.onComplianceChange('ComplianceChange', { + target: new targets.SnsTopic(complianceTopic), +}); +``` diff --git a/packages/@aws-cdk/aws-config/lib/rule.ts b/packages/@aws-cdk/aws-config/lib/rule.ts index 06ae1f943b85a..9984a22fdac61 100644 --- a/packages/@aws-cdk/aws-config/lib/rule.ts +++ b/packages/@aws-cdk/aws-config/lib/rule.ts @@ -6,7 +6,7 @@ import { Construct } from 'constructs'; import { CfnConfigRule } from './config.generated'; /** - * A config rule. + * Interface representing an AWS Config rule */ export interface IRule extends IResource { /** @@ -17,18 +17,18 @@ export interface IRule extends IResource { readonly configRuleName: string; /** - * Defines a CloudWatch event rule which triggers for rule events. Use + * Defines an EventBridge event rule which triggers for rule events. Use * `rule.addEventPattern(pattern)` to specify a filter. */ onEvent(id: string, options?: events.OnEventOptions): events.Rule; /** - * Defines a CloudWatch event rule which triggers for rule compliance events. + * Defines a EventBridge event rule which triggers for rule compliance events. */ onComplianceChange(id: string, options?: events.OnEventOptions): events.Rule; /** - * Defines a CloudWatch event rule which triggers for rule re-evaluation status events. + * Defines a EventBridge event rule which triggers for rule re-evaluation status events. */ onReEvaluationStatus(id: string, options?: events.OnEventOptions): events.Rule; } @@ -40,7 +40,7 @@ abstract class RuleBase extends Resource implements IRule { public abstract readonly configRuleName: string; /** - * Defines a CloudWatch event rule which triggers for rule events. Use + * Defines an EventBridge event rule which triggers for rule events. Use * `rule.addEventPattern(pattern)` to specify a filter. */ public onEvent(id: string, options: events.OnEventOptions = {}) { @@ -56,7 +56,7 @@ abstract class RuleBase extends Resource implements IRule { } /** - * Defines a CloudWatch event rule which triggers for rule compliance events. + * Defines an EventBridge event rule which triggers for rule compliance events. */ public onComplianceChange(id: string, options: events.OnEventOptions = {}): events.Rule { const rule = this.onEvent(id, options); @@ -67,7 +67,7 @@ abstract class RuleBase extends Resource implements IRule { } /** - * Defines a CloudWatch event rule which triggers for rule re-evaluation status events. + * Defines an EventBridge event rule which triggers for rule re-evaluation status events. */ public onReEvaluationStatus(id: string, options: events.OnEventOptions = {}): events.Rule { const rule = this.onEvent(id, options); diff --git a/packages/@aws-cdk/aws-config/package.json b/packages/@aws-cdk/aws-config/package.json index f049256f71aba..3d3e033d053a2 100644 --- a/packages/@aws-cdk/aws-config/package.json +++ b/packages/@aws-cdk/aws-config/package.json @@ -101,6 +101,16 @@ }, "stability": "experimental", "maturity": "developer-preview", + "features": [ + { + "name": "Higher level constructs for Config Rules", + "stability": "Developer Preview" + }, + { + "name": "Higher level constructs for initial set-up (delivery channel & configuration recorder)", + "stability": "Not Implemented" + } + ], "awscdkio": { "announce": false } From e57f5c3aa8fd780dfbdecf49cd18ba16f0883737 Mon Sep 17 00:00:00 2001 From: Alex Pulver Date: Tue, 6 Oct 2020 10:07:07 +0300 Subject: [PATCH 22/47] docs(cli): update cdk init help message (#8995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As of AWS CDK 1.51.0, `cdk init` does not default to `app` template, but lists available templates and languages. ```bash $ cdk init Available templates: * app: Template for a CDK Application └─ cdk init app --language=[csharp|fsharp|java|javascript|python|typescript] * lib: Template for a CDK Construct Library └─ cdk init lib --language=typescript * sample-app: Example CDK Application with some constructs └─ cdk init sample-app --language=[csharp|fsharp|java|javascript|python|typescript] ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/bin/cdk.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/bin/cdk.ts b/packages/aws-cdk/bin/cdk.ts index 5ae3896e2bec4..fcae51e342956 100644 --- a/packages/aws-cdk/bin/cdk.ts +++ b/packages/aws-cdk/bin/cdk.ts @@ -107,7 +107,7 @@ async function parseCommandLineArguments() { .option('strict', { type: 'boolean', desc: 'Do not filter out AWS::CDK::Metadata resources', default: false })) .option('fail', { type: 'boolean', desc: 'Fail with exit code 1 in case of diff', default: false }) .command('metadata [STACK]', 'Returns all metadata associated with this stack') - .command('init [TEMPLATE]', 'Create a new, empty CDK project from a template. Invoked without TEMPLATE, the app template will be used.', yargs => yargs + .command('init [TEMPLATE]', 'Create a new, empty CDK project from a template.', yargs => yargs .option('language', { type: 'string', alias: 'l', desc: 'The language to be used for the new project (default can be configured in ~/.cdk.json)', choices: initTemplateLanuages }) .option('list', { type: 'boolean', desc: 'List the available templates' }) .option('generate-only', { type: 'boolean', default: false, desc: 'If true, only generates project files, without executing additional operations such as setting up a git repo, installing dependencies or compiling the project' }), From 08ae74569eb52fb73f202b770d652a941fd61ea4 Mon Sep 17 00:00:00 2001 From: Dan Andersson Date: Tue, 6 Oct 2020 11:04:30 +0200 Subject: [PATCH 23/47] feat(aws-ec2): KINESIS_FIREHOSE vpc endpoint (#10682) KINESIS_FIREHOSE is missing from InterfaceVpcEndpointAwsService. KINESIS_STREAM is provided, but Firehose is not. closes: #10611 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../test/s3-origin.test.ts | 24 ++++++++++++++----- packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts | 1 + packages/@aws-cdk/aws-ec2/package.json | 1 + .../test/integ.instance-init.expected.json | 6 ++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts b/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts index 84aacc84916d6..7545135e4fb0e 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts @@ -19,11 +19,17 @@ describe('With bucket', () => { const origin = new S3Origin(bucket); const originBindConfig = origin.bind(stack, { originId: 'StackOrigin029E19582' }); - expect(originBindConfig.originProperty).toEqual({ + expect(stack.resolve(originBindConfig.originProperty)).toEqual({ id: 'StackOrigin029E19582', - domainName: bucket.bucketRegionalDomainName, + domainName: { 'Fn::GetAtt': ['Bucket83908E77', 'RegionalDomainName'] }, s3OriginConfig: { - originAccessIdentity: 'origin-access-identity/cloudfront/${Token[TOKEN.69]}', + originAccessIdentity: { + 'Fn::Join': ['', + [ + 'origin-access-identity/cloudfront/', + { Ref: 'S3Origin83A0717C' }, + ]], + }, }, }); }); @@ -34,12 +40,18 @@ describe('With bucket', () => { const origin = new S3Origin(bucket, { originPath: '/assets' }); const originBindConfig = origin.bind(stack, { originId: 'StackOrigin029E19582' }); - expect(originBindConfig.originProperty).toEqual({ + expect(stack.resolve(originBindConfig.originProperty)).toEqual({ id: 'StackOrigin029E19582', - domainName: bucket.bucketRegionalDomainName, + domainName: { 'Fn::GetAtt': ['Bucket83908E77', 'RegionalDomainName'] }, originPath: '/assets', s3OriginConfig: { - originAccessIdentity: 'origin-access-identity/cloudfront/${Token[TOKEN.89]}', + originAccessIdentity: { + 'Fn::Join': ['', + [ + 'origin-access-identity/cloudfront/', + { Ref: 'S3Origin83A0717C' }, + ]], + }, }, }); }); diff --git a/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts index 2770ed0f6a5b6..d612641eaa929 100644 --- a/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts +++ b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts @@ -281,6 +281,7 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ public static readonly CODECOMMIT_GIT = new InterfaceVpcEndpointAwsService('git-codecommit'); public static readonly CODECOMMIT_GIT_FIPS = new InterfaceVpcEndpointAwsService('git-codecommit-fips'); public static readonly KINESIS_STREAMS = new InterfaceVpcEndpointAwsService('kinesis-streams'); + public static readonly KINESIS_FIREHOSE = new InterfaceVpcEndpointAwsService('kinesis-firehose'); public static readonly KMS = new InterfaceVpcEndpointAwsService('kms'); public static readonly CLOUDWATCH_LOGS = new InterfaceVpcEndpointAwsService('logs'); public static readonly CLOUDWATCH = new InterfaceVpcEndpointAwsService('monitoring'); diff --git a/packages/@aws-cdk/aws-ec2/package.json b/packages/@aws-cdk/aws-ec2/package.json index 3b4c3c0e04ccb..e61318e44f6cf 100644 --- a/packages/@aws-cdk/aws-ec2/package.json +++ b/packages/@aws-cdk/aws-ec2/package.json @@ -229,6 +229,7 @@ "docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.ELASTIC_INFERENCE_RUNTIME", "docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.ELASTIC_LOAD_BALANCING", "docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.KINESIS_STREAMS", + "docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.KINESIS_FIREHOSE", "docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.KMS", "docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.SAGEMAKER_API", "docs-public-apis:@aws-cdk/aws-ec2.InterfaceVpcEndpointAwsService.SAGEMAKER_NOTEBOOK", diff --git a/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json b/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json index 24467fddd0e96..e9f87b528f4b1 100644 --- a/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json +++ b/packages/@aws-cdk/aws-ec2/test/integ.instance-init.expected.json @@ -130,7 +130,7 @@ ] } }, - "Instance255F35265813bd3c1f652ed5b": { + "Instance255F352658b696f54f846988d": { "Type": "AWS::EC2::Instance", "Properties": { "AvailabilityZone": "us-east-1a", @@ -169,7 +169,7 @@ { "Ref": "AWS::StackName" }, - " --resource Instance255F35265813bd3c1f652ed5b -c default\n /opt/aws/bin/cfn-signal -e $? --region ", + " --resource Instance255F352658b696f54f846988d -c default\n /opt/aws/bin/cfn-signal -e $? --region ", { "Ref": "AWS::Region" }, @@ -177,7 +177,7 @@ { "Ref": "AWS::StackName" }, - " --resource Instance255F35265813bd3c1f652ed5b\n cat /var/log/cfn-init.log >&2\n)" + " --resource Instance255F352658b696f54f846988d\n cat /var/log/cfn-init.log >&2\n)" ] ] } From 320ec72a30f06920ab24fb43afff6975992db71f Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Tue, 6 Oct 2020 15:01:37 +0530 Subject: [PATCH 24/47] feat(core): pass environment variables to CustomResourceProvider (#10560) Add environment prop to CustomResourceProvider closes #9668 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../custom-resource-provider.ts | 26 ++++++++++++++++++ .../custom-resource-provider.test.ts | 27 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts index 821307e466a77..82160f3a63ad6 100644 --- a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts +++ b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts @@ -60,6 +60,13 @@ export interface CustomResourceProviderProps { * @default Size.mebibytes(128) */ readonly memorySize?: Size; + + /** + * Key-value pairs that are passed to Lambda as Environment + * + * @default - No environment variables. + */ + readonly environment?: { [key: string]: string }; } /** @@ -177,6 +184,7 @@ export class CustomResourceProvider extends CoreConstruct { Handler: `${ENTRYPOINT_FILENAME}.handler`, Role: role.getAtt('Arn'), Runtime: 'nodejs12.x', + Environment: this.renderEnvironmentVariables(props.environment), }, }); @@ -184,4 +192,22 @@ export class CustomResourceProvider extends CoreConstruct { this.serviceToken = Token.asString(handler.getAtt('Arn')); } + + private renderEnvironmentVariables(env?: { [key: string]: string }) { + if (!env || Object.keys(env).length === 0) { + return undefined; + } + + // Sort environment so the hash of the function used to create + // `currentVersion` is not affected by key order (this is how lambda does + // it) + const variables: { [key: string]: string } = {}; + const keys = Object.keys(env).sort(); + + for (const key of keys) { + variables[key] = env[key]; + } + + return { Variables: variables }; + } } diff --git a/packages/@aws-cdk/core/test/custom-resource-provider/custom-resource-provider.test.ts b/packages/@aws-cdk/core/test/custom-resource-provider/custom-resource-provider.test.ts index f3dbff18ed651..3a08468d9dc32 100644 --- a/packages/@aws-cdk/core/test/custom-resource-provider/custom-resource-provider.test.ts +++ b/packages/@aws-cdk/core/test/custom-resource-provider/custom-resource-provider.test.ts @@ -169,4 +169,31 @@ nodeunitShim({ test.deepEqual(lambda.Properties.Timeout, 300); test.done(); }, + + 'environment variables'(test: Test) { + // GIVEN + const stack = new Stack(); + + // WHEN + CustomResourceProvider.getOrCreate(stack, 'Custom:MyResourceType', { + codeDirectory: TEST_HANDLER, + runtime: CustomResourceProviderRuntime.NODEJS_12, + environment: { + B: 'b', + A: 'a', + }, + }); + + // THEN + const template = toCloudFormation(stack); + const lambda = template.Resources.CustomMyResourceTypeCustomResourceProviderHandler29FBDD2A; + test.deepEqual(lambda.Properties.Environment, { + Variables: { + A: 'a', + B: 'b', + }, + }); + test.done(); + }, }); + From 614c2a631c097068a549cd447263b8f62e686d7a Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 6 Oct 2020 10:48:15 +0100 Subject: [PATCH 25/47] chore: fix buildup failing due to eslint-plugin-cdk missing (#10719) pkglint uses the same eslintrc file as the rest of the repo but does not depend on cdk-build-tools. Fix this by explicitly declaring eslint-plugin-cdk as a dependency. --- tools/pkglint/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/pkglint/package.json b/tools/pkglint/package.json index efd19c39b098f..d83de33dfdd46 100644 --- a/tools/pkglint/package.json +++ b/tools/pkglint/package.json @@ -38,6 +38,7 @@ "@types/fs-extra": "^8.1.1", "@types/semver": "^7.3.4", "@types/yargs": "^15.0.7", + "eslint-plugin-cdk": "0.0.0", "jest": "^26.4.2", "typescript": "~3.9.7" }, From 063798bdde241285df155999a0a5795eead87703 Mon Sep 17 00:00:00 2001 From: Christopher Rybicki Date: Tue, 6 Oct 2020 06:17:05 -0400 Subject: [PATCH 26/47] fix(core): cannot override properties with `.` in the name (#10441) Closes #10109 While researching this, I saw some comments multiple years old saying that JavaScript doesn't support RegExp lookbehind assertions, but from the looks of https://node.green/ it is supported all the way back to 10.3.0, so that aligns with current CDK supported node versions. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/core/lib/cfn-resource.ts | 28 ++++++++++++++++- packages/@aws-cdk/core/test/resource.test.ts | 33 ++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/core/lib/cfn-resource.ts b/packages/@aws-cdk/core/lib/cfn-resource.ts index c899d95b657c8..58e6820e4b5a7 100644 --- a/packages/@aws-cdk/core/lib/cfn-resource.ts +++ b/packages/@aws-cdk/core/lib/cfn-resource.ts @@ -146,6 +146,10 @@ export class CfnResource extends CfnRefElement { * If the override is nested, separate each nested level using a dot (.) in the path parameter. * If there is an array as part of the nesting, specify the index in the path. * + * To include a literal `.` in the property name, prefix with a `\`. In most + * programming languages you will need to write this as `"\\."` because the + * `\` itself will need to be escaped. + * * For example, * ```typescript * addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']) @@ -177,7 +181,7 @@ export class CfnResource extends CfnRefElement { * @param value - The value. Could be primitive or complex. */ public addOverride(path: string, value: any) { - const parts = path.split('.'); + const parts = splitOnPeriods(path); let curr: any = this.rawOverrides; while (parts.length > 1) { @@ -495,3 +499,25 @@ function deepMerge(target: any, ...sources: any[]) { return target; } + +/** + * Split on periods while processing escape characters \ + */ +function splitOnPeriods(x: string): string[] { + // Build this list in reverse because it's more convenient to get the "current" + // item by doing ret[0] than by ret[ret.length - 1]. + const ret = ['']; + for (let i = 0; i < x.length; i++) { + if (x[i] === '\\' && i + 1 < x.length) { + ret[0] += x[i + 1]; + i++; + } else if (x[i] === '.') { + ret.unshift(''); + } else { + ret[0] += x[i]; + } + } + + ret.reverse(); + return ret; +} \ No newline at end of file diff --git a/packages/@aws-cdk/core/test/resource.test.ts b/packages/@aws-cdk/core/test/resource.test.ts index a559a33658ba2..b883d11f8d752 100644 --- a/packages/@aws-cdk/core/test/resource.test.ts +++ b/packages/@aws-cdk/core/test/resource.test.ts @@ -586,6 +586,39 @@ nodeunitShim({ test.done(); }, + 'addOverride(p, v) will not split on escaped dots'(test: Test) { + // GIVEN + const stack = new Stack(); + const r = new CfnResource(stack, 'MyResource', { type: 'AWS::Resource::Type' }); + + // WHEN + r.addOverride(String.raw`Properties.Hello\.World.Foo\.Bar\.Baz`, 42); + r.addOverride(String.raw`Properties.Single\Back\Slashes`, 42); + r.addOverride(String.raw`Properties.Escaped\\.Back\\.Slashes`, 42); + r.addOverride(String.raw`Properties.DoublyEscaped\\\\Back\\\\Slashes`, 42); + r.addOverride('Properties.EndWith\\', 42); // Raw string cannot end with a backslash + + // THEN + test.deepEqual(toCloudFormation(stack), { + Resources: + { + MyResource: + { + Type: 'AWS::Resource::Type', + Properties: + { + 'Hello.World': { 'Foo.Bar.Baz': 42 }, + 'SingleBackSlashes': 42, + 'Escaped\\': { 'Back\\': { Slashes: 42 } }, + 'DoublyEscaped\\\\Back\\\\Slashes': 42, + 'EndWith\\': 42, + }, + }, + }, + }); + test.done(); + }, + 'addPropertyOverride(pp, v) is a sugar for overriding properties'(test: Test) { // GIVEN const stack = new Stack(); From d345919800d02b80f40802da60e567d4a30b3521 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 6 Oct 2020 12:45:12 +0200 Subject: [PATCH 27/47] fix(cli): deploying a transformed template without changes fails (#10689) The error message is apparently different for templates with Transforms in them, which we need to classify properly. Fixes #10650. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-cdk/lib/api/util/cloudformation.ts | 10 ++++++++-- .../aws-cdk/test/api/deploy-stack.test.ts | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/api/util/cloudformation.ts b/packages/aws-cdk/lib/api/util/cloudformation.ts index 4c75b88c445c0..63f4558d32bcd 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation.ts @@ -242,9 +242,15 @@ export async function waitForChangeSet(cfn: CloudFormation, stackName: string, c * there are changes to Outputs, the change set can still be executed. */ export function changeSetHasNoChanges(description: CloudFormation.DescribeChangeSetOutput) { + const noChangeErrorPrefixes = [ + // Error message for a regular template + 'The submitted information didn\'t contain changes.', + // Error message when a Transform is involved (see #10650) + 'No updates are to be performed.', + ]; + return description.Status === 'FAILED' - && description.StatusReason - && description.StatusReason.startsWith('The submitted information didn\'t contain changes.'); + && noChangeErrorPrefixes.some(p => (description.StatusReason ?? '').startsWith(p)); } /** diff --git a/packages/aws-cdk/test/api/deploy-stack.test.ts b/packages/aws-cdk/test/api/deploy-stack.test.ts index e4507d76b1da4..6e45a20acc770 100644 --- a/packages/aws-cdk/test/api/deploy-stack.test.ts +++ b/packages/aws-cdk/test/api/deploy-stack.test.ts @@ -46,6 +46,7 @@ beforeEach(() => { ], })), createChangeSet: jest.fn((_o) => ({})), + deleteChangeSet: jest.fn((_o) => ({})), describeChangeSet: jest.fn((_o) => ({ Status: 'CREATE_COMPLETE', Changes: [], @@ -376,6 +377,24 @@ test('deploy not skipped if template did not change but tags changed', async () expect(cfnMocks.getTemplate).toHaveBeenCalledWith({ StackName: 'withouterrors', TemplateStage: 'Original' }); }); +test('deployStack reports no change if describeChangeSet returns specific error', async () => { + cfnMocks.describeChangeSet?.mockImplementation(() => ({ + Status: 'FAILED', + StatusReason: 'No updates are to be performed.', + })); + + // WHEN + const deployResult = await deployStack({ + stack: FAKE_STACK, + sdk, + sdkProvider, + resolvedEnvironment: mockResolvedEnvironment(), + }); + + // THEN + expect(deployResult.noOp).toEqual(true); +}); + test('deploy not skipped if template did not change but one tag removed', async () => { // GIVEN givenStackExists({ From bf2c6298358a0eaa7db161798798dda37b1154aa Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 6 Oct 2020 13:49:21 +0200 Subject: [PATCH 28/47] fix(pipelines): cannot use constructs in build environment (#10654) The environment serialization that is used to calculate a hash of the project configuration which is used to restart the pipeline (still following?) was not taking into account that some of the fields of `Environment` are not just data, but are objects. We have to turn those into data before we can serialize them. Fixes #10535. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../lib/synths/simple-synth-action.ts | 17 +++++++++++++++- packages/@aws-cdk/pipelines/package.json | 1 + .../@aws-cdk/pipelines/test/builds.test.ts | 20 +++++++++++++++++++ .../integ.pipeline-with-assets.expected.json | 4 ++-- .../test/integ.pipeline.expected.json | 4 ++-- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts b/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts index 785ef9cc46bc7..8365a3404e120 100644 --- a/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts +++ b/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts @@ -327,7 +327,7 @@ export class SimpleSynthAction implements codepipeline.IAction, iam.IGrantable { // here because the pipeline will definitely restart if projectName changes. // (Resolve tokens) const projectConfigHash = hash(Stack.of(scope).resolve({ - environment, + environment: serializeBuildEnvironment(environment), buildSpecString: buildSpec.toBuildSpec(), environmentVariables, })); @@ -486,3 +486,18 @@ function hash(obj: A) { d.update(JSON.stringify(obj)); return d.digest('hex'); } + +/** + * Serialize a build environment to data (get rid of constructs & objects), so we can JSON.stringify it + */ +function serializeBuildEnvironment(env: codebuild.BuildEnvironment) { + return { + privileged: env.privileged, + environmentVariables: env.environmentVariables, + type: env.buildImage?.type, + imageId: env.buildImage?.imageId, + computeType: env.computeType, + imagePullPrincipalType: env.buildImage?.imagePullPrincipalType, + secretsManagerArn: env.buildImage?.secretsManagerCredentials?.secretArn, + }; +} \ No newline at end of file diff --git a/packages/@aws-cdk/pipelines/package.json b/packages/@aws-cdk/pipelines/package.json index 4d1fa3a335370..d50e7ceb07726 100644 --- a/packages/@aws-cdk/pipelines/package.json +++ b/packages/@aws-cdk/pipelines/package.json @@ -37,6 +37,7 @@ "nodeunit": "^0.11.3", "pkglint": "0.0.0", "@aws-cdk/aws-s3": "0.0.0", + "@aws-cdk/aws-ecr": "0.0.0", "@aws-cdk/aws-ecr-assets": "0.0.0" }, "peerDependencies": { diff --git a/packages/@aws-cdk/pipelines/test/builds.test.ts b/packages/@aws-cdk/pipelines/test/builds.test.ts index fdb9171aedc73..8b753b5cbdc21 100644 --- a/packages/@aws-cdk/pipelines/test/builds.test.ts +++ b/packages/@aws-cdk/pipelines/test/builds.test.ts @@ -3,6 +3,7 @@ import '@aws-cdk/assert/jest'; import * as cbuild from '@aws-cdk/aws-codebuild'; import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as ec2 from '@aws-cdk/aws-ec2'; +import * as ecr from '@aws-cdk/aws-ecr'; import * as s3 from '@aws-cdk/aws-s3'; import { Stack } from '@aws-cdk/core'; import * as cdkp from '../lib'; @@ -405,6 +406,25 @@ test('SimpleSynthAction is IGrantable', () => { }); }); +test('SimpleSynthAction can reference an imported ECR repo', () => { + // Repro from https://github.com/aws/aws-cdk/issues/10535 + + // WHEN + new TestGitHubNpmPipeline(pipelineStack, 'Cdk', { + sourceArtifact, + cloudAssemblyArtifact, + synthAction: cdkp.SimpleSynthAction.standardNpmSynth({ + sourceArtifact, + cloudAssemblyArtifact, + environment: { + buildImage: cbuild.LinuxBuildImage.fromEcrRepository( + ecr.Repository.fromRepositoryName(pipelineStack, 'ECRImage', 'my-repo-name'), + ), + }, + }), + }); +}); + function npmYarnBuild(npmYarn: string) { if (npmYarn === 'npm') { return cdkp.SimpleSynthAction.standardNpmSynth; } if (npmYarn === 'yarn') { return cdkp.SimpleSynthAction.standardYarnSynth; } diff --git a/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json b/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json index 4c8786774af7e..b23bccdd40701 100644 --- a/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json +++ b/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json @@ -489,7 +489,7 @@ "ProjectName": { "Ref": "PipelineBuildSynthCdkBuildProject6BEFA8E6" }, - "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"7f09efece2ae66563f27569c480f9602225200051089f57486c5fa0b52095956\"}]" + "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"ea30b07764cb215963f4b0c292b5a06993fc3dd94621fbdc1c618e0f1e0dae10\"}]" }, "InputArtifacts": [ { @@ -1695,4 +1695,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json b/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json index 06d75a873fd53..c9cf293e1c173 100644 --- a/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json +++ b/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json @@ -445,7 +445,7 @@ "ProjectName": { "Ref": "PipelineBuildSynthCdkBuildProject6BEFA8E6" }, - "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"7f09efece2ae66563f27569c480f9602225200051089f57486c5fa0b52095956\"}]" + "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"ea30b07764cb215963f4b0c292b5a06993fc3dd94621fbdc1c618e0f1e0dae10\"}]" }, "InputArtifacts": [ { @@ -1391,4 +1391,4 @@ } } } -} \ No newline at end of file +} From e51921d1a81ba9d89e21567291b5f7b215726ca7 Mon Sep 17 00:00:00 2001 From: Eli Polonsky Date: Tue, 6 Oct 2020 17:36:23 +0300 Subject: [PATCH 29/47] feat(eks): Support cdk8s charts (#10562) Natively integrate EKS with the `cdk8s` library. Closes https://github.com/aws/aws-cdk/issues/9670 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-eks/README.md | 122 ++++++++++++++++ packages/@aws-cdk/aws-eks/lib/cluster.ts | 22 +++ .../@aws-cdk/aws-eks/lib/legacy-cluster.ts | 9 ++ packages/@aws-cdk/aws-eks/package.json | 5 +- .../test/integ.eks-cluster.expected.json | 137 +++++++++++------- .../aws-eks/test/integ.eks-cluster.ts | 25 ++++ .../@aws-cdk/aws-eks/test/test.cluster.ts | 44 ++++++ packages/aws-cdk-lib/package.json | 4 +- packages/monocdk-experiment/package.json | 4 +- 9 files changed, 319 insertions(+), 53 deletions(-) diff --git a/packages/@aws-cdk/aws-eks/README.md b/packages/@aws-cdk/aws-eks/README.md index a49a11aab2624..a04432a038be9 100644 --- a/packages/@aws-cdk/aws-eks/README.md +++ b/packages/@aws-cdk/aws-eks/README.md @@ -36,6 +36,7 @@ Table Of Contents * [Applying Kubernetes Resources](#applying-kubernetes-resources) * [Kubernetes Manifests](#kubernetes-manifests) * [Helm Charts](#helm-charts) + * [CDK8s Charts](#cdk8s-charts) * [Patching Kuberentes Resources](#patching-kubernetes-resources) * [Querying Kubernetes Resources](#querying-kubernetes-resources) * [Using existing clusters](#using-existing-clusters) @@ -811,6 +812,127 @@ const chart2 = cluster.addHelmChart(...); chart2.node.addDependency(chart1); ``` +#### CDK8s Charts + +[CDK8s](https://cdk8s.io/) is an open-source library that enables Kubernetes manifest authoring using familiar programming languages. It is founded on the same technologies as the AWS CDK, such as [`constructs`](https://github.com/aws/constructs) and [`jsii`](https://github.com/aws/jsii). + +> To learn more about cdk8s, visit the [Getting Started](https://github.com/awslabs/cdk8s/tree/master/docs/getting-started) tutorials. + +The EKS module natively integrates with cdk8s and allows you to apply cdk8s charts on AWS EKS clusters via the `cluster.addCdk8sChart` method. + +In addition to `cdk8s`, you can also use [`cdk8s+`](https://github.com/awslabs/cdk8s/tree/master/packages/cdk8s-plus), which provides higher level abstraction for the core kubernetes api objects. +You can think of it like the `L2` constructs for Kubernetes. Any other `cdk8s` based libraries are also supported, for example [`cdk8s-debore`](https://github.com/toricls/cdk8s-debore). + +To get started, add the following dependencies to your `package.json` file: + +```json +"dependencies": { + "cdk8s": "0.30.0", + "cdk8s-plus": "0.30.0", + "constructs": "3.0.4" +} +``` + +> Note that the version of `cdk8s` must be `>=0.30.0`. + +Similarly to how you would create a stack by extending `@aws-cdk/core.Stack`, we recommend you create a chart of your own that extends `cdk8s.Chart`, +and add your kubernetes resources to it. You can use `aws-cdk` construct attributes and properties inside your `cdk8s` construct freely. + +In this example we create a chart that accepts an `s3.Bucket` and passes its name to a kubernetes pod as an environment variable. + +Notice that the chart must accept a `constructs.Construct` type as its scope, not an `@aws-cdk/core.Construct` as you would normally use. +For this reason, to avoid possible confusion, we will create the chart in a separate file: + +`+ my-chart.ts` +```ts +import * as s3 from '@aws-cdk/aws-s3'; +import * as constructs from 'constructs'; +import * as cdk8s from 'cdk8s'; +import * as kplus from 'cdk8s-plus'; + +export interface MyChartProps { + readonly bucket: s3.Bucket; +} + +export class MyChart extends cdk8s.Chart { + constructor(scope: constructs.Construct, id: string, props: MyChartProps} ) { + super(scope, id); + + new kplus.Pod(this, 'Pod', { + spec: { + containers: [ + new kplus.Container({ + image: 'my-image', + env: { + BUCKET_NAME: bucket.bucketName, + } + }) + ] + } + }); + } +} +``` + +Then, in your AWS CDK app: + +```ts +import * as s3 from '@aws-cdk/aws-s3'; +import * as cdk8s from 'cdk8s'; +import { MyChart } from './my-chart'; + +// some bucket.. +const bucket = new s3.Bucket(this, 'Bucket'); + +// create a cdk8s chart and use `cdk8s.App` as the scope. +const myChart = new MyChart(new cdk8s.App(), 'MyChart', { bucket }); + +// add the cdk8s chart to the cluster +cluster.addCdk8sChart('my-chart', myChart); +``` + +##### Custom CDK8s Constructs + +You can also compose a few stock `cdk8s+` constructs into your own custom construct. However, since mixing scopes between `aws-cdk` and `cdk8s` is currently not supported, the `Construct` class +you'll need to use is the one from the [`constructs`](https://github.com/aws/constructs) module, and not from `@aws-cdk/core` like you normally would. +This is why we used `new cdk8s.App()` as the scope of the chart above. + +```ts +import * as constructs from 'constructs'; +import * as cdk8s from 'cdk8s'; +import * as kplus from 'cdk8s-plus'; + +export interface LoadBalancedWebService { + readonly port: number; + readonly image: string; + readonly replicas: number; +} + +export class LoadBalancedWebService extends constructs.Construct { + constructor(scope: constructs.Construct, id: string, props: LoadBalancedWebService) { + super(scope, id); + + const deployment = new kplus.Deployment(chart, 'Deployment', { + spec: { + replicas: props.replicas, + podSpecTemplate: { + containers: [ new kplus.Container({ image: props.image }) ] + } + }, + }); + + deployment.expose({port: props.port, serviceType: kplus.ServiceType.LOAD_BALANCER}) + + } +} +``` + +##### Manually importing k8s specs and CRD's + +If you find yourself unable to use `cdk8s+`, or just like to directly use the `k8s` native objects or CRD's, you can do so by manually importing them using the `cdk8s-cli`. + +See [Importing kubernetes objects](https://github.com/awslabs/cdk8s/tree/master/packages/cdk8s-cli#import) for detailed instructions. + ## Patching Kubernetes Resources The `KubernetesPatch` construct can be used to update existing kubernetes diff --git a/packages/@aws-cdk/aws-eks/lib/cluster.ts b/packages/@aws-cdk/aws-eks/lib/cluster.ts index cf1b74743a1f9..ae9e1dbdc6dc1 100644 --- a/packages/@aws-cdk/aws-eks/lib/cluster.ts +++ b/packages/@aws-cdk/aws-eks/lib/cluster.ts @@ -7,6 +7,7 @@ import * as kms from '@aws-cdk/aws-kms'; import * as lambda from '@aws-cdk/aws-lambda'; import * as ssm from '@aws-cdk/aws-ssm'; import { Annotations, CfnOutput, CfnResource, IResource, Resource, Stack, Tags, Token, Duration } from '@aws-cdk/core'; +import * as cdk8s from 'cdk8s'; import { Construct, Node } from 'constructs'; import * as YAML from 'yaml'; import { AwsAuth } from './aws-auth'; @@ -132,6 +133,16 @@ export interface ICluster extends IResource, ec2.IConnectable { * @returns a `HelmChart` construct */ addHelmChart(id: string, options: HelmChartOptions): HelmChart; + + /** + * Defines a CDK8s chart in this cluster. + * + * @param id logical id of this chart. + * @param chart the cdk8s chart. + * @returns a `KubernetesManifest` construct representing the chart. + */ + addCdk8sChart(id: string, chart: cdk8s.Chart): KubernetesManifest; + } /** @@ -617,6 +628,17 @@ abstract class ClusterBase extends Resource implements ICluster { public addHelmChart(id: string, options: HelmChartOptions): HelmChart { return new HelmChart(this, `chart-${id}`, { cluster: this, ...options }); } + + /** + * Defines a CDK8s chart in this cluster. + * + * @param id logical id of this chart. + * @param chart the cdk8s chart. + * @returns a `KubernetesManifest` construct representing the chart. + */ + public addCdk8sChart(id: string, chart: cdk8s.Chart): KubernetesManifest { + return this.addManifest(id, ...chart.toJson()); + } } /** diff --git a/packages/@aws-cdk/aws-eks/lib/legacy-cluster.ts b/packages/@aws-cdk/aws-eks/lib/legacy-cluster.ts index 148e65166e1da..c862f7fd3d0f6 100644 --- a/packages/@aws-cdk/aws-eks/lib/legacy-cluster.ts +++ b/packages/@aws-cdk/aws-eks/lib/legacy-cluster.ts @@ -3,6 +3,7 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as kms from '@aws-cdk/aws-kms'; import * as ssm from '@aws-cdk/aws-ssm'; +import * as cdk8s from 'cdk8s'; import { Annotations, CfnOutput, Resource, Stack, Token, Tags } from '@aws-cdk/core'; import { Construct } from 'constructs'; import { ICluster, ClusterAttributes, KubernetesVersion, NodeType, DefaultCapacityType, EksOptimizedImage, AutoScalingGroupCapacityOptions, MachineImageType, AutoScalingGroupOptions, CommonClusterOptions } from './cluster'; @@ -371,6 +372,10 @@ export class LegacyCluster extends Resource implements ICluster { throw new Error('legacy cluster does not support adding helm charts'); } + public addCdk8sChart(_id: string, _chart: cdk8s.Chart): KubernetesManifest { + throw new Error('legacy cluster does not support adding cdk8s charts'); + } + /** * Opportunistically tag subnets with the required tags. * @@ -429,6 +434,10 @@ class ImportedCluster extends Resource implements ICluster { throw new Error('legacy cluster does not support adding helm charts'); } + public addCdk8sChart(_id: string, _chart: cdk8s.Chart): KubernetesManifest { + throw new Error('legacy cluster does not support adding cdk8s charts'); + } + public get vpc() { if (!this.props.vpc) { throw new Error('"vpc" is not defined for this imported cluster'); diff --git a/packages/@aws-cdk/aws-eks/package.json b/packages/@aws-cdk/aws-eks/package.json index 7aa6b16bdd7d4..dcf8ee02c9955 100644 --- a/packages/@aws-cdk/aws-eks/package.json +++ b/packages/@aws-cdk/aws-eks/package.json @@ -79,7 +79,8 @@ "cfn2ts": "0.0.0", "nodeunit": "^0.11.3", "pkglint": "0.0.0", - "sinon": "^9.1.0" + "sinon": "^9.1.0", + "cdk8s-plus": "^0.29.0" }, "dependencies": { "@aws-cdk/aws-autoscaling": "0.0.0", @@ -90,6 +91,7 @@ "@aws-cdk/aws-ssm": "0.0.0", "@aws-cdk/core": "0.0.0", "@aws-cdk/custom-resources": "0.0.0", + "cdk8s": "^0.30.0", "constructs": "^3.0.4", "yaml": "1.10.0" }, @@ -106,6 +108,7 @@ "@aws-cdk/aws-ssm": "0.0.0", "@aws-cdk/core": "0.0.0", "@aws-cdk/custom-resources": "0.0.0", + "cdk8s": "^0.30.0", "constructs": "^3.0.4" }, "engines": { diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json index b015b80826d45..6f5bb70ec88c7 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json @@ -3342,11 +3342,6 @@ } ], "ForceUpdateEnabled": true, - "ScalingConfig": { - "DesiredSize": 1, - "MaxSize": 1, - "MinSize": 1 - }, "LaunchTemplate": { "Id": { "Ref": "LaunchTemplate" @@ -3357,6 +3352,11 @@ "DefaultVersionNumber" ] } + }, + "ScalingConfig": { + "DesiredSize": 1, + "MaxSize": 1, + "MinSize": 1 } } }, @@ -3416,6 +3416,43 @@ "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, + "Clustermanifestcdk8schart6B444884": { + "Type": "Custom::AWSCDK-EKS-KubernetesResource", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "awscdkawseksKubectlProviderNestedStackawscdkawseksKubectlProviderNestedStackResourceA7AEBA6B", + "Outputs.awscdkeksclustertestawscdkawseksKubectlProviderframeworkonEventC681B49AArn" + ] + }, + "Manifest": { + "Fn::Join": [ + "", + [ + "[{\"apiVersion\":\"v1\",\"data\":{\"clusterName\":\"", + { + "Ref": "Cluster9EE0221C" + }, + "\"},\"kind\":\"ConfigMap\",\"metadata\":{\"name\":\"chart-config-map-configmap-cccf3117\"}}]" + ] + ] + }, + "ClusterName": { + "Ref": "Cluster9EE0221C" + }, + "RoleArn": { + "Fn::GetAtt": [ + "ClusterCreationRole360249B6", + "Arn" + ] + } + }, + "DependsOn": [ + "ClusterKubectlReadyBarrier200052AF" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, "ClustermanifestnginxnamespaceA68B4CE0": { "Type": "Custom::AWSCDK-EKS-KubernetesResource", "Properties": { @@ -3710,7 +3747,7 @@ }, "/", { - "Ref": "AssetParameters04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cfS3Bucket0E3AAAB9" + "Ref": "AssetParametersa69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0cS3Bucket1CB7A187" }, "/", { @@ -3720,7 +3757,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cfS3VersionKey8C90C4EF" + "Ref": "AssetParametersa69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0cS3VersionKey7C13F243" } ] } @@ -3733,7 +3770,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cfS3VersionKey8C90C4EF" + "Ref": "AssetParametersa69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0cS3VersionKey7C13F243" } ] } @@ -3749,17 +3786,17 @@ "Arn" ] }, - "referencetoawscdkeksclustertestAssetParameters7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4S3BucketAAB1A713Ref": { - "Ref": "AssetParameters7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4S3Bucket086F94BB" + "referencetoawscdkeksclustertestAssetParameters87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dbaS3Bucket1516DB0ARef": { + "Ref": "AssetParameters87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dbaS3Bucket14D204F9" }, - "referencetoawscdkeksclustertestAssetParameters7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4S3VersionKey481F0807Ref": { - "Ref": "AssetParameters7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4S3VersionKeyA4B5C598" + "referencetoawscdkeksclustertestAssetParameters87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dbaS3VersionKey2B8F3ED3Ref": { + "Ref": "AssetParameters87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dbaS3VersionKeyDE8A2F1F" }, - "referencetoawscdkeksclustertestAssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3Bucket85526CA7Ref": { - "Ref": "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3BucketD25BCC90" + "referencetoawscdkeksclustertestAssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3Bucket0815E7B5Ref": { + "Ref": "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3BucketDC4B98B1" }, - "referencetoawscdkeksclustertestAssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3VersionKey46BA60C1Ref": { - "Ref": "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3VersionKey72DFE7A5" + "referencetoawscdkeksclustertestAssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3VersionKey657736ADRef": { + "Ref": "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3VersionKeyA495226F" } } } @@ -3777,7 +3814,7 @@ }, "/", { - "Ref": "AssetParameters215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11S3BucketC456B560" + "Ref": "AssetParameters8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64S3BucketAA0CCE0D" }, "/", { @@ -3787,7 +3824,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11S3VersionKeyA1DAD649" + "Ref": "AssetParameters8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64S3VersionKey3012C8DD" } ] } @@ -3800,7 +3837,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11S3VersionKeyA1DAD649" + "Ref": "AssetParameters8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64S3VersionKey3012C8DD" } ] } @@ -3843,11 +3880,11 @@ "ClusterSecurityGroupId" ] }, - "referencetoawscdkeksclustertestAssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3Bucket85526CA7Ref": { - "Ref": "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3BucketD25BCC90" + "referencetoawscdkeksclustertestAssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3Bucket0815E7B5Ref": { + "Ref": "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3BucketDC4B98B1" }, - "referencetoawscdkeksclustertestAssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3VersionKey46BA60C1Ref": { - "Ref": "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3VersionKey72DFE7A5" + "referencetoawscdkeksclustertestAssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3VersionKey657736ADRef": { + "Ref": "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3VersionKeyA495226F" } } } @@ -4271,7 +4308,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3BucketD25BCC90" + "Ref": "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3BucketDC4B98B1" }, "S3Key": { "Fn::Join": [ @@ -4284,7 +4321,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3VersionKey72DFE7A5" + "Ref": "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3VersionKeyA495226F" } ] } @@ -4297,7 +4334,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3VersionKey72DFE7A5" + "Ref": "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3VersionKeyA495226F" } ] } @@ -4458,29 +4495,29 @@ } }, "Parameters": { - "AssetParameters7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4S3Bucket086F94BB": { + "AssetParameters87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dbaS3Bucket14D204F9": { "Type": "String", - "Description": "S3 bucket for asset \"7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4\"" + "Description": "S3 bucket for asset \"87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dba\"" }, - "AssetParameters7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4S3VersionKeyA4B5C598": { + "AssetParameters87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dbaS3VersionKeyDE8A2F1F": { "Type": "String", - "Description": "S3 key for asset version \"7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4\"" + "Description": "S3 key for asset version \"87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dba\"" }, - "AssetParameters7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4ArtifactHash9B26D532": { + "AssetParameters87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dbaArtifactHash54822A43": { "Type": "String", - "Description": "Artifact hash for asset \"7997347617940455774a736af2df2e6238c13b755ad25353a3d081446cfc80a4\"" + "Description": "Artifact hash for asset \"87b1e2c41f84590d14f7ab8cb0f338c51d6fa3efe78943867af07fa959593dba\"" }, - "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3BucketD25BCC90": { + "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3BucketDC4B98B1": { "Type": "String", - "Description": "S3 bucket for asset \"34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1\"" + "Description": "S3 bucket for asset \"daeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1\"" }, - "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1S3VersionKey72DFE7A5": { + "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1S3VersionKeyA495226F": { "Type": "String", - "Description": "S3 key for asset version \"34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1\"" + "Description": "S3 key for asset version \"daeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1\"" }, - "AssetParameters34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1ArtifactHashAA0236EE": { + "AssetParametersdaeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1ArtifactHashA521A16F": { "Type": "String", - "Description": "Artifact hash for asset \"34131c2e554ab57ad3a47fc0a13173a5c2a4b65a7582fe9622277b3d04c8e1e1\"" + "Description": "Artifact hash for asset \"daeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1\"" }, "AssetParametersb7d8a9750f8bfded8ac76be100e3bee1c3d4824df006766110d023f42952f5c2S3Bucket9ABBD5A2": { "Type": "String", @@ -4530,29 +4567,29 @@ "Type": "String", "Description": "Artifact hash for asset \"2acc31b34c05692ab3ea9831a27e5f241cffb21857e633d8256b8f0ebf5f3f43\"" }, - "AssetParameters04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cfS3Bucket0E3AAAB9": { + "AssetParametersa69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0cS3Bucket1CB7A187": { "Type": "String", - "Description": "S3 bucket for asset \"04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cf\"" + "Description": "S3 bucket for asset \"a69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0c\"" }, - "AssetParameters04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cfS3VersionKey8C90C4EF": { + "AssetParametersa69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0cS3VersionKey7C13F243": { "Type": "String", - "Description": "S3 key for asset version \"04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cf\"" + "Description": "S3 key for asset version \"a69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0c\"" }, - "AssetParameters04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cfArtifactHash1CDB946A": { + "AssetParametersa69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0cArtifactHashBADE945D": { "Type": "String", - "Description": "Artifact hash for asset \"04fa2d485a51abd8261468eb6fa053d3a72242fc068fa75683232a52960b30cf\"" + "Description": "Artifact hash for asset \"a69aadbed84d554dd9f2eb7987ffe5d8f76b53a86f1909059df07050e57bef0c\"" }, - "AssetParameters215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11S3BucketC456B560": { + "AssetParameters8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64S3BucketAA0CCE0D": { "Type": "String", - "Description": "S3 bucket for asset \"215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11\"" + "Description": "S3 bucket for asset \"8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64\"" }, - "AssetParameters215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11S3VersionKeyA1DAD649": { + "AssetParameters8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64S3VersionKey3012C8DD": { "Type": "String", - "Description": "S3 key for asset version \"215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11\"" + "Description": "S3 key for asset version \"8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64\"" }, - "AssetParameters215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11ArtifactHash95B6846D": { + "AssetParameters8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64ArtifactHashFBD3EEB7": { "Type": "String", - "Description": "Artifact hash for asset \"215e9f40bd76e7102c690b24b0922eb4963d2d24938eec175e107db683455d11\"" + "Description": "Artifact hash for asset \"8a716921b900641df041bd35d4d1817780375a004ec952e2cab0cd621c5a4d64\"" }, "SsmParameterValueawsserviceeksoptimizedami117amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts index 689d6cee92068..61860df4b94c5 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts @@ -3,6 +3,9 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as kms from '@aws-cdk/aws-kms'; import { App, CfnOutput, Duration, Token, Fn } from '@aws-cdk/core'; +import * as cdk8s from 'cdk8s'; +import * as kplus from 'cdk8s-plus'; +import * as constructs from 'constructs'; import * as eks from '../lib'; import * as hello from './hello-k8s'; import { Pinger } from './pinger/pinger'; @@ -58,6 +61,8 @@ class EksClusterStack extends TestStack { this.assertSimpleHelmChart(); + this.assertSimpleCdk8sChart(); + this.assertCreateNamespace(); this.assertServiceAccount(); @@ -101,6 +106,26 @@ class EksClusterStack extends TestStack { } + + private assertSimpleCdk8sChart() { + + class Chart extends cdk8s.Chart { + constructor(scope: constructs.Construct, ns: string, cluster: eks.ICluster) { + super(scope, ns); + + new kplus.ConfigMap(this, 'config-map', { + data: { + clusterName: cluster.clusterName, + }, + }); + + } + } + const app = new cdk8s.App(); + const chart = new Chart(app, 'Chart', this.cluster); + + this.cluster.addCdk8sChart('cdk8s-chart', chart); + } private assertSimpleHelmChart() { // deploy the Kubernetes dashboard through a helm chart this.cluster.addHelmChart('dashboard', { diff --git a/packages/@aws-cdk/aws-eks/test/test.cluster.ts b/packages/@aws-cdk/aws-eks/test/test.cluster.ts index afd71faa9c308..ca3ace90524d1 100644 --- a/packages/@aws-cdk/aws-eks/test/test.cluster.ts +++ b/packages/@aws-cdk/aws-eks/test/test.cluster.ts @@ -7,6 +7,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as kms from '@aws-cdk/aws-kms'; import * as lambda from '@aws-cdk/aws-lambda'; import * as cdk from '@aws-cdk/core'; +import * as cdk8s from 'cdk8s'; import * as constructs from 'constructs'; import { Test } from 'nodeunit'; import * as YAML from 'yaml'; @@ -21,6 +22,49 @@ const CLUSTER_VERSION = eks.KubernetesVersion.V1_16; export = { + 'cdk8s chart can be added to cluster'(test: Test) { + + const { stack } = testFixture(); + + const cluster = new eks.Cluster(stack, 'Cluster', { + version: eks.KubernetesVersion.V1_17, + }); + + const app = new cdk8s.App(); + const chart = new cdk8s.Chart(app, 'Chart'); + + new cdk8s.ApiObject(chart, 'FakePod', { + apiVersion: 'v1', + kind: 'Pod', + metadata: { + name: 'fake-pod', + labels: { + // adding aws-cdk token to cdk8s chart + clusterName: cluster.clusterName, + }, + }, + }); + + cluster.addCdk8sChart('cdk8s-chart', chart); + + expect(stack).to(haveResourceLike('Custom::AWSCDK-EKS-KubernetesResource', { + Manifest: { + 'Fn::Join': [ + '', + [ + '[{"apiVersion":"v1","kind":"Pod","metadata":{"labels":{"clusterName":"', + { + Ref: 'Cluster9EE0221C', + }, + '"},"name":"fake-pod"}}]', + ], + ], + }, + })); + + test.done(); + }, + 'cluster connections include both control plane and cluster security group'(test: Test) { const { stack } = testFixture(); diff --git a/packages/aws-cdk-lib/package.json b/packages/aws-cdk-lib/package.json index 55c8f73f38b4b..02b2d7db98e2d 100644 --- a/packages/aws-cdk-lib/package.json +++ b/packages/aws-cdk-lib/package.json @@ -259,6 +259,7 @@ "@types/node": "^10.17.35", "cdk-build-tools": "0.0.0", "constructs": "^3.0.4", + "cdk8s": "^0.30.0", "fs-extra": "^9.0.1", "pkglint": "0.0.0", "ts-node": "^9.0.0", @@ -266,7 +267,8 @@ "ubergen": "0.0.0" }, "peerDependencies": { - "constructs": "^3.0.4" + "constructs": "^3.0.4", + "cdk8s": "^0.30.0" }, "homepage": "https://github.com/aws/aws-cdk", "engines": { diff --git a/packages/monocdk-experiment/package.json b/packages/monocdk-experiment/package.json index da8000b78cf3d..14496548649c7 100644 --- a/packages/monocdk-experiment/package.json +++ b/packages/monocdk-experiment/package.json @@ -258,6 +258,7 @@ "@types/node": "^10.17.35", "cdk-build-tools": "0.0.0", "constructs": "^3.0.4", + "cdk8s": "^0.30.0", "fs-extra": "^9.0.1", "pkglint": "0.0.0", "ts-node": "^9.0.0", @@ -265,7 +266,8 @@ "ubergen": "0.0.0" }, "peerDependencies": { - "constructs": "^3.0.4" + "constructs": "^3.0.4", + "cdk8s": "^0.30.0" }, "homepage": "https://github.com/aws/aws-cdk", "engines": { From b7a13ee163162c4ee25b968fdb5ea6a844934f49 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 6 Oct 2020 17:04:31 +0200 Subject: [PATCH 30/47] chore: don't pack `test` directories (#10728) Stop bundling `test` directories in NPM packages to reduce package sizes and prevent Yarn from unplugging some packages based on the presence of a `.jar` file. Fixes #10602. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../ecs-service-extensions/.npmignore | 2 ++ .../ecs-service-extensions/package.json | 2 +- packages/@aws-cdk/alexa-ask/.npmignore | 3 ++- packages/@aws-cdk/app-delivery/.npmignore | 3 ++- packages/@aws-cdk/assert/.npmignore | 3 ++- packages/@aws-cdk/assets/.npmignore | 3 ++- packages/@aws-cdk/aws-accessanalyzer/.npmignore | 3 ++- packages/@aws-cdk/aws-acmpca/.npmignore | 3 ++- packages/@aws-cdk/aws-amazonmq/.npmignore | 3 ++- packages/@aws-cdk/aws-amplify/.npmignore | 3 ++- packages/@aws-cdk/aws-apigateway/.npmignore | 3 ++- packages/@aws-cdk/aws-apigatewayv2/.npmignore | 3 ++- packages/@aws-cdk/aws-appconfig/.npmignore | 3 ++- packages/@aws-cdk/aws-appflow/.npmignore | 3 ++- .../aws-applicationautoscaling/.npmignore | 3 ++- .../@aws-cdk/aws-applicationinsights/.npmignore | 2 ++ packages/@aws-cdk/aws-appmesh/.npmignore | 3 ++- packages/@aws-cdk/aws-appstream/.npmignore | 3 ++- packages/@aws-cdk/aws-appsync/.npmignore | 3 ++- packages/@aws-cdk/aws-athena/.npmignore | 3 ++- .../@aws-cdk/aws-autoscaling-common/.npmignore | 3 ++- .../aws-autoscaling-hooktargets/.npmignore | 3 ++- packages/@aws-cdk/aws-autoscaling/.npmignore | 3 ++- packages/@aws-cdk/aws-autoscalingplans/.npmignore | 3 ++- packages/@aws-cdk/aws-backup/.npmignore | 3 ++- packages/@aws-cdk/aws-batch/.npmignore | 3 ++- packages/@aws-cdk/aws-budgets/.npmignore | 3 ++- packages/@aws-cdk/aws-cassandra/.npmignore | 3 ++- packages/@aws-cdk/aws-ce/.npmignore | 3 ++- .../@aws-cdk/aws-certificatemanager/.npmignore | 2 ++ packages/@aws-cdk/aws-chatbot/.npmignore | 3 ++- packages/@aws-cdk/aws-cloud9/.npmignore | 3 ++- packages/@aws-cdk/aws-cloudformation/.npmignore | 3 ++- .../@aws-cdk/aws-cloudfront-origins/.npmignore | 3 ++- packages/@aws-cdk/aws-cloudfront/.npmignore | 3 ++- packages/@aws-cdk/aws-cloudtrail/.npmignore | 3 ++- .../@aws-cdk/aws-cloudwatch-actions/.npmignore | 3 ++- packages/@aws-cdk/aws-cloudwatch/.npmignore | 3 ++- packages/@aws-cdk/aws-codebuild/.npmignore | 3 ++- packages/@aws-cdk/aws-codecommit/.npmignore | 3 ++- packages/@aws-cdk/aws-codedeploy/.npmignore | 3 ++- packages/@aws-cdk/aws-codeguruprofiler/.npmignore | 3 ++- packages/@aws-cdk/aws-codegurureviewer/.npmignore | 2 ++ .../@aws-cdk/aws-codepipeline-actions/.npmignore | 3 ++- packages/@aws-cdk/aws-codepipeline/.npmignore | 2 ++ packages/@aws-cdk/aws-codestar/.npmignore | 3 ++- .../@aws-cdk/aws-codestarconnections/.npmignore | 3 ++- .../@aws-cdk/aws-codestarnotifications/.npmignore | 3 ++- packages/@aws-cdk/aws-cognito/.npmignore | 3 ++- packages/@aws-cdk/aws-config/.npmignore | 3 ++- packages/@aws-cdk/aws-datapipeline/.npmignore | 3 ++- packages/@aws-cdk/aws-dax/.npmignore | 3 ++- packages/@aws-cdk/aws-detective/.npmignore | 3 ++- packages/@aws-cdk/aws-directoryservice/.npmignore | 3 ++- packages/@aws-cdk/aws-dlm/.npmignore | 3 ++- packages/@aws-cdk/aws-dms/.npmignore | 3 ++- packages/@aws-cdk/aws-docdb/.npmignore | 3 ++- packages/@aws-cdk/aws-dynamodb-global/.npmignore | 3 ++- packages/@aws-cdk/aws-dynamodb/.npmignore | 3 ++- packages/@aws-cdk/aws-ec2/.npmignore | 3 ++- packages/@aws-cdk/aws-ecr-assets/.npmignore | 3 ++- packages/@aws-cdk/aws-ecr/.npmignore | 3 ++- packages/@aws-cdk/aws-ecs-patterns/.npmignore | 3 ++- packages/@aws-cdk/aws-ecs/.npmignore | 3 ++- packages/@aws-cdk/aws-efs/.npmignore | 3 ++- packages/@aws-cdk/aws-eks-legacy/.npmignore | 3 ++- packages/@aws-cdk/aws-eks/.npmignore | 3 ++- packages/@aws-cdk/aws-elasticache/.npmignore | 3 ++- packages/@aws-cdk/aws-elasticbeanstalk/.npmignore | 3 ++- .../@aws-cdk/aws-elasticloadbalancing/.npmignore | 2 ++ .../aws-elasticloadbalancingv2-actions/.npmignore | 3 ++- .../aws-elasticloadbalancingv2-targets/.npmignore | 3 ++- .../aws-elasticloadbalancingv2/.npmignore | 2 ++ packages/@aws-cdk/aws-elasticsearch/.npmignore | 3 ++- packages/@aws-cdk/aws-emr/.npmignore | 3 ++- packages/@aws-cdk/aws-events-targets/.npmignore | 3 ++- packages/@aws-cdk/aws-events/.npmignore | 3 ++- packages/@aws-cdk/aws-eventschemas/.npmignore | 3 ++- packages/@aws-cdk/aws-fms/.npmignore | 3 ++- packages/@aws-cdk/aws-fsx/.npmignore | 3 ++- packages/@aws-cdk/aws-gamelift/.npmignore | 3 ++- .../@aws-cdk/aws-globalaccelerator/.npmignore | 3 ++- packages/@aws-cdk/aws-glue/.npmignore | 3 ++- packages/@aws-cdk/aws-greengrass/.npmignore | 3 ++- packages/@aws-cdk/aws-guardduty/.npmignore | 3 ++- packages/@aws-cdk/aws-iam/.npmignore | 3 ++- packages/@aws-cdk/aws-imagebuilder/.npmignore | 3 ++- packages/@aws-cdk/aws-inspector/.npmignore | 3 ++- packages/@aws-cdk/aws-iot/.npmignore | 3 ++- packages/@aws-cdk/aws-iot1click/.npmignore | 3 ++- packages/@aws-cdk/aws-iotanalytics/.npmignore | 3 ++- packages/@aws-cdk/aws-iotevents/.npmignore | 3 ++- packages/@aws-cdk/aws-iotthingsgraph/.npmignore | 3 ++- packages/@aws-cdk/aws-kendra/.npmignore | 2 ++ packages/@aws-cdk/aws-kinesis/.npmignore | 3 ++- packages/@aws-cdk/aws-kinesisanalytics/.npmignore | 3 ++- packages/@aws-cdk/aws-kinesisfirehose/.npmignore | 3 ++- packages/@aws-cdk/aws-kms/.npmignore | 3 ++- packages/@aws-cdk/aws-lakeformation/.npmignore | 3 ++- .../@aws-cdk/aws-lambda-destinations/.npmignore | 3 ++- .../@aws-cdk/aws-lambda-event-sources/.npmignore | 3 ++- packages/@aws-cdk/aws-lambda-nodejs/.npmignore | 3 ++- packages/@aws-cdk/aws-lambda-python/.npmignore | 2 ++ packages/@aws-cdk/aws-lambda/.npmignore | 3 ++- .../@aws-cdk/aws-logs-destinations/.npmignore | 3 ++- packages/@aws-cdk/aws-logs/.npmignore | 3 ++- packages/@aws-cdk/aws-macie/.npmignore | 3 ++- .../@aws-cdk/aws-managedblockchain/.npmignore | 3 ++- packages/@aws-cdk/aws-mediaconvert/.npmignore | 3 ++- packages/@aws-cdk/aws-medialive/.npmignore | 3 ++- packages/@aws-cdk/aws-mediastore/.npmignore | 3 ++- packages/@aws-cdk/aws-msk/.npmignore | 3 ++- packages/@aws-cdk/aws-neptune/.npmignore | 3 ++- packages/@aws-cdk/aws-networkmanager/.npmignore | 3 ++- packages/@aws-cdk/aws-opsworks/.npmignore | 3 ++- packages/@aws-cdk/aws-opsworkscm/.npmignore | 3 ++- packages/@aws-cdk/aws-pinpoint/.npmignore | 3 ++- packages/@aws-cdk/aws-pinpointemail/.npmignore | 3 ++- packages/@aws-cdk/aws-qldb/.npmignore | 3 ++- packages/@aws-cdk/aws-ram/.npmignore | 3 ++- packages/@aws-cdk/aws-rds/.npmignore | 3 ++- packages/@aws-cdk/aws-redshift/.npmignore | 3 ++- packages/@aws-cdk/aws-resourcegroups/.npmignore | 3 ++- packages/@aws-cdk/aws-robomaker/.npmignore | 3 ++- packages/@aws-cdk/aws-route53-patterns/.npmignore | 3 ++- packages/@aws-cdk/aws-route53-targets/.npmignore | 3 ++- packages/@aws-cdk/aws-route53/.npmignore | 3 ++- packages/@aws-cdk/aws-route53resolver/.npmignore | 3 ++- packages/@aws-cdk/aws-s3-assets/.npmignore | 3 ++- packages/@aws-cdk/aws-s3-deployment/.npmignore | 3 ++- packages/@aws-cdk/aws-s3-notifications/.npmignore | 3 ++- packages/@aws-cdk/aws-s3/.npmignore | 3 ++- packages/@aws-cdk/aws-sagemaker/.npmignore | 3 ++- packages/@aws-cdk/aws-sam/.npmignore | 3 ++- packages/@aws-cdk/aws-sdb/.npmignore | 3 ++- packages/@aws-cdk/aws-secretsmanager/.npmignore | 3 ++- packages/@aws-cdk/aws-securityhub/.npmignore | 3 ++- packages/@aws-cdk/aws-servicecatalog/.npmignore | 3 ++- packages/@aws-cdk/aws-servicediscovery/.npmignore | 3 ++- packages/@aws-cdk/aws-ses-actions/.npmignore | 3 ++- packages/@aws-cdk/aws-ses/.npmignore | 3 ++- .../@aws-cdk/aws-sns-subscriptions/.npmignore | 3 ++- packages/@aws-cdk/aws-sns/.npmignore | 3 ++- packages/@aws-cdk/aws-sqs/.npmignore | 3 ++- packages/@aws-cdk/aws-ssm/.npmignore | 3 ++- packages/@aws-cdk/aws-sso/.npmignore | 2 ++ .../@aws-cdk/aws-stepfunctions-tasks/.npmignore | 3 ++- packages/@aws-cdk/aws-stepfunctions/.npmignore | 3 ++- packages/@aws-cdk/aws-synthetics/.npmignore | 3 ++- packages/@aws-cdk/aws-transfer/.npmignore | 3 ++- packages/@aws-cdk/aws-waf/.npmignore | 3 ++- packages/@aws-cdk/aws-wafregional/.npmignore | 3 ++- packages/@aws-cdk/aws-wafv2/.npmignore | 3 ++- packages/@aws-cdk/aws-workspaces/.npmignore | 3 ++- packages/@aws-cdk/cdk-assets-schema/.npmignore | 3 ++- .../@aws-cdk/cloud-assembly-schema/.npmignore | 3 ++- packages/@aws-cdk/cloudformation-diff/.npmignore | 3 ++- .../@aws-cdk/cloudformation-include/.npmignore | 3 ++- packages/@aws-cdk/core/.npmignore | 3 ++- packages/@aws-cdk/custom-resources/.npmignore | 3 ++- packages/@aws-cdk/cx-api/.npmignore | 3 ++- packages/@aws-cdk/pipelines/.npmignore | 1 + packages/@aws-cdk/region-info/.npmignore | 3 ++- packages/@aws-cdk/yaml-cfn/.npmignore | 3 ++- .../rewrite-imports/.npmignore | 3 ++- packages/awslint/.npmignore | 3 ++- packages/cdk-assets/.npmignore | 3 ++- packages/monocdk-experiment/.npmignore | 3 ++- tools/pkglint/lib/rules.ts | 15 +++++++++++++++ tools/ubergen/package.json | 4 ++-- 170 files changed, 351 insertions(+), 159 deletions(-) diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/.npmignore b/packages/@aws-cdk-containers/ecs-service-extensions/.npmignore index 913c96cd9ae15..722d4070cdc1f 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/.npmignore +++ b/packages/@aws-cdk-containers/ecs-service-extensions/.npmignore @@ -22,3 +22,5 @@ tsconfig.json **/cdk.out junit.xml + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/package.json b/packages/@aws-cdk-containers/ecs-service-extensions/package.json index 31af1ded594ec..41d80ae3884a9 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/package.json +++ b/packages/@aws-cdk-containers/ecs-service-extensions/package.json @@ -95,4 +95,4 @@ }, "maturity": "experimental", "stability": "experimental" -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/alexa-ask/.npmignore b/packages/@aws-cdk/alexa-ask/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/alexa-ask/.npmignore +++ b/packages/@aws-cdk/alexa-ask/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/app-delivery/.npmignore b/packages/@aws-cdk/app-delivery/.npmignore index 82e007c2c1c49..d04129afefc48 100644 --- a/packages/@aws-cdk/app-delivery/.npmignore +++ b/packages/@aws-cdk/app-delivery/.npmignore @@ -20,4 +20,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/assert/.npmignore b/packages/@aws-cdk/assert/.npmignore index 582a6ea324723..6f149ce45fddd 100644 --- a/packages/@aws-cdk/assert/.npmignore +++ b/packages/@aws-cdk/assert/.npmignore @@ -18,4 +18,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/assets/.npmignore b/packages/@aws-cdk/assets/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/assets/.npmignore +++ b/packages/@aws-cdk/assets/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-accessanalyzer/.npmignore b/packages/@aws-cdk/aws-accessanalyzer/.npmignore index a7c5b49852b3b..c2827f80c26db 100644 --- a/packages/@aws-cdk/aws-accessanalyzer/.npmignore +++ b/packages/@aws-cdk/aws-accessanalyzer/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-acmpca/.npmignore b/packages/@aws-cdk/aws-acmpca/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-acmpca/.npmignore +++ b/packages/@aws-cdk/aws-acmpca/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amazonmq/.npmignore b/packages/@aws-cdk/aws-amazonmq/.npmignore index 3dffd1ce79a72..2892fc6e99416 100644 --- a/packages/@aws-cdk/aws-amazonmq/.npmignore +++ b/packages/@aws-cdk/aws-amazonmq/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/.npmignore b/packages/@aws-cdk/aws-amplify/.npmignore index 917201c845418..f3eaded585e2d 100644 --- a/packages/@aws-cdk/aws-amplify/.npmignore +++ b/packages/@aws-cdk/aws-amplify/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/.npmignore b/packages/@aws-cdk/aws-apigateway/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-apigateway/.npmignore +++ b/packages/@aws-cdk/aws-apigateway/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigatewayv2/.npmignore b/packages/@aws-cdk/aws-apigatewayv2/.npmignore index e9418d013ad1f..093c734b1bd2f 100644 --- a/packages/@aws-cdk/aws-apigatewayv2/.npmignore +++ b/packages/@aws-cdk/aws-apigatewayv2/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appconfig/.npmignore b/packages/@aws-cdk/aws-appconfig/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-appconfig/.npmignore +++ b/packages/@aws-cdk/aws-appconfig/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appflow/.npmignore b/packages/@aws-cdk/aws-appflow/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-appflow/.npmignore +++ b/packages/@aws-cdk/aws-appflow/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-applicationautoscaling/.npmignore b/packages/@aws-cdk/aws-applicationautoscaling/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/.npmignore +++ b/packages/@aws-cdk/aws-applicationautoscaling/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-applicationinsights/.npmignore b/packages/@aws-cdk/aws-applicationinsights/.npmignore index 7633957caec65..9c086d15db4aa 100644 --- a/packages/@aws-cdk/aws-applicationinsights/.npmignore +++ b/packages/@aws-cdk/aws-applicationinsights/.npmignore @@ -25,3 +25,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out junit.xml + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appmesh/.npmignore b/packages/@aws-cdk/aws-appmesh/.npmignore index f937500da09a6..305e5b0db6ec1 100644 --- a/packages/@aws-cdk/aws-appmesh/.npmignore +++ b/packages/@aws-cdk/aws-appmesh/.npmignore @@ -25,4 +25,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appstream/.npmignore b/packages/@aws-cdk/aws-appstream/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-appstream/.npmignore +++ b/packages/@aws-cdk/aws-appstream/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appsync/.npmignore b/packages/@aws-cdk/aws-appsync/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-appsync/.npmignore +++ b/packages/@aws-cdk/aws-appsync/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-athena/.npmignore b/packages/@aws-cdk/aws-athena/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-athena/.npmignore +++ b/packages/@aws-cdk/aws-athena/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling-common/.npmignore b/packages/@aws-cdk/aws-autoscaling-common/.npmignore index b0d6aa6c90bf1..500c9f6884d44 100644 --- a/packages/@aws-cdk/aws-autoscaling-common/.npmignore +++ b/packages/@aws-cdk/aws-autoscaling-common/.npmignore @@ -25,4 +25,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling-hooktargets/.npmignore b/packages/@aws-cdk/aws-autoscaling-hooktargets/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-autoscaling-hooktargets/.npmignore +++ b/packages/@aws-cdk/aws-autoscaling-hooktargets/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/.npmignore b/packages/@aws-cdk/aws-autoscaling/.npmignore index 5d8f93d8a9c7e..6b3aee5fcab7c 100644 --- a/packages/@aws-cdk/aws-autoscaling/.npmignore +++ b/packages/@aws-cdk/aws-autoscaling/.npmignore @@ -23,4 +23,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out jest.config.js -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscalingplans/.npmignore b/packages/@aws-cdk/aws-autoscalingplans/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-autoscalingplans/.npmignore +++ b/packages/@aws-cdk/aws-autoscalingplans/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-backup/.npmignore b/packages/@aws-cdk/aws-backup/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-backup/.npmignore +++ b/packages/@aws-cdk/aws-backup/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/.npmignore b/packages/@aws-cdk/aws-batch/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-batch/.npmignore +++ b/packages/@aws-cdk/aws-batch/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-budgets/.npmignore b/packages/@aws-cdk/aws-budgets/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-budgets/.npmignore +++ b/packages/@aws-cdk/aws-budgets/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cassandra/.npmignore b/packages/@aws-cdk/aws-cassandra/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-cassandra/.npmignore +++ b/packages/@aws-cdk/aws-cassandra/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ce/.npmignore b/packages/@aws-cdk/aws-ce/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-ce/.npmignore +++ b/packages/@aws-cdk/aws-ce/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-certificatemanager/.npmignore b/packages/@aws-cdk/aws-certificatemanager/.npmignore index 0a336369a6bfb..8ace99e984f5a 100644 --- a/packages/@aws-cdk/aws-certificatemanager/.npmignore +++ b/packages/@aws-cdk/aws-certificatemanager/.npmignore @@ -27,3 +27,5 @@ tsconfig.json **/cdk.out junit.xml jest.config.js + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-chatbot/.npmignore b/packages/@aws-cdk/aws-chatbot/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-chatbot/.npmignore +++ b/packages/@aws-cdk/aws-chatbot/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloud9/.npmignore b/packages/@aws-cdk/aws-cloud9/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-cloud9/.npmignore +++ b/packages/@aws-cdk/aws-cloud9/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudformation/.npmignore b/packages/@aws-cdk/aws-cloudformation/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-cloudformation/.npmignore +++ b/packages/@aws-cdk/aws-cloudformation/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudfront-origins/.npmignore b/packages/@aws-cdk/aws-cloudfront-origins/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/.npmignore +++ b/packages/@aws-cdk/aws-cloudfront-origins/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudfront/.npmignore b/packages/@aws-cdk/aws-cloudfront/.npmignore index cccec9064cc31..fccf7d5aa28df 100644 --- a/packages/@aws-cdk/aws-cloudfront/.npmignore +++ b/packages/@aws-cdk/aws-cloudfront/.npmignore @@ -25,4 +25,5 @@ tsconfig.json **/cdk.out jest.config.js -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudtrail/.npmignore b/packages/@aws-cdk/aws-cloudtrail/.npmignore index 34633f72bca87..f507135a52f29 100644 --- a/packages/@aws-cdk/aws-cloudtrail/.npmignore +++ b/packages/@aws-cdk/aws-cloudtrail/.npmignore @@ -23,4 +23,5 @@ tsconfig.json jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudwatch-actions/.npmignore b/packages/@aws-cdk/aws-cloudwatch-actions/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-cloudwatch-actions/.npmignore +++ b/packages/@aws-cdk/aws-cloudwatch-actions/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudwatch/.npmignore b/packages/@aws-cdk/aws-cloudwatch/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-cloudwatch/.npmignore +++ b/packages/@aws-cdk/aws-cloudwatch/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codebuild/.npmignore b/packages/@aws-cdk/aws-codebuild/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-codebuild/.npmignore +++ b/packages/@aws-cdk/aws-codebuild/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codecommit/.npmignore b/packages/@aws-cdk/aws-codecommit/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-codecommit/.npmignore +++ b/packages/@aws-cdk/aws-codecommit/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codedeploy/.npmignore b/packages/@aws-cdk/aws-codedeploy/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-codedeploy/.npmignore +++ b/packages/@aws-cdk/aws-codedeploy/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codeguruprofiler/.npmignore b/packages/@aws-cdk/aws-codeguruprofiler/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-codeguruprofiler/.npmignore +++ b/packages/@aws-cdk/aws-codeguruprofiler/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codegurureviewer/.npmignore b/packages/@aws-cdk/aws-codegurureviewer/.npmignore index 72b7fcab0a22a..7b8fb69082a0f 100644 --- a/packages/@aws-cdk/aws-codegurureviewer/.npmignore +++ b/packages/@aws-cdk/aws-codegurureviewer/.npmignore @@ -24,3 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out junit.xml + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline-actions/.npmignore b/packages/@aws-cdk/aws-codepipeline-actions/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/.npmignore +++ b/packages/@aws-cdk/aws-codepipeline-actions/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline/.npmignore b/packages/@aws-cdk/aws-codepipeline/.npmignore index b70bd617fba2d..1b4217fb1a9f0 100644 --- a/packages/@aws-cdk/aws-codepipeline/.npmignore +++ b/packages/@aws-cdk/aws-codepipeline/.npmignore @@ -24,3 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out junit.xml + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codestar/.npmignore b/packages/@aws-cdk/aws-codestar/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-codestar/.npmignore +++ b/packages/@aws-cdk/aws-codestar/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codestarconnections/.npmignore b/packages/@aws-cdk/aws-codestarconnections/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-codestarconnections/.npmignore +++ b/packages/@aws-cdk/aws-codestarconnections/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codestarnotifications/.npmignore b/packages/@aws-cdk/aws-codestarnotifications/.npmignore index a7c5b49852b3b..c2827f80c26db 100644 --- a/packages/@aws-cdk/aws-codestarnotifications/.npmignore +++ b/packages/@aws-cdk/aws-codestarnotifications/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cognito/.npmignore b/packages/@aws-cdk/aws-cognito/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-cognito/.npmignore +++ b/packages/@aws-cdk/aws-cognito/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-config/.npmignore b/packages/@aws-cdk/aws-config/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-config/.npmignore +++ b/packages/@aws-cdk/aws-config/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-datapipeline/.npmignore b/packages/@aws-cdk/aws-datapipeline/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-datapipeline/.npmignore +++ b/packages/@aws-cdk/aws-datapipeline/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dax/.npmignore b/packages/@aws-cdk/aws-dax/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-dax/.npmignore +++ b/packages/@aws-cdk/aws-dax/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-detective/.npmignore b/packages/@aws-cdk/aws-detective/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-detective/.npmignore +++ b/packages/@aws-cdk/aws-detective/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-directoryservice/.npmignore b/packages/@aws-cdk/aws-directoryservice/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-directoryservice/.npmignore +++ b/packages/@aws-cdk/aws-directoryservice/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dlm/.npmignore b/packages/@aws-cdk/aws-dlm/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-dlm/.npmignore +++ b/packages/@aws-cdk/aws-dlm/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dms/.npmignore b/packages/@aws-cdk/aws-dms/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-dms/.npmignore +++ b/packages/@aws-cdk/aws-dms/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-docdb/.npmignore b/packages/@aws-cdk/aws-docdb/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-docdb/.npmignore +++ b/packages/@aws-cdk/aws-docdb/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dynamodb-global/.npmignore b/packages/@aws-cdk/aws-dynamodb-global/.npmignore index e418511182841..ecc7155058048 100644 --- a/packages/@aws-cdk/aws-dynamodb-global/.npmignore +++ b/packages/@aws-cdk/aws-dynamodb-global/.npmignore @@ -23,4 +23,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dynamodb/.npmignore b/packages/@aws-cdk/aws-dynamodb/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-dynamodb/.npmignore +++ b/packages/@aws-cdk/aws-dynamodb/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/.npmignore b/packages/@aws-cdk/aws-ec2/.npmignore index 5d8f93d8a9c7e..6b3aee5fcab7c 100644 --- a/packages/@aws-cdk/aws-ec2/.npmignore +++ b/packages/@aws-cdk/aws-ec2/.npmignore @@ -23,4 +23,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out jest.config.js -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecr-assets/.npmignore b/packages/@aws-cdk/aws-ecr-assets/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-ecr-assets/.npmignore +++ b/packages/@aws-cdk/aws-ecr-assets/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecr/.npmignore b/packages/@aws-cdk/aws-ecr/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-ecr/.npmignore +++ b/packages/@aws-cdk/aws-ecr/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs-patterns/.npmignore b/packages/@aws-cdk/aws-ecs-patterns/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/.npmignore +++ b/packages/@aws-cdk/aws-ecs-patterns/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/.npmignore b/packages/@aws-cdk/aws-ecs/.npmignore index d683303ca5c16..40fbede1f02dc 100644 --- a/packages/@aws-cdk/aws-ecs/.npmignore +++ b/packages/@aws-cdk/aws-ecs/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-efs/.npmignore b/packages/@aws-cdk/aws-efs/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-efs/.npmignore +++ b/packages/@aws-cdk/aws-efs/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks-legacy/.npmignore b/packages/@aws-cdk/aws-eks-legacy/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-eks-legacy/.npmignore +++ b/packages/@aws-cdk/aws-eks-legacy/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks/.npmignore b/packages/@aws-cdk/aws-eks/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-eks/.npmignore +++ b/packages/@aws-cdk/aws-eks/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticache/.npmignore b/packages/@aws-cdk/aws-elasticache/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-elasticache/.npmignore +++ b/packages/@aws-cdk/aws-elasticache/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticbeanstalk/.npmignore b/packages/@aws-cdk/aws-elasticbeanstalk/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-elasticbeanstalk/.npmignore +++ b/packages/@aws-cdk/aws-elasticbeanstalk/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancing/.npmignore b/packages/@aws-cdk/aws-elasticloadbalancing/.npmignore index 1a36d0617073e..4a398e9d7d239 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancing/.npmignore +++ b/packages/@aws-cdk/aws-elasticloadbalancing/.npmignore @@ -24,3 +24,5 @@ tsconfig.json **/cdk.out junit.xml jest.config.js + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/.npmignore b/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/.npmignore index d7886d9208116..dffe09131a636 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/.npmignore +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2-actions/.npmignore @@ -22,4 +22,5 @@ tsconfig.json jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/.npmignore b/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/.npmignore index a0bf754e3cc79..c28149f1ec41d 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/.npmignore +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/.npmignore @@ -22,4 +22,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/.npmignore b/packages/@aws-cdk/aws-elasticloadbalancingv2/.npmignore index 1a36d0617073e..4a398e9d7d239 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/.npmignore +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/.npmignore @@ -24,3 +24,5 @@ tsconfig.json **/cdk.out junit.xml jest.config.js + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticsearch/.npmignore b/packages/@aws-cdk/aws-elasticsearch/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-elasticsearch/.npmignore +++ b/packages/@aws-cdk/aws-elasticsearch/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-emr/.npmignore b/packages/@aws-cdk/aws-emr/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-emr/.npmignore +++ b/packages/@aws-cdk/aws-emr/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events-targets/.npmignore b/packages/@aws-cdk/aws-events-targets/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-events-targets/.npmignore +++ b/packages/@aws-cdk/aws-events-targets/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/.npmignore b/packages/@aws-cdk/aws-events/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-events/.npmignore +++ b/packages/@aws-cdk/aws-events/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eventschemas/.npmignore b/packages/@aws-cdk/aws-eventschemas/.npmignore index a7c5b49852b3b..c2827f80c26db 100644 --- a/packages/@aws-cdk/aws-eventschemas/.npmignore +++ b/packages/@aws-cdk/aws-eventschemas/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-fms/.npmignore b/packages/@aws-cdk/aws-fms/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-fms/.npmignore +++ b/packages/@aws-cdk/aws-fms/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-fsx/.npmignore b/packages/@aws-cdk/aws-fsx/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-fsx/.npmignore +++ b/packages/@aws-cdk/aws-fsx/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/.npmignore b/packages/@aws-cdk/aws-gamelift/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-gamelift/.npmignore +++ b/packages/@aws-cdk/aws-gamelift/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-globalaccelerator/.npmignore b/packages/@aws-cdk/aws-globalaccelerator/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-globalaccelerator/.npmignore +++ b/packages/@aws-cdk/aws-globalaccelerator/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-glue/.npmignore b/packages/@aws-cdk/aws-glue/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-glue/.npmignore +++ b/packages/@aws-cdk/aws-glue/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-greengrass/.npmignore b/packages/@aws-cdk/aws-greengrass/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-greengrass/.npmignore +++ b/packages/@aws-cdk/aws-greengrass/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-guardduty/.npmignore b/packages/@aws-cdk/aws-guardduty/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-guardduty/.npmignore +++ b/packages/@aws-cdk/aws-guardduty/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iam/.npmignore b/packages/@aws-cdk/aws-iam/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-iam/.npmignore +++ b/packages/@aws-cdk/aws-iam/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-imagebuilder/.npmignore b/packages/@aws-cdk/aws-imagebuilder/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-imagebuilder/.npmignore +++ b/packages/@aws-cdk/aws-imagebuilder/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-inspector/.npmignore b/packages/@aws-cdk/aws-inspector/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-inspector/.npmignore +++ b/packages/@aws-cdk/aws-inspector/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iot/.npmignore b/packages/@aws-cdk/aws-iot/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-iot/.npmignore +++ b/packages/@aws-cdk/aws-iot/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iot1click/.npmignore b/packages/@aws-cdk/aws-iot1click/.npmignore index 3dffd1ce79a72..2892fc6e99416 100644 --- a/packages/@aws-cdk/aws-iot1click/.npmignore +++ b/packages/@aws-cdk/aws-iot1click/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iotanalytics/.npmignore b/packages/@aws-cdk/aws-iotanalytics/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-iotanalytics/.npmignore +++ b/packages/@aws-cdk/aws-iotanalytics/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iotevents/.npmignore b/packages/@aws-cdk/aws-iotevents/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-iotevents/.npmignore +++ b/packages/@aws-cdk/aws-iotevents/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iotthingsgraph/.npmignore b/packages/@aws-cdk/aws-iotthingsgraph/.npmignore index 917201c845418..f3eaded585e2d 100644 --- a/packages/@aws-cdk/aws-iotthingsgraph/.npmignore +++ b/packages/@aws-cdk/aws-iotthingsgraph/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kendra/.npmignore b/packages/@aws-cdk/aws-kendra/.npmignore index 72b7fcab0a22a..7b8fb69082a0f 100644 --- a/packages/@aws-cdk/aws-kendra/.npmignore +++ b/packages/@aws-cdk/aws-kendra/.npmignore @@ -24,3 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out junit.xml + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kinesis/.npmignore b/packages/@aws-cdk/aws-kinesis/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-kinesis/.npmignore +++ b/packages/@aws-cdk/aws-kinesis/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kinesisanalytics/.npmignore b/packages/@aws-cdk/aws-kinesisanalytics/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-kinesisanalytics/.npmignore +++ b/packages/@aws-cdk/aws-kinesisanalytics/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kinesisfirehose/.npmignore b/packages/@aws-cdk/aws-kinesisfirehose/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-kinesisfirehose/.npmignore +++ b/packages/@aws-cdk/aws-kinesisfirehose/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kms/.npmignore b/packages/@aws-cdk/aws-kms/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-kms/.npmignore +++ b/packages/@aws-cdk/aws-kms/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lakeformation/.npmignore b/packages/@aws-cdk/aws-lakeformation/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-lakeformation/.npmignore +++ b/packages/@aws-cdk/aws-lakeformation/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-destinations/.npmignore b/packages/@aws-cdk/aws-lambda-destinations/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-lambda-destinations/.npmignore +++ b/packages/@aws-cdk/aws-lambda-destinations/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-event-sources/.npmignore b/packages/@aws-cdk/aws-lambda-event-sources/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/.npmignore +++ b/packages/@aws-cdk/aws-lambda-event-sources/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-nodejs/.npmignore b/packages/@aws-cdk/aws-lambda-nodejs/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/.npmignore +++ b/packages/@aws-cdk/aws-lambda-nodejs/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-python/.npmignore b/packages/@aws-cdk/aws-lambda-python/.npmignore index b70bd617fba2d..1b4217fb1a9f0 100644 --- a/packages/@aws-cdk/aws-lambda-python/.npmignore +++ b/packages/@aws-cdk/aws-lambda-python/.npmignore @@ -24,3 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out junit.xml + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/.npmignore b/packages/@aws-cdk/aws-lambda/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-lambda/.npmignore +++ b/packages/@aws-cdk/aws-lambda/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-logs-destinations/.npmignore b/packages/@aws-cdk/aws-logs-destinations/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-logs-destinations/.npmignore +++ b/packages/@aws-cdk/aws-logs-destinations/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-logs/.npmignore b/packages/@aws-cdk/aws-logs/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-logs/.npmignore +++ b/packages/@aws-cdk/aws-logs/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-macie/.npmignore b/packages/@aws-cdk/aws-macie/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-macie/.npmignore +++ b/packages/@aws-cdk/aws-macie/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-managedblockchain/.npmignore b/packages/@aws-cdk/aws-managedblockchain/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-managedblockchain/.npmignore +++ b/packages/@aws-cdk/aws-managedblockchain/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-mediaconvert/.npmignore b/packages/@aws-cdk/aws-mediaconvert/.npmignore index a7c5b49852b3b..c2827f80c26db 100644 --- a/packages/@aws-cdk/aws-mediaconvert/.npmignore +++ b/packages/@aws-cdk/aws-mediaconvert/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-medialive/.npmignore b/packages/@aws-cdk/aws-medialive/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-medialive/.npmignore +++ b/packages/@aws-cdk/aws-medialive/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-mediastore/.npmignore b/packages/@aws-cdk/aws-mediastore/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-mediastore/.npmignore +++ b/packages/@aws-cdk/aws-mediastore/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk/.npmignore b/packages/@aws-cdk/aws-msk/.npmignore index 917201c845418..f3eaded585e2d 100644 --- a/packages/@aws-cdk/aws-msk/.npmignore +++ b/packages/@aws-cdk/aws-msk/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-neptune/.npmignore b/packages/@aws-cdk/aws-neptune/.npmignore index 3dffd1ce79a72..2892fc6e99416 100644 --- a/packages/@aws-cdk/aws-neptune/.npmignore +++ b/packages/@aws-cdk/aws-neptune/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-networkmanager/.npmignore b/packages/@aws-cdk/aws-networkmanager/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-networkmanager/.npmignore +++ b/packages/@aws-cdk/aws-networkmanager/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-opsworks/.npmignore b/packages/@aws-cdk/aws-opsworks/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-opsworks/.npmignore +++ b/packages/@aws-cdk/aws-opsworks/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-opsworkscm/.npmignore b/packages/@aws-cdk/aws-opsworkscm/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-opsworkscm/.npmignore +++ b/packages/@aws-cdk/aws-opsworkscm/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-pinpoint/.npmignore b/packages/@aws-cdk/aws-pinpoint/.npmignore index 917201c845418..f3eaded585e2d 100644 --- a/packages/@aws-cdk/aws-pinpoint/.npmignore +++ b/packages/@aws-cdk/aws-pinpoint/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-pinpointemail/.npmignore b/packages/@aws-cdk/aws-pinpointemail/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-pinpointemail/.npmignore +++ b/packages/@aws-cdk/aws-pinpointemail/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-qldb/.npmignore b/packages/@aws-cdk/aws-qldb/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-qldb/.npmignore +++ b/packages/@aws-cdk/aws-qldb/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ram/.npmignore b/packages/@aws-cdk/aws-ram/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-ram/.npmignore +++ b/packages/@aws-cdk/aws-ram/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/.npmignore b/packages/@aws-cdk/aws-rds/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-rds/.npmignore +++ b/packages/@aws-cdk/aws-rds/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/.npmignore b/packages/@aws-cdk/aws-redshift/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-redshift/.npmignore +++ b/packages/@aws-cdk/aws-redshift/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-resourcegroups/.npmignore b/packages/@aws-cdk/aws-resourcegroups/.npmignore index c8874799485a3..5bd978c36b820 100644 --- a/packages/@aws-cdk/aws-resourcegroups/.npmignore +++ b/packages/@aws-cdk/aws-resourcegroups/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-robomaker/.npmignore b/packages/@aws-cdk/aws-robomaker/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-robomaker/.npmignore +++ b/packages/@aws-cdk/aws-robomaker/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53-patterns/.npmignore b/packages/@aws-cdk/aws-route53-patterns/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-route53-patterns/.npmignore +++ b/packages/@aws-cdk/aws-route53-patterns/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53-targets/.npmignore b/packages/@aws-cdk/aws-route53-targets/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-route53-targets/.npmignore +++ b/packages/@aws-cdk/aws-route53-targets/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53/.npmignore b/packages/@aws-cdk/aws-route53/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-route53/.npmignore +++ b/packages/@aws-cdk/aws-route53/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53resolver/.npmignore b/packages/@aws-cdk/aws-route53resolver/.npmignore index ab90672b1d91e..207e92300ba4a 100644 --- a/packages/@aws-cdk/aws-route53resolver/.npmignore +++ b/packages/@aws-cdk/aws-route53resolver/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3-assets/.npmignore b/packages/@aws-cdk/aws-s3-assets/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-s3-assets/.npmignore +++ b/packages/@aws-cdk/aws-s3-assets/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3-deployment/.npmignore b/packages/@aws-cdk/aws-s3-deployment/.npmignore index f1b35d10f16cf..6ed30427bcfa6 100644 --- a/packages/@aws-cdk/aws-s3-deployment/.npmignore +++ b/packages/@aws-cdk/aws-s3-deployment/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3-notifications/.npmignore b/packages/@aws-cdk/aws-s3-notifications/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-s3-notifications/.npmignore +++ b/packages/@aws-cdk/aws-s3-notifications/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3/.npmignore b/packages/@aws-cdk/aws-s3/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-s3/.npmignore +++ b/packages/@aws-cdk/aws-s3/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sagemaker/.npmignore b/packages/@aws-cdk/aws-sagemaker/.npmignore index 3ac7fc56cea02..142da412995b7 100644 --- a/packages/@aws-cdk/aws-sagemaker/.npmignore +++ b/packages/@aws-cdk/aws-sagemaker/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sam/.npmignore b/packages/@aws-cdk/aws-sam/.npmignore index 3dffd1ce79a72..2892fc6e99416 100644 --- a/packages/@aws-cdk/aws-sam/.npmignore +++ b/packages/@aws-cdk/aws-sam/.npmignore @@ -27,4 +27,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sdb/.npmignore b/packages/@aws-cdk/aws-sdb/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-sdb/.npmignore +++ b/packages/@aws-cdk/aws-sdb/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-secretsmanager/.npmignore b/packages/@aws-cdk/aws-secretsmanager/.npmignore index f937500da09a6..305e5b0db6ec1 100644 --- a/packages/@aws-cdk/aws-secretsmanager/.npmignore +++ b/packages/@aws-cdk/aws-secretsmanager/.npmignore @@ -25,4 +25,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-securityhub/.npmignore b/packages/@aws-cdk/aws-securityhub/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-securityhub/.npmignore +++ b/packages/@aws-cdk/aws-securityhub/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-servicecatalog/.npmignore b/packages/@aws-cdk/aws-servicecatalog/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-servicecatalog/.npmignore +++ b/packages/@aws-cdk/aws-servicecatalog/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-servicediscovery/.npmignore b/packages/@aws-cdk/aws-servicediscovery/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-servicediscovery/.npmignore +++ b/packages/@aws-cdk/aws-servicediscovery/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ses-actions/.npmignore b/packages/@aws-cdk/aws-ses-actions/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-ses-actions/.npmignore +++ b/packages/@aws-cdk/aws-ses-actions/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ses/.npmignore b/packages/@aws-cdk/aws-ses/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-ses/.npmignore +++ b/packages/@aws-cdk/aws-ses/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sns-subscriptions/.npmignore b/packages/@aws-cdk/aws-sns-subscriptions/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-sns-subscriptions/.npmignore +++ b/packages/@aws-cdk/aws-sns-subscriptions/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sns/.npmignore b/packages/@aws-cdk/aws-sns/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-sns/.npmignore +++ b/packages/@aws-cdk/aws-sns/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sqs/.npmignore b/packages/@aws-cdk/aws-sqs/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-sqs/.npmignore +++ b/packages/@aws-cdk/aws-sqs/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ssm/.npmignore b/packages/@aws-cdk/aws-ssm/.npmignore index 95a6e5fe5bb87..a94c531529866 100644 --- a/packages/@aws-cdk/aws-ssm/.npmignore +++ b/packages/@aws-cdk/aws-ssm/.npmignore @@ -22,4 +22,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sso/.npmignore b/packages/@aws-cdk/aws-sso/.npmignore index 72b7fcab0a22a..7b8fb69082a0f 100644 --- a/packages/@aws-cdk/aws-sso/.npmignore +++ b/packages/@aws-cdk/aws-sso/.npmignore @@ -24,3 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out junit.xml + +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/.npmignore b/packages/@aws-cdk/aws-stepfunctions-tasks/.npmignore index a0bf754e3cc79..c28149f1ec41d 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/.npmignore +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/.npmignore @@ -22,4 +22,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions/.npmignore b/packages/@aws-cdk/aws-stepfunctions/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-stepfunctions/.npmignore +++ b/packages/@aws-cdk/aws-stepfunctions/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-synthetics/.npmignore b/packages/@aws-cdk/aws-synthetics/.npmignore index 548b39048e917..b3858c23d8230 100644 --- a/packages/@aws-cdk/aws-synthetics/.npmignore +++ b/packages/@aws-cdk/aws-synthetics/.npmignore @@ -23,4 +23,5 @@ tsconfig.json jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-transfer/.npmignore b/packages/@aws-cdk/aws-transfer/.npmignore index 5c003cc4e3040..de98f3be1b6f4 100644 --- a/packages/@aws-cdk/aws-transfer/.npmignore +++ b/packages/@aws-cdk/aws-transfer/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-waf/.npmignore b/packages/@aws-cdk/aws-waf/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-waf/.npmignore +++ b/packages/@aws-cdk/aws-waf/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-wafregional/.npmignore b/packages/@aws-cdk/aws-wafregional/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-wafregional/.npmignore +++ b/packages/@aws-cdk/aws-wafregional/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-wafv2/.npmignore b/packages/@aws-cdk/aws-wafv2/.npmignore index a7c5b49852b3b..c2827f80c26db 100644 --- a/packages/@aws-cdk/aws-wafv2/.npmignore +++ b/packages/@aws-cdk/aws-wafv2/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/aws-workspaces/.npmignore b/packages/@aws-cdk/aws-workspaces/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/aws-workspaces/.npmignore +++ b/packages/@aws-cdk/aws-workspaces/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/cdk-assets-schema/.npmignore b/packages/@aws-cdk/cdk-assets-schema/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/cdk-assets-schema/.npmignore +++ b/packages/@aws-cdk/cdk-assets-schema/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/cloud-assembly-schema/.npmignore b/packages/@aws-cdk/cloud-assembly-schema/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/.npmignore +++ b/packages/@aws-cdk/cloud-assembly-schema/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/cloudformation-diff/.npmignore b/packages/@aws-cdk/cloudformation-diff/.npmignore index 582a6ea324723..6f149ce45fddd 100644 --- a/packages/@aws-cdk/cloudformation-diff/.npmignore +++ b/packages/@aws-cdk/cloudformation-diff/.npmignore @@ -18,4 +18,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/cloudformation-include/.npmignore b/packages/@aws-cdk/cloudformation-include/.npmignore index 5f0a7e632cc2b..89953b9a92f1b 100644 --- a/packages/@aws-cdk/cloudformation-include/.npmignore +++ b/packages/@aws-cdk/cloudformation-include/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/core/.npmignore b/packages/@aws-cdk/core/.npmignore index 90948e3dcecea..cab9567cc557d 100644 --- a/packages/@aws-cdk/core/.npmignore +++ b/packages/@aws-cdk/core/.npmignore @@ -26,4 +26,5 @@ tsconfig.json # exclude cdk artifacts **/cdk.out junit.xml -jest.config.js \ No newline at end of file +jest.config.js +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/custom-resources/.npmignore b/packages/@aws-cdk/custom-resources/.npmignore index 3b641cc6c559c..fcd1908ac39cb 100644 --- a/packages/@aws-cdk/custom-resources/.npmignore +++ b/packages/@aws-cdk/custom-resources/.npmignore @@ -24,4 +24,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/cx-api/.npmignore b/packages/@aws-cdk/cx-api/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/cx-api/.npmignore +++ b/packages/@aws-cdk/cx-api/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/pipelines/.npmignore b/packages/@aws-cdk/pipelines/.npmignore index 43090522285b1..8b1d5e48f3c78 100644 --- a/packages/@aws-cdk/pipelines/.npmignore +++ b/packages/@aws-cdk/pipelines/.npmignore @@ -25,3 +25,4 @@ tsconfig.json jest.config.js junit.xml package/node_modules +test/ diff --git a/packages/@aws-cdk/region-info/.npmignore b/packages/@aws-cdk/region-info/.npmignore index d32b63723f317..4e84b879a486f 100644 --- a/packages/@aws-cdk/region-info/.npmignore +++ b/packages/@aws-cdk/region-info/.npmignore @@ -21,4 +21,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@aws-cdk/yaml-cfn/.npmignore b/packages/@aws-cdk/yaml-cfn/.npmignore index bca0ae2513f1e..63ab95621c764 100644 --- a/packages/@aws-cdk/yaml-cfn/.npmignore +++ b/packages/@aws-cdk/yaml-cfn/.npmignore @@ -23,4 +23,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/@monocdk-experiment/rewrite-imports/.npmignore b/packages/@monocdk-experiment/rewrite-imports/.npmignore index 1a0946f499b8d..4a2955c9ce9f9 100644 --- a/packages/@monocdk-experiment/rewrite-imports/.npmignore +++ b/packages/@monocdk-experiment/rewrite-imports/.npmignore @@ -13,4 +13,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/awslint/.npmignore b/packages/awslint/.npmignore index dd1dbf2be01be..7cb354bd2b155 100644 --- a/packages/awslint/.npmignore +++ b/packages/awslint/.npmignore @@ -8,4 +8,5 @@ dist *.tsbuildinfo tsconfig.json .eslintrc.js -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/cdk-assets/.npmignore b/packages/cdk-assets/.npmignore index de7dfbff2926f..45b8808bdd7ac 100644 --- a/packages/cdk-assets/.npmignore +++ b/packages/cdk-assets/.npmignore @@ -26,4 +26,5 @@ jest.config.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/packages/monocdk-experiment/.npmignore b/packages/monocdk-experiment/.npmignore index b5bc540300d0f..eb24dc7eb2308 100644 --- a/packages/monocdk-experiment/.npmignore +++ b/packages/monocdk-experiment/.npmignore @@ -23,4 +23,5 @@ tsconfig.json .eslintrc.js # exclude cdk artifacts **/cdk.out -junit.xml \ No newline at end of file +junit.xml +test/ \ No newline at end of file diff --git a/tools/pkglint/lib/rules.ts b/tools/pkglint/lib/rules.ts index 77fce1a03d423..ca240dbd737e1 100644 --- a/tools/pkglint/lib/rules.ts +++ b/tools/pkglint/lib/rules.ts @@ -574,6 +574,21 @@ export class NoTsBuildInfo extends ValidationRule { } } +export class NoTestsInNpmPackage extends ValidationRule { + public readonly name = 'npmignore/test'; + + public validate(pkg: PackageJson): void { + // skip private packages + if (pkg.json.private) { return; } + + // Skip the CLI package, as its 'test' subdirectory is used at runtime. + if (pkg.packageName === 'aws-cdk') { return; } + + // Exclude 'test/' directories from being packaged + fileShouldContain(this.name, pkg, '.npmignore', 'test/'); + } +} + export class NoTsConfig extends ValidationRule { public readonly name = 'npmignore/tsconfig'; diff --git a/tools/ubergen/package.json b/tools/ubergen/package.json index 8e2e2e0eaa5a9..4698e84f54300 100644 --- a/tools/ubergen/package.json +++ b/tools/ubergen/package.json @@ -12,8 +12,8 @@ "ubergen": "bin/ubergen" }, "scripts": { - "build": "tsc -b && chmod +x bin/ubergen && eslint . --ext=.ts", - "watch": "tsc -b -w", + "build": "cdk-build", + "watch": "cdk-watch", "pkglint": "pkglint -f", "test": "echo success", "build+test+package": "npm run build+test", From 0297f31ef4224b374a340ba09eeafe963d62e789 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 6 Oct 2020 17:33:15 +0200 Subject: [PATCH 31/47] fix(pipelines): pipeline doesn't restart if CLI version changes (#10727) To fix, add the CLI version into the pipeline structure (as an environment variable to the CodePipeline project). Fixes #10659. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../lib/actions/publish-assets-action.ts | 4 +++ .../lib/actions/update-pipeline-action.ts | 4 +++ .../@aws-cdk/pipelines/test/pipeline.test.ts | 27 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/packages/@aws-cdk/pipelines/lib/actions/publish-assets-action.ts b/packages/@aws-cdk/pipelines/lib/actions/publish-assets-action.ts index 7e8b46b7a4503..1e2adadafb52d 100644 --- a/packages/@aws-cdk/pipelines/lib/actions/publish-assets-action.ts +++ b/packages/@aws-cdk/pipelines/lib/actions/publish-assets-action.ts @@ -137,6 +137,10 @@ export class PublishAssetsAction extends CoreConstruct implements codepipeline.I project, input: this.props.cloudAssemblyInput, role: props.role, + // Add this purely so that the pipeline will selfupdate if the CLI version changes + environmentVariables: props.cdkCliVersion ? { + CDK_CLI_VERSION: { value: props.cdkCliVersion }, + } : undefined, }); } diff --git a/packages/@aws-cdk/pipelines/lib/actions/update-pipeline-action.ts b/packages/@aws-cdk/pipelines/lib/actions/update-pipeline-action.ts index 9642fa7ba854e..20dce58246c27 100644 --- a/packages/@aws-cdk/pipelines/lib/actions/update-pipeline-action.ts +++ b/packages/@aws-cdk/pipelines/lib/actions/update-pipeline-action.ts @@ -93,6 +93,10 @@ export class UpdatePipelineAction extends CoreConstruct implements codepipeline. actionName: 'SelfMutate', input: props.cloudAssemblyInput, project: selfMutationProject, + // Add this purely so that the pipeline will selfupdate if the CLI version changes + environmentVariables: props.cdkCliVersion ? { + CDK_CLI_VERSION: { value: props.cdkCliVersion }, + } : undefined, }); } diff --git a/packages/@aws-cdk/pipelines/test/pipeline.test.ts b/packages/@aws-cdk/pipelines/test/pipeline.test.ts index 8fa56d50f3ea0..023f4bdcf575d 100644 --- a/packages/@aws-cdk/pipelines/test/pipeline.test.ts +++ b/packages/@aws-cdk/pipelines/test/pipeline.test.ts @@ -385,6 +385,33 @@ test('can control fix/CLI version used in pipeline selfupdate', () => { }); }); +test('changing CLI version leads to a different pipeline structure (restarting it)', () => { + // GIVEN + const stack2 = new Stack(app, 'Stack2', { env: PIPELINE_ENV }); + const stack3 = new Stack(app, 'Stack3', { env: PIPELINE_ENV }); + const structure2 = Capture.anyType(); + const structure3 = Capture.anyType(); + + // WHEN + new TestGitHubNpmPipeline(stack2, 'Cdk', { + cdkCliVersion: '1.2.3', + }); + new TestGitHubNpmPipeline(stack3, 'Cdk', { + cdkCliVersion: '4.5.6', + }); + + // THEN + expect(stack2).toHaveResourceLike('AWS::CodePipeline::Pipeline', { + Stages: structure2.capture(), + }); + expect(stack3).toHaveResourceLike('AWS::CodePipeline::Pipeline', { + Stages: structure3.capture(), + }); + + expect(JSON.stringify(structure2.capturedValue)).not.toEqual(JSON.stringify(structure3.capturedValue)); + +}); + test('add another action to an existing stage', () => { // WHEN pipeline.stage('Source').addAction(new cpa.GitHubSourceAction({ From c4fe4947e36f9f2cb7075add21d4f3b084246eab Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Tue, 6 Oct 2020 14:57:59 -0700 Subject: [PATCH 32/47] chore(monocdk-experiment): rename package name to monocdk (#10743) * chore(monocdk-experiment): rename package name to monocdk --- package.json | 24 +++++++++---------- .../@aws-cdk/cfnspec/build-tools/update.sh | 2 +- .../@monocdk-experiment/assert/package.json | 4 ++-- .../rewrite-imports/README.md | 2 +- .../rewrite-imports/lib/rewrite.ts | 4 ++-- .../rewrite-imports/package.json | 2 +- .../rewrite-imports/test/rewrite.test.ts | 8 +++---- .../.eslintrc.js | 0 .../.gitignore | 0 .../.npmignore | 0 .../{monocdk-experiment => monocdk}/LICENSE | 0 .../{monocdk-experiment => monocdk}/NOTICE | 0 .../{monocdk-experiment => monocdk}/README.md | 10 ++++---- .../package.json | 12 +++++----- tools/pkglint/lib/rules.ts | 2 +- 15 files changed, 35 insertions(+), 35 deletions(-) rename packages/{monocdk-experiment => monocdk}/.eslintrc.js (100%) rename packages/{monocdk-experiment => monocdk}/.gitignore (100%) rename packages/{monocdk-experiment => monocdk}/.npmignore (100%) rename packages/{monocdk-experiment => monocdk}/LICENSE (100%) rename packages/{monocdk-experiment => monocdk}/NOTICE (100%) rename packages/{monocdk-experiment => monocdk}/README.md (80%) rename packages/{monocdk-experiment => monocdk}/package.json (97%) diff --git a/package.json b/package.json index e9cc508495fa6..0e9d0006b5941 100644 --- a/package.json +++ b/package.json @@ -82,18 +82,18 @@ "aws-cdk-lib/semver/**", "aws-cdk-lib/yaml", "aws-cdk-lib/yaml/**", - "monocdk-experiment/case", - "monocdk-experiment/case/**", - "monocdk-experiment/fs-extra", - "monocdk-experiment/fs-extra/**", - "monocdk-experiment/jsonschema", - "monocdk-experiment/jsonschema/**", - "monocdk-experiment/minimatch", - "monocdk-experiment/minimatch/**", - "monocdk-experiment/semver", - "monocdk-experiment/semver/**", - "monocdk-experiment/yaml", - "monocdk-experiment/yaml/**" + "monocdk/case", + "monocdk/case/**", + "monocdk/fs-extra", + "monocdk/fs-extra/**", + "monocdk/jsonschema", + "monocdk/jsonschema/**", + "monocdk/minimatch", + "monocdk/minimatch/**", + "monocdk/semver", + "monocdk/semver/**", + "monocdk/yaml", + "monocdk/yaml/**" ] } } diff --git a/packages/@aws-cdk/cfnspec/build-tools/update.sh b/packages/@aws-cdk/cfnspec/build-tools/update.sh index 12dacedc5f5c2..684e46b35af53 100755 --- a/packages/@aws-cdk/cfnspec/build-tools/update.sh +++ b/packages/@aws-cdk/cfnspec/build-tools/update.sh @@ -71,7 +71,7 @@ node ${scriptdir}/create-missing-libraries.js || { # update decdk dep list (cd ${scriptdir}/../../../decdk && node ./deps.js || true) -(cd ${scriptdir}/../../../monocdk-experiment && yarn gen || true) +(cd ${scriptdir}/../../../monocdk && yarn gen || true) # append old changelog after new and replace as the last step because otherwise we will not be idempotent _changelog_contents=$(cat CHANGELOG.md.new) diff --git a/packages/@monocdk-experiment/assert/package.json b/packages/@monocdk-experiment/assert/package.json index bdfa792c68113..f5dc4ddfe584f 100644 --- a/packages/@monocdk-experiment/assert/package.json +++ b/packages/@monocdk-experiment/assert/package.json @@ -39,7 +39,7 @@ "cdk-build-tools": "0.0.0", "constructs": "^3.0.4", "jest": "^26.4.2", - "monocdk-experiment": "0.0.0", + "monocdk": "0.0.0", "pkglint": "0.0.0", "ts-jest": "^26.4.1" }, @@ -49,7 +49,7 @@ "peerDependencies": { "constructs": "^3.0.4", "jest": "^26.4.2", - "monocdk-experiment": "^0.0.0" + "monocdk": "^0.0.0" }, "repository": { "url": "https://github.com/aws/aws-cdk.git", diff --git a/packages/@monocdk-experiment/rewrite-imports/README.md b/packages/@monocdk-experiment/rewrite-imports/README.md index d4dd324816fac..1255d2913afb6 100644 --- a/packages/@monocdk-experiment/rewrite-imports/README.md +++ b/packages/@monocdk-experiment/rewrite-imports/README.md @@ -9,7 +9,7 @@ --- -Migrate TypeScript `import` statements from modular CDK (i.e. `@aws-cdk/aws-s3`) to mono-cdk (i.e. `monocdk-experiment/aws-s3`); +Migrate TypeScript `import` statements from modular CDK (i.e. `@aws-cdk/aws-s3`) to mono-cdk (i.e. `monocdk/aws-s3`); Usage: diff --git a/packages/@monocdk-experiment/rewrite-imports/lib/rewrite.ts b/packages/@monocdk-experiment/rewrite-imports/lib/rewrite.ts index f6dad5edbd89b..c0dd892cd6356 100644 --- a/packages/@monocdk-experiment/rewrite-imports/lib/rewrite.ts +++ b/packages/@monocdk-experiment/rewrite-imports/lib/rewrite.ts @@ -98,7 +98,7 @@ function updatedLocationOf(modulePath: string): string | undefined { } if (modulePath === '@aws-cdk/core') { - return 'monocdk-experiment'; + return 'monocdk'; } if (modulePath === '@aws-cdk/assert') { @@ -109,5 +109,5 @@ function updatedLocationOf(modulePath: string): string | undefined { return '@monocdk-experiment/assert/jest'; } - return `monocdk-experiment/${modulePath.substring(9)}`; + return `monocdk/${modulePath.substring(9)}`; } diff --git a/packages/@monocdk-experiment/rewrite-imports/package.json b/packages/@monocdk-experiment/rewrite-imports/package.json index ed39eee4544bd..683d6be64a2ee 100644 --- a/packages/@monocdk-experiment/rewrite-imports/package.json +++ b/packages/@monocdk-experiment/rewrite-imports/package.json @@ -1,7 +1,7 @@ { "name": "@monocdk-experiment/rewrite-imports", "version": "0.0.0", - "description": "Rewrites typescript 'import' statements from @aws-cdk/xxx to monocdk-experiment", + "description": "Rewrites typescript 'import' statements from @aws-cdk/xxx to monocdk", "bin": { "rewrite-imports": "bin/rewrite-imports" }, diff --git a/packages/@monocdk-experiment/rewrite-imports/test/rewrite.test.ts b/packages/@monocdk-experiment/rewrite-imports/test/rewrite.test.ts index 689efb72ef79b..d932b8f356964 100644 --- a/packages/@monocdk-experiment/rewrite-imports/test/rewrite.test.ts +++ b/packages/@monocdk-experiment/rewrite-imports/test/rewrite.test.ts @@ -45,9 +45,9 @@ describe(rewriteImports, () => { expect(output).toBe(` // something before - import * as s3 from 'monocdk-experiment/aws-s3'; + import * as s3 from 'monocdk/aws-s3'; import * as cfndiff from '@aws-cdk/cloudformation-diff'; - import { Construct } from "monocdk-experiment"; + import { Construct } from "monocdk"; // something after console.log('Look! I did something!');`); @@ -65,9 +65,9 @@ describe(rewriteImports, () => { expect(output).toBe(` // something before - import s3 = require('monocdk-experiment/aws-s3'); + import s3 = require('monocdk/aws-s3'); import cfndiff = require('@aws-cdk/cloudformation-diff'); - import { Construct } = require("monocdk-experiment"); + import { Construct } = require("monocdk"); // something after console.log('Look! I did something!');`); diff --git a/packages/monocdk-experiment/.eslintrc.js b/packages/monocdk/.eslintrc.js similarity index 100% rename from packages/monocdk-experiment/.eslintrc.js rename to packages/monocdk/.eslintrc.js diff --git a/packages/monocdk-experiment/.gitignore b/packages/monocdk/.gitignore similarity index 100% rename from packages/monocdk-experiment/.gitignore rename to packages/monocdk/.gitignore diff --git a/packages/monocdk-experiment/.npmignore b/packages/monocdk/.npmignore similarity index 100% rename from packages/monocdk-experiment/.npmignore rename to packages/monocdk/.npmignore diff --git a/packages/monocdk-experiment/LICENSE b/packages/monocdk/LICENSE similarity index 100% rename from packages/monocdk-experiment/LICENSE rename to packages/monocdk/LICENSE diff --git a/packages/monocdk-experiment/NOTICE b/packages/monocdk/NOTICE similarity index 100% rename from packages/monocdk-experiment/NOTICE rename to packages/monocdk/NOTICE diff --git a/packages/monocdk-experiment/README.md b/packages/monocdk/README.md similarity index 80% rename from packages/monocdk-experiment/README.md rename to packages/monocdk/README.md index a82945b85886e..fe98c56b654b1 100644 --- a/packages/monocdk-experiment/README.md +++ b/packages/monocdk/README.md @@ -11,9 +11,9 @@ An __experiment__ to bundle all of the CDK into a single module. ## Usage ### Installation -To try out `monocdk-experiment` replace all references to CDK Construct +To try out `monocdk` replace all references to CDK Construct Libraries (most `@aws-cdk/*` packages) in your `package.json` file with a single -entrey referring to `monocdk-experiment`. +entrey referring to `monocdk`. You also need to add a reference to the `constructs` library, according to the kind of project you are developing: @@ -27,7 +27,7 @@ kind of project you are developing: You can use a classic import to get access to each service namespaces: ```ts -import { core, aws_s3 as s3 } from 'monocdk-experiment'; +import { core, aws_s3 as s3 } from 'monocdk'; const app = new core.App(); const stack = new core.Stack(app, 'MonoCDK-Stack'); @@ -40,8 +40,8 @@ new s3.Bucket(stack, 'TestBucket'); Alternatively, you can use "barrel" imports: ```ts -import { App, Stack } from 'monocdk-experiment'; -import { Bucket } from 'monocdk-experiment/aws-s3'; +import { App, Stack } from 'monocdk'; +import { Bucket } from 'monocdk/aws-s3'; const app = new App(); const stack = new Stack(app, 'MonoCDK-Stack'); diff --git a/packages/monocdk-experiment/package.json b/packages/monocdk/package.json similarity index 97% rename from packages/monocdk-experiment/package.json rename to packages/monocdk/package.json index 14496548649c7..8366f1693d2c6 100644 --- a/packages/monocdk-experiment/package.json +++ b/packages/monocdk/package.json @@ -1,5 +1,5 @@ { - "name": "monocdk-experiment", + "name": "monocdk", "version": "0.0.0", "description": "An experiment to bundle the entire CDK into a single module", "main": "lib/index.js", @@ -7,7 +7,7 @@ "repository": { "type": "git", "url": "https://github.com/aws/aws-cdk.git", - "directory": "packages/monocdk-experiment" + "directory": "packages/monocdk" }, "stability": "experimental", "maturity": "developer-preview", @@ -52,7 +52,7 @@ "targets": { "dotnet": { "namespace": "Amazon.CDK", - "packageId": "Amazon.CDK.MonoCDK.Experiment", + "packageId": "Amazon.CDK.MonoCDK.", "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "versionSuffix": "-devpreview", "signAssembly": true, @@ -62,13 +62,13 @@ "package": "software.amazon.awscdk.core", "maven": { "groupId": "software.amazon.awscdk", - "artifactId": "monocdk-experiment", + "artifactId": "monocdk", "versionSuffix": ".DEVPREVIEW" } }, "python": { - "distName": "monocdk.experiment", - "module": "monocdk_experiment" + "distName": "monocdk", + "module": "monocdk" } }, "projectReferences": false diff --git a/tools/pkglint/lib/rules.ts b/tools/pkglint/lib/rules.ts index ca240dbd737e1..f04446df7e4a9 100644 --- a/tools/pkglint/lib/rules.ts +++ b/tools/pkglint/lib/rules.ts @@ -482,7 +482,7 @@ export class JSIIProjectReferences extends ValidationRule { this.name, pkg, 'jsii.projectReferences', - pkg.json.name !== 'monocdk-experiment' && pkg.json.name !== 'aws-cdk-lib', + pkg.json.name !== 'monocdk' && pkg.json.name !== 'aws-cdk-lib', ); } } From 8006459b9d20542cb9c4d8ca3f10ef5938c67e74 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Wed, 7 Oct 2020 00:25:35 +0200 Subject: [PATCH 33/47] fix(stepfunctions): X-Ray policy does not match documentation (#10721) Based on the discovery of Michael (https://twitter.com/hellomichibye/status/1313134632918024193) this fixes the needed IAM permissions for X-Ray in step-functions. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts | 8 +++++++- .../@aws-cdk/aws-stepfunctions/test/state-machine.test.ts | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts b/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts index 46ad90e48660d..2a12632d33ed0 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts @@ -418,7 +418,13 @@ export class StateMachine extends StateMachineBase { private buildTracingConfiguration(): CfnStateMachine.TracingConfigurationProperty { this.addToRolePolicy(new iam.PolicyStatement({ // https://docs.aws.amazon.com/xray/latest/devguide/security_iam_id-based-policy-examples.html#xray-permissions-resources - actions: ['xray:PutTraceSegments', 'xray:PutTelemetryRecords'], + // https://docs.aws.amazon.com/step-functions/latest/dg/xray-iam.html + actions: [ + 'xray:PutTraceSegments', + 'xray:PutTelemetryRecords', + 'xray:GetSamplingRules', + 'xray:GetSamplingTargets', + ], resources: ['*'], })); diff --git a/packages/@aws-cdk/aws-stepfunctions/test/state-machine.test.ts b/packages/@aws-cdk/aws-stepfunctions/test/state-machine.test.ts index 86475be650276..33353447abeec 100644 --- a/packages/@aws-cdk/aws-stepfunctions/test/state-machine.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions/test/state-machine.test.ts @@ -144,6 +144,8 @@ describe('State Machine', () => { Action: [ 'xray:PutTraceSegments', 'xray:PutTelemetryRecords', + 'xray:GetSamplingRules', + 'xray:GetSamplingTargets', ], Effect: 'Allow', Resource: '*', From 1559fe9d352f5ec90e13196ab6b5a74e7e479753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20M=C3=BCller?= Date: Wed, 7 Oct 2020 00:52:12 +0200 Subject: [PATCH 34/47] feat(rds): add clusterArn property to IServerlessCluster (#10741) This PR adds a property `clusterArn` to `IServerlessCluster`. This simplifies the usage of the Data API which requires passing the ARN of the cluster in Data API calls. closes #10736 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-rds/lib/serverless-cluster.ts | 19 +++++++++++- .../aws-rds/test/test.serverless-cluster.ts | 31 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts b/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts index 3f2dbfef37c7d..f8b0d51577bf0 100644 --- a/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts +++ b/packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts @@ -1,7 +1,7 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as kms from '@aws-cdk/aws-kms'; import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; -import { Resource, Duration, Token, Annotations, RemovalPolicy, IResource } from '@aws-cdk/core'; +import { Resource, Duration, Token, Annotations, RemovalPolicy, IResource, Stack } from '@aws-cdk/core'; import { Construct } from 'constructs'; import { IClusterEngine } from './cluster-engine'; import { DatabaseSecret } from './database-secret'; @@ -23,6 +23,11 @@ export interface IServerlessCluster extends IResource, ec2.IConnectable, secrets */ readonly clusterIdentifier: string; + /** + * The ARN of the cluster + */ + readonly clusterArn: string; + /** * The endpoint to use for read/write operations * @attribute EndpointAddress,EndpointPort @@ -282,6 +287,18 @@ abstract class ServerlessClusterBase extends Resource implements IServerlessClus */ public abstract readonly connections: ec2.Connections; + /** + * The ARN of the cluster + */ + public get clusterArn(): string { + return Stack.of(this).formatArn({ + service: 'rds', + resource: 'cluster', + sep: ':', + resourceName: this.clusterIdentifier, + }); + } + /** * Renders the secret attachment target specifications. */ diff --git a/packages/@aws-cdk/aws-rds/test/test.serverless-cluster.ts b/packages/@aws-cdk/aws-rds/test/test.serverless-cluster.ts index dbd93d4d7fd38..bb4e20d58cdee 100644 --- a/packages/@aws-cdk/aws-rds/test/test.serverless-cluster.ts +++ b/packages/@aws-cdk/aws-rds/test/test.serverless-cluster.ts @@ -617,6 +617,37 @@ export = { test.done(); }, + + 'check that clusterArn property works'(test: Test) { + // GIVEN + const stack = testStack(); + const vpc = ec2.Vpc.fromLookup(stack, 'VPC', { isDefault: true }); + const cluster = new ServerlessCluster(stack, 'Database', { + engine: DatabaseClusterEngine.AURORA_MYSQL, + vpc, + }); + const exportName = 'DbCluterArn'; + + // WHEN + new cdk.CfnOutput(stack, exportName, { + exportName, + value: cluster.clusterArn, + }); + + // THEN + test.deepEqual(stack.resolve(cluster.clusterArn), { + 'Fn::Join': [ + '', + [ + 'arn:', + { Ref: 'AWS::Partition' }, + ':rds:us-test-1:12345:cluster:', + { Ref: 'DatabaseB269D8BB' }, + ], + ], + }); + test.done(); + }, }; function testStack() { From c58127bd1b7215468df0f2bd584fed1a344ac7a5 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Tue, 6 Oct 2020 17:20:42 -0700 Subject: [PATCH 35/47] chore(monocdk): fix dotnet naming (#10747) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/monocdk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/monocdk/package.json b/packages/monocdk/package.json index 8366f1693d2c6..e3acbbf9553ca 100644 --- a/packages/monocdk/package.json +++ b/packages/monocdk/package.json @@ -52,7 +52,7 @@ "targets": { "dotnet": { "namespace": "Amazon.CDK", - "packageId": "Amazon.CDK.MonoCDK.", + "packageId": "Amazon.CDK.MonoCDK", "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "versionSuffix": "-devpreview", "signAssembly": true, From 4864fa057e56a4e8e2d1afeaa5fe4e84a8c90878 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Tue, 6 Oct 2020 21:34:53 -0700 Subject: [PATCH 36/47] chore(cli): "cdk context" is broken (#10751) This [commit](https://github.com/aws/aws-cdk/pull/10619), while fixed the problem mentioned, broke the simplest functionally of: ``` cdk context ``` Now throws: ``` Cannot read property 'sort' of undefined ``` This PR reverts that change, and adds a simple unit test that will allow detecting this kind of breakage in unit tests. We still need to fix the issue in the PR, opening the orginal [issue](https://github.com/aws/aws-cdk/issues/3033). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/lib/commands/context.ts | 4 ++-- .../test/commands/context-command.test.ts | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/aws-cdk/lib/commands/context.ts b/packages/aws-cdk/lib/commands/context.ts index 994bb7c675636..cd5309bae7360 100644 --- a/packages/aws-cdk/lib/commands/context.ts +++ b/packages/aws-cdk/lib/commands/context.ts @@ -81,7 +81,7 @@ function listContext(context: any) { function invalidateContext(context: Context, key: string) { const i = parseInt(key, 10); if (`${i}` === key) { - // Twas a number and we fully parsed it. + // was a number and we fully parsed it. key = keyByNumber(context, i); } @@ -107,7 +107,7 @@ function keyByNumber(context: any, n: number) { * Return enumerated keys in a definitive order */ function contextKeys(context: Context): [number, string][] { - const keys = context.keys; + const keys = Object.keys(context); keys.sort(); return enumerate1(keys); } diff --git a/packages/aws-cdk/test/commands/context-command.test.ts b/packages/aws-cdk/test/commands/context-command.test.ts index 47b9ffc070f82..87389fd1896f6 100644 --- a/packages/aws-cdk/test/commands/context-command.test.ts +++ b/packages/aws-cdk/test/commands/context-command.test.ts @@ -1,30 +1,23 @@ import { realHandler } from '../../lib/commands/context'; import { Configuration } from '../../lib/settings'; -test('context reset can remove a context key', async () => { +test('context list', async() => { // GIVEN const configuration = new Configuration(); configuration.context.set('foo', 'bar'); - configuration.context.set('baz', 'quux'); expect(configuration.context.all).toEqual({ foo: 'bar', - baz: 'quux', }); // WHEN await realHandler({ configuration, - args: { reset: 'foo' }, + args: {}, } as any); - - // THEN - expect(configuration.context.all).toEqual({ - baz: 'quux', - }); }); -test('context reset can remove a context key using number', async () => { +test('context reset can remove a context key', async () => { // GIVEN const configuration = new Configuration(); configuration.context.set('foo', 'bar'); @@ -38,11 +31,11 @@ test('context reset can remove a context key using number', async () => { // WHEN await realHandler({ configuration, - args: { reset: '1' }, + args: { reset: 'foo' }, } as any); // THEN expect(configuration.context.all).toEqual({ - foo: 'bar', + baz: 'quux', }); }); From 41f6de2b3fe6cb20a49fce2d3db0bd25812fd5d9 Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Wed, 7 Oct 2020 12:07:20 +0530 Subject: [PATCH 37/47] feat(efs): add support for backup policy (#10524) Add support for setting `BackupPolicy` to the `FileSystem` L2 construct. [Reference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-filesystem.html#cfn-efs-filesystem-backuppolicy) closes #10414 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-efs/README.md | 3 ++- packages/@aws-cdk/aws-efs/lib/efs-file-system.ts | 8 ++++++++ .../@aws-cdk/aws-efs/test/efs-file-system.test.ts | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-efs/README.md b/packages/@aws-cdk/aws-efs/README.md index f1082eeddbc83..853ae097327cb 100644 --- a/packages/@aws-cdk/aws-efs/README.md +++ b/packages/@aws-cdk/aws-efs/README.md @@ -76,7 +76,8 @@ const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', { encrypted: true, lifecyclePolicy: efs.LifecyclePolicy.AFTER_14_DAYS, performanceMode: efs.PerformanceMode.GENERAL_PURPOSE, - throughputMode: efs.ThroughputMode.BURSTING + throughputMode: efs.ThroughputMode.BURSTING, + enableAutomaticBackups: true }); const inst = new Instance(this, 'inst', { diff --git a/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts b/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts index ce5fc4eac2e9c..2c28375667fe4 100644 --- a/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts +++ b/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts @@ -171,6 +171,13 @@ export interface FileSystemProps { * @default RemovalPolicy.RETAIN */ readonly removalPolicy?: RemovalPolicy; + + /** + * Whether to enable automatic backups for the file system. + * + * @default false + */ + readonly enableAutomaticBackups?: boolean; } /** @@ -252,6 +259,7 @@ export class FileSystem extends Resource implements IFileSystem { performanceMode: props.performanceMode, throughputMode: props.throughputMode, provisionedThroughputInMibps: props.provisionedThroughputPerSecond?.toMebibytes(), + backupPolicy: props.enableAutomaticBackups ? { status: 'ENABLED' } : undefined, }); filesystem.applyRemovalPolicy(props.removalPolicy); diff --git a/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts b/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts index 02369563bd9a5..dfdb56bcc46f6 100644 --- a/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts +++ b/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts @@ -7,7 +7,7 @@ import { FileSystem, LifecyclePolicy, PerformanceMode, ThroughputMode } from '.. let stack = new Stack(); let vpc = new ec2.Vpc(stack, 'VPC'); -beforeEach( () => { +beforeEach(() => { stack = new Stack(); vpc = new ec2.Vpc(stack, 'VPC'); }); @@ -216,11 +216,24 @@ test('auto-named if none provided', () => { }); test('removalPolicy is DESTROY', () => { + // WHEN new FileSystem(stack, 'EfsFileSystem', { vpc, removalPolicy: RemovalPolicy.DESTROY }); + // THEN expectCDK(stack).to(haveResource('AWS::EFS::FileSystem', { DeletionPolicy: 'Delete', UpdateReplacePolicy: 'Delete', }, ResourcePart.CompleteDefinition)); +}); + +test('can specify backup policy', () => { + // WHEN + new FileSystem(stack, 'EfsFileSystem', { vpc, enableAutomaticBackups: true }); + // THEN + expectCDK(stack).to(haveResource('AWS::EFS::FileSystem', { + BackupPolicy: { + Status: 'ENABLED', + }, + })); }); From d1a6e88f72c3f2e13de22f82250f04df1df89cab Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Wed, 7 Oct 2020 02:15:24 -0700 Subject: [PATCH 38/47] chore: upgrade jsonschema minor version (#10758) bump the minor version to `1.2.10` to avoid a [bug](https://github.com/tdegrunt/jsonschema/issues/314) in version `1.2.9`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../cloud-assembly-schema/package.json | 2 +- packages/aws-cdk-lib/package.json | 2 +- packages/decdk/package.json | 2 +- packages/monocdk/package.json | 2 +- yarn.lock | 25 +++++++++++++++++-- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk/cloud-assembly-schema/package.json b/packages/@aws-cdk/cloud-assembly-schema/package.json index 90c423d3cc36e..8db7c0ed14807 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/package.json +++ b/packages/@aws-cdk/cloud-assembly-schema/package.json @@ -82,7 +82,7 @@ "exclude": [] }, "dependencies": { - "jsonschema": "^1.2.7", + "jsonschema": "^1.2.10", "semver": "^7.3.2" }, "awscdkio": { diff --git a/packages/aws-cdk-lib/package.json b/packages/aws-cdk-lib/package.json index 02b2d7db98e2d..4b16e9d1c1123 100644 --- a/packages/aws-cdk-lib/package.json +++ b/packages/aws-cdk-lib/package.json @@ -91,7 +91,7 @@ "dependencies": { "case": "1.6.3", "fs-extra": "^9.0.1", - "jsonschema": "^1.2.7", + "jsonschema": "^1.2.10", "minimatch": "^3.0.4", "semver": "^7.3.2", "yaml": "1.10.0" diff --git a/packages/decdk/package.json b/packages/decdk/package.json index 51a6fbe5eaff8..0d78acb308e5c 100644 --- a/packages/decdk/package.json +++ b/packages/decdk/package.json @@ -188,7 +188,7 @@ "constructs": "^3.0.4", "fs-extra": "^9.0.1", "jsii-reflect": "^1.13.0", - "jsonschema": "^1.2.7", + "jsonschema": "^1.2.10", "yaml": "1.10.0", "yargs": "^16.0.3" }, diff --git a/packages/monocdk/package.json b/packages/monocdk/package.json index e3acbbf9553ca..9de8f4556e592 100644 --- a/packages/monocdk/package.json +++ b/packages/monocdk/package.json @@ -90,7 +90,7 @@ "dependencies": { "case": "1.6.3", "fs-extra": "^9.0.1", - "jsonschema": "^1.2.7", + "jsonschema": "^1.2.10", "minimatch": "^3.0.4", "semver": "^7.3.2", "yaml": "1.10.0" diff --git a/yarn.lock b/yarn.lock index 03e7e46a0c496..affb10c957d4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4456,6 +4456,22 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +cdk8s-plus@^0.29.0: + version "0.29.0" + resolved "https://registry.yarnpkg.com/cdk8s-plus/-/cdk8s-plus-0.29.0.tgz#c30dc2aca0338f473b2572e92268946adc014ad9" + integrity sha512-++8E+uk7cdLiqZgpb/95goNd8pSHBtjWEqe/Fe7JCrUOCfKEBma60PvTHZaSMGRx52bkd1vevyQYiCmcAz4Aww== + dependencies: + minimatch "^3.0.4" + +cdk8s@^0.30.0: + version "0.30.0" + resolved "https://registry.yarnpkg.com/cdk8s/-/cdk8s-0.30.0.tgz#71cfbc36c09a03c2410b4530486d38b4e0025c51" + integrity sha512-ZPNq02HXekAbgdTwNVXYpAqPT9tq2S279oRf0ffbiphjmVtL+wrog2es+DAygFZzG8zkoOkJG5dOZtkE9FaSbQ== + dependencies: + follow-redirects "^1.11.0" + json-stable-stringify "^1.0.1" + yaml "^1.7.2" + chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -6773,7 +6789,7 @@ follow-redirects@1.5.10: dependencies: debug "=3.1.0" -follow-redirects@^1.0.0: +follow-redirects@^1.0.0, follow-redirects@^1.11.0: version "1.13.0" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db" integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA== @@ -9256,6 +9272,11 @@ jsonparse@^1.2.0: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= +jsonschema@^1.2.10: + version "1.2.10" + resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.10.tgz#38dc18b63839e8f07580df015e37d959f20d1eda" + integrity sha512-CoRSun5gmvgSYMHx5msttse19SnQpaHoPzIqULwE7B9KtR4Od1g70sBqeUriq5r8b9R3ptDc0o7WKpUDjUgLgg== + jsonschema@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.7.tgz#4e6d6dc4d83dc80707055ba22c00ec6152c0e6e9" @@ -14372,7 +14393,7 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml@*, yaml@1.10.0, yaml@^1.10.0, yaml@^1.5.0: +yaml@*, yaml@1.10.0, yaml@^1.10.0, yaml@^1.5.0, yaml@^1.7.2: version "1.10.0" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== From 4f46341ae9290200e7e8a34a4c98b5b3af726ba2 Mon Sep 17 00:00:00 2001 From: Daniel Schroeder Date: Wed, 7 Oct 2020 11:44:07 +0200 Subject: [PATCH 39/47] docs(ec2): fix block device example in README (#10760) In the latest version the property is called `blockDevices`, not `blockDeviceMappings`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-ec2/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/README.md b/packages/@aws-cdk/aws-ec2/README.md index 2704685007a0e..01672fae19a40 100644 --- a/packages/@aws-cdk/aws-ec2/README.md +++ b/packages/@aws-cdk/aws-ec2/README.md @@ -738,14 +738,14 @@ EBS volume for the bastion host can be encrypted like: ### Block Devices -To add EBS block device mappings, specify the `blockDeviceMappings` property. The follow example sets the EBS-backed +To add EBS block device mappings, specify the `blockDevices` property. The following example sets the EBS-backed root device (`/dev/sda1`) size to 50 GiB, and adds another EBS-backed device mapped to `/dev/sdm` that is 100 GiB in size: ```ts new ec2.Instance(this, 'Instance', { // ... - blockDeviceMappings: [ + blockDevices: [ { deviceName: '/dev/sda1', volume: ec2.BlockDeviceVolume.ebs(50), From 8b9a5cf3b68d97677915a034dda31edfbf1c60b4 Mon Sep 17 00:00:00 2001 From: Neil Kuan <46012524+guan840912@users.noreply.github.com> Date: Wed, 7 Oct 2020 18:12:55 +0800 Subject: [PATCH 40/47] chore(rds): add additional mysql engine versions (#10757) chore(rds): add additional mysql engine versions Closes: #10756 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-rds/lib/instance-engine.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/@aws-cdk/aws-rds/lib/instance-engine.ts b/packages/@aws-cdk/aws-rds/lib/instance-engine.ts index 570e7b81a0479..f00e1e593782b 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance-engine.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance-engine.ts @@ -349,6 +349,8 @@ export class MysqlEngineVersion { public static readonly VER_8_0_17 = MysqlEngineVersion.of('8.0.17', '8.0'); /** Version "8.0.19". */ public static readonly VER_8_0_19 = MysqlEngineVersion.of('8.0.19', '8.0'); + /** Version "8.0.20 ". */ + public static readonly VER_8_0_20 = MysqlEngineVersion.of('8.0.20', '8.0'); /** * Create a new MysqlEngineVersion with an arbitrary version. From 6078cab14dcc6d974d4f0c92eab05e661bbc44e6 Mon Sep 17 00:00:00 2001 From: AWS CDK Automation <43080478+aws-cdk-automation@users.noreply.github.com> Date: Wed, 7 Oct 2020 12:41:03 +0200 Subject: [PATCH 41/47] feat(cfnspec): cloudformation spec v18.6.0 (#10762) Co-authored-by: AWS CDK Team Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- packages/@aws-cdk/cfnspec/CHANGELOG.md | 47 +++++ packages/@aws-cdk/cfnspec/cfn.version | 2 +- ...0_CloudFormationResourceSpecification.json | 175 ++++++++++++++---- 3 files changed, 183 insertions(+), 41 deletions(-) diff --git a/packages/@aws-cdk/cfnspec/CHANGELOG.md b/packages/@aws-cdk/cfnspec/CHANGELOG.md index 6ef142cd6ce2b..1809b1db9f2a7 100644 --- a/packages/@aws-cdk/cfnspec/CHANGELOG.md +++ b/packages/@aws-cdk/cfnspec/CHANGELOG.md @@ -1,3 +1,50 @@ +# CloudFormation Resource Specification v18.6.0 + +## New Resource Types + +* AWS::WorkSpaces::ConnectionAlias + +## Attribute Changes + +* AWS::ImageBuilder::Component Name (__added__) +* AWS::ImageBuilder::DistributionConfiguration Name (__added__) +* AWS::ImageBuilder::Image Name (__added__) +* AWS::ImageBuilder::ImagePipeline Name (__added__) +* AWS::ImageBuilder::ImageRecipe Name (__added__) +* AWS::ImageBuilder::InfrastructureConfiguration Name (__added__) + +## Property Changes + +* AWS::ApiGateway::DomainName DomainName.UpdateType (__changed__) + * Old: Mutable + * New: Immutable +* AWS::Config::ConformancePack DeliveryS3Bucket.Required (__changed__) + * Old: true + * New: false +* AWS::Config::OrganizationConformancePack DeliveryS3Bucket.Required (__changed__) + * Old: true + * New: false +* AWS::ImageBuilder::Component Name (__deleted__) +* AWS::ImageBuilder::DistributionConfiguration Name (__deleted__) +* AWS::ImageBuilder::ImagePipeline Name (__deleted__) +* AWS::ImageBuilder::ImageRecipe Name (__deleted__) +* AWS::ImageBuilder::InfrastructureConfiguration Name (__deleted__) +* AWS::Kendra::Faq FileFormat (__added__) +* AWS::StepFunctions::Activity Arn (__deleted__) +* AWS::StepFunctions::Activity Name (__added__) +* AWS::StepFunctions::Activity Tags.DuplicatesAllowed (__deleted__) + +## Property Type Changes + +* AWS::Backup::BackupPlan.AdvancedBackupSettingResourceType (__added__) +* AWS::Backup::BackupPlan.BackupPlanResourceType AdvancedBackupSettings (__added__) +* AWS::CloudFront::CachePolicy.ParametersInCacheKeyAndForwardedToOrigin EnableAcceptEncodingBrotli (__added__) +* AWS::CodeBuild::Project.ProjectTriggers BuildType (__added__) +* AWS::ECS::Service.NetworkConfiguration AwsVpcConfiguration (__deleted__) +* AWS::ECS::Service.NetworkConfiguration AwsvpcConfiguration (__added__) +* AWS::Synthetics::Canary.RunConfig ActiveTracing (__added__) + + # CloudFormation Resource Specification v18.5.0 ## New Resource Types diff --git a/packages/@aws-cdk/cfnspec/cfn.version b/packages/@aws-cdk/cfnspec/cfn.version index 9020bd13e71ad..4b5ebaf0fc650 100644 --- a/packages/@aws-cdk/cfnspec/cfn.version +++ b/packages/@aws-cdk/cfnspec/cfn.version @@ -1 +1 @@ -18.5.0 +18.6.0 diff --git a/packages/@aws-cdk/cfnspec/spec-source/000_CloudFormationResourceSpecification.json b/packages/@aws-cdk/cfnspec/spec-source/000_CloudFormationResourceSpecification.json index c62ff373855fd..aaa0365669032 100644 --- a/packages/@aws-cdk/cfnspec/spec-source/000_CloudFormationResourceSpecification.json +++ b/packages/@aws-cdk/cfnspec/spec-source/000_CloudFormationResourceSpecification.json @@ -6900,9 +6900,33 @@ } } }, + "AWS::Backup::BackupPlan.AdvancedBackupSettingResourceType": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupplan-advancedbackupsettingresourcetype.html", + "Properties": { + "BackupOptions": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupplan-advancedbackupsettingresourcetype.html#cfn-backup-backupplan-advancedbackupsettingresourcetype-backupoptions", + "PrimitiveType": "Json", + "Required": true, + "UpdateType": "Mutable" + }, + "ResourceType": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupplan-advancedbackupsettingresourcetype.html#cfn-backup-backupplan-advancedbackupsettingresourcetype-resourcetype", + "PrimitiveType": "String", + "Required": true, + "UpdateType": "Mutable" + } + } + }, "AWS::Backup::BackupPlan.BackupPlanResourceType": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupplan-backupplanresourcetype.html", "Properties": { + "AdvancedBackupSettings": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupplan-backupplanresourcetype.html#cfn-backup-backupplan-backupplanresourcetype-advancedbackupsettings", + "ItemType": "AdvancedBackupSettingResourceType", + "Required": false, + "Type": "List", + "UpdateType": "Mutable" + }, "BackupPlanName": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupplan-backupplanresourcetype.html#cfn-backup-backupplan-backupplanresourcetype-backupplanname", "PrimitiveType": "String", @@ -8181,6 +8205,12 @@ "Type": "CookiesConfig", "UpdateType": "Mutable" }, + "EnableAcceptEncodingBrotli": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-cachepolicy-parametersincachekeyandforwardedtoorigin.html#cfn-cloudfront-cachepolicy-parametersincachekeyandforwardedtoorigin-enableacceptencodingbrotli", + "PrimitiveType": "Boolean", + "Required": false, + "UpdateType": "Mutable" + }, "EnableAcceptEncodingGzip": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-cachepolicy-parametersincachekeyandforwardedtoorigin.html#cfn-cloudfront-cachepolicy-parametersincachekeyandforwardedtoorigin-enableacceptencodinggzip", "PrimitiveType": "Boolean", @@ -9747,6 +9777,12 @@ "AWS::CodeBuild::Project.ProjectTriggers": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-projecttriggers.html", "Properties": { + "BuildType": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-projecttriggers.html#cfn-codebuild-project-projecttriggers-buildtype", + "PrimitiveType": "String", + "Required": false, + "UpdateType": "Mutable" + }, "FilterGroups": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-projecttriggers.html#cfn-codebuild-project-projecttriggers-filtergroups", "ItemType": "FilterGroup", @@ -15335,7 +15371,7 @@ "AWS::ECS::Service.NetworkConfiguration": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-service-networkconfiguration.html", "Properties": { - "AwsVpcConfiguration": { + "AwsvpcConfiguration": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-service-networkconfiguration.html#cfn-ecs-service-networkconfiguration-awsvpcconfiguration", "Required": false, "Type": "AwsVpcConfiguration", @@ -39403,6 +39439,12 @@ "AWS::Synthetics::Canary.RunConfig": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-runconfig.html", "Properties": { + "ActiveTracing": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-runconfig.html#cfn-synthetics-canary-runconfig-activetracing", + "PrimitiveType": "Boolean", + "Required": false, + "UpdateType": "Mutable" + }, "MemoryInMB": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-runconfig.html#cfn-synthetics-canary-runconfig-memoryinmb", "PrimitiveType": "Integer", @@ -41505,6 +41547,35 @@ } } }, + "AWS::WorkSpaces::ConnectionAlias.ConnectionAliasAssociation": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-workspaces-connectionalias-connectionaliasassociation.html", + "Properties": { + "AssociatedAccountId": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-workspaces-connectionalias-connectionaliasassociation.html#cfn-workspaces-connectionalias-connectionaliasassociation-associatedaccountid", + "PrimitiveType": "String", + "Required": false, + "UpdateType": "Mutable" + }, + "AssociationStatus": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-workspaces-connectionalias-connectionaliasassociation.html#cfn-workspaces-connectionalias-connectionaliasassociation-associationstatus", + "PrimitiveType": "String", + "Required": false, + "UpdateType": "Mutable" + }, + "ConnectionIdentifier": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-workspaces-connectionalias-connectionaliasassociation.html#cfn-workspaces-connectionalias-connectionaliasassociation-connectionidentifier", + "PrimitiveType": "String", + "Required": false, + "UpdateType": "Mutable" + }, + "ResourceId": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-workspaces-connectionalias-connectionaliasassociation.html#cfn-workspaces-connectionalias-connectionaliasassociation-resourceid", + "PrimitiveType": "String", + "Required": false, + "UpdateType": "Mutable" + } + } + }, "AWS::WorkSpaces::Workspace.WorkspaceProperties": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-workspaces-workspace-workspaceproperties.html", "Properties": { @@ -41627,7 +41698,7 @@ } } }, - "ResourceSpecificationVersion": "18.5.0", + "ResourceSpecificationVersion": "18.6.0", "ResourceTypes": { "AWS::ACMPCA::Certificate": { "Attributes": { @@ -42569,7 +42640,7 @@ "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-domainname", "PrimitiveType": "String", "Required": false, - "UpdateType": "Mutable" + "UpdateType": "Immutable" }, "EndpointConfiguration": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-endpointconfiguration", @@ -48954,7 +49025,7 @@ "DeliveryS3Bucket": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-config-conformancepack.html#cfn-config-conformancepack-deliverys3bucket", "PrimitiveType": "String", - "Required": true, + "Required": false, "UpdateType": "Mutable" }, "DeliveryS3KeyPrefix": { @@ -49055,7 +49126,7 @@ "DeliveryS3Bucket": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-config-organizationconformancepack.html#cfn-config-organizationconformancepack-deliverys3bucket", "PrimitiveType": "String", - "Required": true, + "Required": false, "UpdateType": "Mutable" }, "DeliveryS3KeyPrefix": { @@ -57951,6 +58022,9 @@ "Encrypted": { "PrimitiveType": "Boolean" }, + "Name": { + "PrimitiveType": "String" + }, "Type": { "PrimitiveType": "String" } @@ -57981,12 +58055,6 @@ "Required": false, "UpdateType": "Immutable" }, - "Name": { - "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-component.html#cfn-imagebuilder-component-name", - "PrimitiveType": "String", - "Required": true, - "UpdateType": "Immutable" - }, "Platform": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-component.html#cfn-imagebuilder-component-platform", "PrimitiveType": "String", @@ -58025,6 +58093,9 @@ "Attributes": { "Arn": { "PrimitiveType": "String" + }, + "Name": { + "PrimitiveType": "String" } }, "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-distributionconfiguration.html", @@ -58042,12 +58113,6 @@ "Type": "List", "UpdateType": "Mutable" }, - "Name": { - "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-distributionconfiguration.html#cfn-imagebuilder-distributionconfiguration-name", - "PrimitiveType": "String", - "Required": true, - "UpdateType": "Immutable" - }, "Tags": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-distributionconfiguration.html#cfn-imagebuilder-distributionconfiguration-tags", "PrimitiveItemType": "String", @@ -58064,6 +58129,9 @@ }, "ImageId": { "PrimitiveType": "String" + }, + "Name": { + "PrimitiveType": "String" } }, "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-image.html", @@ -58111,6 +58179,9 @@ "Attributes": { "Arn": { "PrimitiveType": "String" + }, + "Name": { + "PrimitiveType": "String" } }, "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagepipeline.html", @@ -58151,12 +58222,6 @@ "Required": true, "UpdateType": "Mutable" }, - "Name": { - "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagepipeline.html#cfn-imagebuilder-imagepipeline-name", - "PrimitiveType": "String", - "Required": true, - "UpdateType": "Immutable" - }, "Schedule": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagepipeline.html#cfn-imagebuilder-imagepipeline-schedule", "Required": false, @@ -58182,6 +58247,9 @@ "Attributes": { "Arn": { "PrimitiveType": "String" + }, + "Name": { + "PrimitiveType": "String" } }, "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagerecipe.html", @@ -58206,12 +58274,6 @@ "Required": false, "UpdateType": "Immutable" }, - "Name": { - "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagerecipe.html#cfn-imagebuilder-imagerecipe-name", - "PrimitiveType": "String", - "Required": true, - "UpdateType": "Immutable" - }, "ParentImage": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagerecipe.html#cfn-imagebuilder-imagerecipe-parentimage", "PrimitiveType": "String", @@ -58243,6 +58305,9 @@ "Attributes": { "Arn": { "PrimitiveType": "String" + }, + "Name": { + "PrimitiveType": "String" } }, "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-infrastructureconfiguration.html", @@ -58279,12 +58344,6 @@ "Type": "Logging", "UpdateType": "Mutable" }, - "Name": { - "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-infrastructureconfiguration.html#cfn-imagebuilder-infrastructureconfiguration-name", - "PrimitiveType": "String", - "Required": true, - "UpdateType": "Immutable" - }, "ResourceTags": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-infrastructureconfiguration.html#cfn-imagebuilder-infrastructureconfiguration-resourcetags", "PrimitiveItemType": "String", @@ -59127,6 +59186,12 @@ "Required": false, "UpdateType": "Immutable" }, + "FileFormat": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kendra-faq.html#cfn-kendra-faq-fileformat", + "PrimitiveType": "String", + "Required": false, + "UpdateType": "Immutable" + }, "IndexId": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kendra-faq.html#cfn-kendra-faq-indexid", "PrimitiveType": "String", @@ -67538,15 +67603,14 @@ }, "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-activity.html", "Properties": { - "Arn": { - "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-activity.html#cfn-stepfunctions-activity-arn", + "Name": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-activity.html#cfn-stepfunctions-activity-name", "PrimitiveType": "String", - "Required": false, - "UpdateType": "Mutable" + "Required": true, + "UpdateType": "Immutable" }, "Tags": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-activity.html#cfn-stepfunctions-activity-tags", - "DuplicatesAllowed": true, "ItemType": "TagsEntry", "Required": false, "Type": "List", @@ -68466,6 +68530,37 @@ } } }, + "AWS::WorkSpaces::ConnectionAlias": { + "Attributes": { + "AliasId": { + "PrimitiveType": "String" + }, + "Associations": { + "ItemType": "ConnectionAliasAssociation", + "Type": "List" + }, + "ConnectionAliasState": { + "PrimitiveType": "String" + } + }, + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-workspaces-connectionalias.html", + "Properties": { + "ConnectionString": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-workspaces-connectionalias.html#cfn-workspaces-connectionalias-connectionstring", + "PrimitiveType": "String", + "Required": true, + "UpdateType": "Immutable" + }, + "Tags": { + "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-workspaces-connectionalias.html#cfn-workspaces-connectionalias-tags", + "DuplicatesAllowed": true, + "ItemType": "Tag", + "Required": false, + "Type": "List", + "UpdateType": "Immutable" + } + } + }, "AWS::WorkSpaces::Workspace": { "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-workspaces-workspace.html", "Properties": { From effed09854b6614e75077fd39be8aced69c33582 Mon Sep 17 00:00:00 2001 From: Mitch Lloyd Date: Wed, 7 Oct 2020 04:41:18 -0700 Subject: [PATCH 42/47] fix(redshift): Allow redshift cluster securityGroupName to be generated (#10742) PR that resolves #10740 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-redshift/lib/cluster.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/@aws-cdk/aws-redshift/lib/cluster.ts b/packages/@aws-cdk/aws-redshift/lib/cluster.ts index 0856766b99fb9..3b0667364772a 100644 --- a/packages/@aws-cdk/aws-redshift/lib/cluster.ts +++ b/packages/@aws-cdk/aws-redshift/lib/cluster.ts @@ -416,7 +416,6 @@ export class Cluster extends ClusterBase { props.securityGroups : [new ec2.SecurityGroup(this, 'SecurityGroup', { description: 'Redshift security group', vpc: this.vpc, - securityGroupName: 'redshift SG', })]; const securityGroupIds = securityGroups.map(sg => sg.securityGroupId); From dbb7e34eeb9f396003522fbee52f63f985826f70 Mon Sep 17 00:00:00 2001 From: wtho Date: Wed, 7 Oct 2020 14:09:55 +0200 Subject: [PATCH 43/47] feat(cloudfront-origins): customize origin access identity in s3origin (#10491) Adds support for passing in a identity as it is possible in the CloudFrontWebDistribution closes #9859 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../@aws-cdk/aws-cloudfront-origins/README.md | 2 +- .../aws-cloudfront-origins/lib/s3-origin.ts | 13 ++++- .../test/integ.s3-origin-oai.expected.json | 58 +++++++++++++++++++ .../test/integ.s3-origin-oai.ts | 18 ++++++ .../test/s3-origin.test.ts | 19 +++++- 5 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.expected.json create mode 100644 packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.ts diff --git a/packages/@aws-cdk/aws-cloudfront-origins/README.md b/packages/@aws-cdk/aws-cloudfront-origins/README.md index 614a089247459..1fe19e77ebf1b 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/README.md +++ b/packages/@aws-cdk/aws-cloudfront-origins/README.md @@ -32,7 +32,7 @@ The above will treat the bucket differently based on if `IBucket.isWebsite` is s treated as an HTTP origin, and the built-in S3 redirects and error pages can be used. Otherwise, the bucket is handled as a bucket origin and CloudFront's redirect and error handling will be used. In the latter case, the Origin wil create an origin access identity and grant it access to the underlying bucket. This can be used in conjunction with a bucket that is not public to require that your users access your content using CloudFront -URLs and not S3 URLs directly. +URLs and not S3 URLs directly. Alternatively, a custom origin access identity can be passed to the S3 origin in the properties. ## ELBv2 Load Balancer diff --git a/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts b/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts index 9159bc1f545ed..c6e0f83d0c15a 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts +++ b/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts @@ -16,6 +16,12 @@ export interface S3OriginProps { * @default '/' */ readonly originPath?: string; + /** + * An optional Origin Access Identity of the origin identity cloudfront will use when calling your s3 bucket. + * + * @default - An Origin Access Identity will be created. + */ + readonly originAccessIdentity?: cloudfront.IOriginAccessIdentity; } /** @@ -50,10 +56,13 @@ export class S3Origin implements cloudfront.IOrigin { * Contains additional logic around bucket permissions and origin access identities. */ class S3BucketOrigin extends cloudfront.OriginBase { - private originAccessIdentity!: cloudfront.OriginAccessIdentity; + private originAccessIdentity!: cloudfront.IOriginAccessIdentity; - constructor(private readonly bucket: s3.IBucket, props: S3OriginProps) { + constructor(private readonly bucket: s3.IBucket, { originAccessIdentity, ...props }: S3OriginProps) { super(bucket.bucketRegionalDomainName, props); + if (originAccessIdentity) { + this.originAccessIdentity = originAccessIdentity; + } } public bind(scope: cdk.Construct, options: cloudfront.OriginBindOptions): cloudfront.OriginBindConfig { diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.expected.json b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.expected.json new file mode 100644 index 0000000000000..7783c6d9da969 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.expected.json @@ -0,0 +1,58 @@ +{ + "Resources": { + "Bucket83908E77": { + "Type": "AWS::S3::Bucket", + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "OriginAccessIdentityDF1E3CAC": { + "Type": "AWS::CloudFront::CloudFrontOriginAccessIdentity", + "Properties": { + "CloudFrontOriginAccessIdentityConfig": { + "Comment": "Identity for bucket provided by test" + } + } + }, + "Distribution830FAC52": { + "Type": "AWS::CloudFront::Distribution", + "Properties": { + "DistributionConfig": { + "DefaultCacheBehavior": { + "ForwardedValues": { + "QueryString": false + }, + "TargetOriginId": "cloudfronts3originoaiDistributionOrigin1516C5A91", + "ViewerProtocolPolicy": "allow-all" + }, + "Enabled": true, + "HttpVersion": "http2", + "IPV6Enabled": true, + "Origins": [ + { + "DomainName": { + "Fn::GetAtt": [ + "Bucket83908E77", + "RegionalDomainName" + ] + }, + "Id": "cloudfronts3originoaiDistributionOrigin1516C5A91", + "S3OriginConfig": { + "OriginAccessIdentity": { + "Fn::Join": [ + "", + [ + "origin-access-identity/cloudfront/", + { + "Ref": "OriginAccessIdentityDF1E3CAC" + } + ] + ] + } + } + } + ] + } + } + } + } +} diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.ts b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.ts new file mode 100644 index 0000000000000..d7331a160abcd --- /dev/null +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/integ.s3-origin-oai.ts @@ -0,0 +1,18 @@ +import * as cloudfront from '@aws-cdk/aws-cloudfront'; +import * as s3 from '@aws-cdk/aws-s3'; +import * as cdk from '@aws-cdk/core'; +import * as origins from '../lib'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'cloudfront-s3-origin-oai'); + +const bucket = new s3.Bucket(stack, 'Bucket'); +const originAccessIdentity = new cloudfront.OriginAccessIdentity(stack, 'OriginAccessIdentity', { + comment: 'Identity for bucket provided by test', +}); +new cloudfront.Distribution(stack, 'Distribution', { + defaultBehavior: { origin: new origins.S3Origin(bucket, { originAccessIdentity }) }, +}); + +app.synth(); diff --git a/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts b/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts index 7545135e4fb0e..75770ce250ce1 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts +++ b/packages/@aws-cdk/aws-cloudfront-origins/test/s3-origin.test.ts @@ -34,7 +34,7 @@ describe('With bucket', () => { }); }); - test('can customize properties', () => { + test('can customize originPath property', () => { const bucket = new s3.Bucket(stack, 'Bucket'); const origin = new S3Origin(bucket, { originPath: '/assets' }); @@ -56,6 +56,23 @@ describe('With bucket', () => { }); }); + test('can customize OriginAccessIdentity property', () => { + const bucket = new s3.Bucket(stack, 'Bucket'); + + const originAccessIdentity = new cloudfront.OriginAccessIdentity(stack, 'OriginAccessIdentity', { + comment: 'Identity for bucket provided by test', + }); + + const origin = new S3Origin(bucket, { originAccessIdentity }); + new cloudfront.Distribution(stack, 'Dist', { defaultBehavior: { origin } }); + + expect(stack).toHaveResourceLike('AWS::CloudFront::CloudFrontOriginAccessIdentity', { + CloudFrontOriginAccessIdentityConfig: { + Comment: 'Identity for bucket provided by test', + }, + }); + }); + test('creates an OriginAccessIdentity and grants read permissions on the bucket', () => { const bucket = new s3.Bucket(stack, 'Bucket'); From 1123f073b07b3a465499759427e8e34c692e72f1 Mon Sep 17 00:00:00 2001 From: Shiv Lakshminarayan Date: Wed, 7 Oct 2020 07:10:34 -0700 Subject: [PATCH 44/47] chore(cfnspec): drop step functions patch as the updated spec has restored properties (#10764) in the `18.5` import, there the AWS::StepFunctions::Activity resource dropped the required name property and added one called Arn which was unintentional. A patch was added to restore the resource specification to previous state. Since #10762 has been merged, those properties have been restored in the resource specification as of `18.6`. The patch is no longer necessary. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../660_StepFunctions_Activity_patch.json | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 packages/@aws-cdk/cfnspec/spec-source/660_StepFunctions_Activity_patch.json diff --git a/packages/@aws-cdk/cfnspec/spec-source/660_StepFunctions_Activity_patch.json b/packages/@aws-cdk/cfnspec/spec-source/660_StepFunctions_Activity_patch.json deleted file mode 100644 index 260d79e4398d6..0000000000000 --- a/packages/@aws-cdk/cfnspec/spec-source/660_StepFunctions_Activity_patch.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "ResourceTypes": { - "AWS::StepFunctions::Activity": { - "patch": { - "description": "The StepFunctions resource is using the CloudFormation Registry and this was an errant entry. It will be restored in the next versions of the spec but is incorrect in v18.5", - "operations": [ - { - "op": "remove", - "path": "/Properties/Arn" - }, - { - "op": "add", - "path": "/Properties/Name", - "value": { - "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-activity.html#cfn-stepfunctions-activity-name", - "PrimitiveType": "String", - "Required": true, - "UpdateType": "Immutable" - } - } - ] - } - } - } -} \ No newline at end of file From e0d0e11a4c4822d5132dca7d12af237febb55b38 Mon Sep 17 00:00:00 2001 From: AWS CDK Team Date: Wed, 7 Oct 2020 17:01:21 +0000 Subject: [PATCH 45/47] chore(release): 1.67.0 --- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++++ lerna.json | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef8eeebf578f4..5070abf5bda71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,42 @@ 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. +## [1.67.0](https://github.com/aws/aws-cdk/compare/v1.66.0...v1.67.0) (2020-10-07) + + +### Features + +* **aws-ec2:** KINESIS_FIREHOSE vpc endpoint ([#10682](https://github.com/aws/aws-cdk/issues/10682)) ([08ae745](https://github.com/aws/aws-cdk/commit/08ae74569eb52fb73f202b770d652a941fd61ea4)), closes [#10611](https://github.com/aws/aws-cdk/issues/10611) +* **cfnspec:** cloudformation spec v18.6.0 ([#10762](https://github.com/aws/aws-cdk/issues/10762)) ([6078cab](https://github.com/aws/aws-cdk/commit/6078cab14dcc6d974d4f0c92eab05e661bbc44e6)) +* **cloudfront-origins:** customize origin access identity in s3origin ([#10491](https://github.com/aws/aws-cdk/issues/10491)) ([dbb7e34](https://github.com/aws/aws-cdk/commit/dbb7e34eeb9f396003522fbee52f63f985826f70)), closes [#9859](https://github.com/aws/aws-cdk/issues/9859) +* **core:** pass environment variables to CustomResourceProvider ([#10560](https://github.com/aws/aws-cdk/issues/10560)) ([320ec72](https://github.com/aws/aws-cdk/commit/320ec72a30f06920ab24fb43afff6975992db71f)), closes [#9668](https://github.com/aws/aws-cdk/issues/9668) +* **efs:** add support for backup policy ([#10524](https://github.com/aws/aws-cdk/issues/10524)) ([41f6de2](https://github.com/aws/aws-cdk/commit/41f6de2b3fe6cb20a49fce2d3db0bd25812fd5d9)), closes [#10414](https://github.com/aws/aws-cdk/issues/10414) +* **eks:** Support cdk8s charts ([#10562](https://github.com/aws/aws-cdk/issues/10562)) ([e51921d](https://github.com/aws/aws-cdk/commit/e51921d1a81ba9d89e21567291b5f7b215726ca7)) +* **rds:** add clusterArn property to IServerlessCluster ([#10741](https://github.com/aws/aws-cdk/issues/10741)) ([1559fe9](https://github.com/aws/aws-cdk/commit/1559fe9d352f5ec90e13196ab6b5a74e7e479753)), closes [#10736](https://github.com/aws/aws-cdk/issues/10736) +* **readme:** deprecate Gitter in favor of cdk.dev Slack ([#10700](https://github.com/aws/aws-cdk/issues/10700)) ([c60764e](https://github.com/aws/aws-cdk/commit/c60764e28ddc93e5a6f818fdc8e6ae3c0aa09f91)) + + +### Bug Fixes + +* **cli:** 'stack already contains Metadata resource' warning ([#10695](https://github.com/aws/aws-cdk/issues/10695)) ([e0b5508](https://github.com/aws/aws-cdk/commit/e0b55086cf9061e579c3c804b4d2e169ec9d7ae2)), closes [#10625](https://github.com/aws/aws-cdk/issues/10625) +* **cli:** `cdk context --reset ` does not work ([#10619](https://github.com/aws/aws-cdk/issues/10619)) ([3f62752](https://github.com/aws/aws-cdk/commit/3f6275265f84cbc04e12660496e9d9eb7cd65354)), closes [#3033](https://github.com/aws/aws-cdk/issues/3033) +* **cli:** deploying a transformed template without changes fails ([#10689](https://github.com/aws/aws-cdk/issues/10689)) ([d345919](https://github.com/aws/aws-cdk/commit/d345919800d02b80f40802da60e567d4a30b3521)), closes [#10650](https://github.com/aws/aws-cdk/issues/10650) +* **cloudfront-origins:** S3Origins with cross-stack buckets cause cyclic references ([#10696](https://github.com/aws/aws-cdk/issues/10696)) ([0ec4588](https://github.com/aws/aws-cdk/commit/0ec45881e66f598ec37bb772cd01c30be4da96f8)), closes [#10399](https://github.com/aws/aws-cdk/issues/10399) +* **codepipeline-actions:** correctly name the triggering Event in CodeCommitSourceAction ([#10706](https://github.com/aws/aws-cdk/issues/10706)) ([ff3a692](https://github.com/aws/aws-cdk/commit/ff3a69285f1f3ae1ff6c6b1495192ce54e46d2fc)), closes [#10665](https://github.com/aws/aws-cdk/issues/10665) +* **core:** cannot override properties with `.` in the name ([#10441](https://github.com/aws/aws-cdk/issues/10441)) ([063798b](https://github.com/aws/aws-cdk/commit/063798bdde241285df155999a0a5795eead87703)), closes [#10109](https://github.com/aws/aws-cdk/issues/10109) +* **core:** Stacks from 3rd-party libraries do not synthesize correctly ([#10690](https://github.com/aws/aws-cdk/issues/10690)) ([7bb5cf4](https://github.com/aws/aws-cdk/commit/7bb5cf43113db76d7e5e0fec5643e2e4cd64d289)), closes [#10671](https://github.com/aws/aws-cdk/issues/10671) +* **ec2:** `addExecuteFileCommand` arguments cannot be omitted ([#10692](https://github.com/aws/aws-cdk/issues/10692)) ([7178374](https://github.com/aws/aws-cdk/commit/7178374a3e545083724af70fbd777fbaabd33b1c)), closes [#10687](https://github.com/aws/aws-cdk/issues/10687) +* **ec2:** `InitCommand.shellCommand()` renders an argv command instead ([#10691](https://github.com/aws/aws-cdk/issues/10691)) ([de9d2f7](https://github.com/aws/aws-cdk/commit/de9d2f77779f16ead3ab871b8d4a51d12c700ea2)), closes [#10684](https://github.com/aws/aws-cdk/issues/10684) +* **ec2:** memory optimised graviton2 instance type ([#10615](https://github.com/aws/aws-cdk/issues/10615)) ([a72cfbd](https://github.com/aws/aws-cdk/commit/a72cfbd5d0f9af87aacf0657a6fc370ce2a23c55)) +* **elbv2:** metric(Un)HealthyHostCount don't use TargetGroup dimension ([#10697](https://github.com/aws/aws-cdk/issues/10697)) ([9444399](https://github.com/aws/aws-cdk/commit/9444399b08825b4d1c5dce58e3c396c9941724c4)), closes [#5046](https://github.com/aws/aws-cdk/issues/5046) +* **glue:** GetTableVersion permission not available for read ([#10628](https://github.com/aws/aws-cdk/issues/10628)) ([b0c5699](https://github.com/aws/aws-cdk/commit/b0c56999be6a1756b95eb9d976b36598a91c8316)), closes [#10577](https://github.com/aws/aws-cdk/issues/10577) +* **glue:** incorrect s3 prefix used for grant* in Table ([#10627](https://github.com/aws/aws-cdk/issues/10627)) ([4d20079](https://github.com/aws/aws-cdk/commit/4d20079c6c6e8343a3807beb5dbaca841d77c3d6)), closes [#10582](https://github.com/aws/aws-cdk/issues/10582) +* **pipelines:** cannot use constructs in build environment ([#10654](https://github.com/aws/aws-cdk/issues/10654)) ([bf2c629](https://github.com/aws/aws-cdk/commit/bf2c6298358a0eaa7db161798798dda37b1154aa)), closes [#10535](https://github.com/aws/aws-cdk/issues/10535) +* **pipelines:** pipeline doesn't restart if CLI version changes ([#10727](https://github.com/aws/aws-cdk/issues/10727)) ([0297f31](https://github.com/aws/aws-cdk/commit/0297f31ef4224b374a340ba09eeafe963d62e789)), closes [#10659](https://github.com/aws/aws-cdk/issues/10659) +* **rds:** secret for ServerlessCluster is not accessible programmatically ([#10657](https://github.com/aws/aws-cdk/issues/10657)) ([028495e](https://github.com/aws/aws-cdk/commit/028495e55fed02f727024a443fc29a17d4629fe3)) +* **redshift:** Allow redshift cluster securityGroupName to be generated ([#10742](https://github.com/aws/aws-cdk/issues/10742)) ([effed09](https://github.com/aws/aws-cdk/commit/effed09854b6614e75077fd39be8aced69c33582)), closes [#10740](https://github.com/aws/aws-cdk/issues/10740) +* **stepfunctions:** X-Ray policy does not match documentation ([#10721](https://github.com/aws/aws-cdk/issues/10721)) ([8006459](https://github.com/aws/aws-cdk/commit/8006459b9d20542cb9c4d8ca3f10ef5938c67e74)) + ## [1.66.0](https://github.com/aws/aws-cdk/compare/v1.65.0...v1.66.0) (2020-10-02) ### Features diff --git a/lerna.json b/lerna.json index c1ba78ef181d7..22e829805c696 100644 --- a/lerna.json +++ b/lerna.json @@ -11,5 +11,5 @@ "tools/*" ], "rejectCycles": "true", - "version": "1.66.0" + "version": "1.67.0" } From 6b74184bd726a3fa71f9145c52f1ce5042e031f7 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Wed, 7 Oct 2020 10:21:22 -0700 Subject: [PATCH 46/47] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5070abf5bda71..8a1e5a2c31e26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. See [standa ## [1.67.0](https://github.com/aws/aws-cdk/compare/v1.66.0...v1.67.0) (2020-10-07) +### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES + +* **monodk-experiment:** This package is now deprected in favor of `monocdk`. Note that `monocdk` is still experimental. ### Features From 310408449fef737a538b80a51a0496867a37c1f1 Mon Sep 17 00:00:00 2001 From: Neta Nir Date: Wed, 7 Oct 2020 11:05:55 -0700 Subject: [PATCH 47/47] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a1e5a2c31e26..024c058b30cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ All notable changes to this project will be documented in this file. See [standa ### Bug Fixes * **cli:** 'stack already contains Metadata resource' warning ([#10695](https://github.com/aws/aws-cdk/issues/10695)) ([e0b5508](https://github.com/aws/aws-cdk/commit/e0b55086cf9061e579c3c804b4d2e169ec9d7ae2)), closes [#10625](https://github.com/aws/aws-cdk/issues/10625) -* **cli:** `cdk context --reset ` does not work ([#10619](https://github.com/aws/aws-cdk/issues/10619)) ([3f62752](https://github.com/aws/aws-cdk/commit/3f6275265f84cbc04e12660496e9d9eb7cd65354)), closes [#3033](https://github.com/aws/aws-cdk/issues/3033) * **cli:** deploying a transformed template without changes fails ([#10689](https://github.com/aws/aws-cdk/issues/10689)) ([d345919](https://github.com/aws/aws-cdk/commit/d345919800d02b80f40802da60e567d4a30b3521)), closes [#10650](https://github.com/aws/aws-cdk/issues/10650) * **cloudfront-origins:** S3Origins with cross-stack buckets cause cyclic references ([#10696](https://github.com/aws/aws-cdk/issues/10696)) ([0ec4588](https://github.com/aws/aws-cdk/commit/0ec45881e66f598ec37bb772cd01c30be4da96f8)), closes [#10399](https://github.com/aws/aws-cdk/issues/10399) * **codepipeline-actions:** correctly name the triggering Event in CodeCommitSourceAction ([#10706](https://github.com/aws/aws-cdk/issues/10706)) ([ff3a692](https://github.com/aws/aws-cdk/commit/ff3a69285f1f3ae1ff6c6b1495192ce54e46d2fc)), closes [#10665](https://github.com/aws/aws-cdk/issues/10665)