From 83b8df8c390a27e10bf362f49babfb24ee425506 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Fri, 15 Jan 2021 09:12:54 +0200 Subject: [PATCH] chore: eliminate the use of `xxx.Construct` to reduce v2 merge conflicts (#12504) Introduce an eslint rule & fix all instances in our code which refer to `@aws-cdk/core.Construct` using a qualified namespace (e.g. `core.Construct`, `cdk.Construct`, etc). In v2, `Construct` will refer to `constructs.Construct` so it will reduce the chances for merge issues. The rule fixer automatically adds an `import` statement (separated from the main import group) and replaces the usage. If the file already imports `constructs.Construct`, then the new import will alias as `CoreConstruct`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../ecs-service-extensions/lib/environment.ts | 14 +- .../lib/extensions/appmesh.ts | 6 +- .../assign-public-ip/assign-public-ip.ts | 7 +- .../assign-public-ip/task-record-manager.ts | 8 +- .../lib/extensions/cloudwatch-agent.ts | 9 +- .../lib/extensions/container.ts | 9 +- .../lib/extensions/extension-interfaces.ts | 6 +- .../lib/extensions/firelens.ts | 6 +- .../lib/extensions/http-load-balancer.ts | 6 +- .../lib/extensions/xray.ts | 6 +- .../ecs-service-extensions/lib/service.ts | 8 +- .../lib/pipeline-deploy-stack-action.ts | 6 +- .../aws-apigateway/lib/api-definition.ts | 13 +- .../aws-apigateway/lib/apigatewayv2.ts | 26 ++-- .../lib/base-scalable-attribute.ts | 7 +- .../lib/step-scaling-action.ts | 6 +- .../lib/step-scaling-policy.ts | 8 +- .../lib/target-tracking-scaling-policy.ts | 6 +- .../@aws-cdk/aws-appmesh/lib/client-policy.ts | 9 +- .../aws-appmesh/lib/gateway-route-spec.ts | 11 +- .../@aws-cdk/aws-appmesh/lib/route-spec.ts | 13 +- .../aws-appmesh/lib/service-discovery.ts | 11 +- .../aws-appmesh/lib/shared-interfaces.ts | 8 +- .../aws-appmesh/lib/tls-certificate.ts | 11 +- .../lib/virtual-gateway-listener.ts | 8 +- .../aws-appmesh/lib/virtual-node-listener.ts | 8 +- .../lib/virtual-router-listener.ts | 9 +- .../aws-autoscaling/test/scaling.test.ts | 6 +- .../aws-cloudformation/lib/custom-resource.ts | 10 +- .../aws-cloudformation/lib/nested-stack.ts | 6 +- .../test/integ.trivial-lambda-resource.ts | 8 +- .../aws-cloudformation/test/test.resource.ts | 8 +- .../aws-cloudfront-origins/lib/s3-origin.ts | 8 +- .../aws-cloudwatch-actions/lib/appscaling.ts | 7 +- .../aws-cloudwatch-actions/lib/autoscaling.ts | 7 +- .../@aws-cdk/aws-cloudwatch/lib/metric.ts | 8 +- .../lib/linux-gpu-build-image.ts | 6 +- .../lib/cloudformation/pipeline-actions.ts | 18 ++- .../lib/codebuild/build-action.ts | 6 +- .../lib/custom-action-registration.ts | 9 +- .../lib/jenkins/jenkins-provider.ts | 6 +- .../lib/manual-approval-action.ts | 7 +- .../lib/stepfunctions/invoke-action.ts | 6 +- .../lib/private/cross-region-support-stack.ts | 10 +- .../lib/aws-dynamodb-global.ts | 8 +- .../lib/global-table-coordinator.ts | 6 +- .../aws-ec2/test/integ.share-vpcs.lit.ts | 6 +- .../application-load-balanced-service-base.ts | 8 +- .../network-load-balanced-service-base.ts | 8 +- .../aws-ecs/lib/container-definition.ts | 6 +- .../lib/drain-hook/instance-drain-hook.ts | 6 +- .../images/tag-parameter-container-image.ts | 6 +- .../@aws-cdk/aws-ecs/lib/linux-parameters.ts | 6 +- .../alb/application-listener-certificate.ts | 7 +- .../lib/alb/application-listener-rule.ts | 6 +- .../lib/shared/base-target-group.ts | 6 +- .../lib/shared/imported.ts | 6 +- .../test/helpers.ts | 7 +- .../lib/elasticsearch-access-policy.ts | 7 +- .../lib/log-group-resource-policy.ts | 7 +- .../lib/log-group-resource-policy.ts | 6 +- .../lib/endpoint-group.ts | 6 +- .../aws-iam/test/example.attaching.lit.ts | 6 +- .../aws-iam/test/example.external-id.lit.ts | 7 +- .../aws-iam/test/example.managedpolicy.lit.ts | 7 +- .../@aws-cdk/aws-iam/test/example.role.lit.ts | 7 +- .../aws-lambda-nodejs/lib/function.ts | 7 +- .../aws-lambda-python/lib/function.ts | 7 +- .../@aws-cdk/aws-lambda-python/lib/layer.ts | 7 +- packages/@aws-cdk/aws-lambda/lib/code.ts | 18 ++- .../aws-logs/lib/cross-account-destination.ts | 6 +- .../@aws-cdk/aws-logs/lib/log-retention.ts | 8 +- .../@aws-cdk/aws-rds/lib/cluster-engine.ts | 21 +-- .../@aws-cdk/aws-rds/lib/instance-engine.ts | 15 +- packages/@aws-cdk/aws-s3-assets/lib/asset.ts | 6 +- .../lib/bucket-deployment.ts | 6 +- .../@aws-cdk/aws-s3-deployment/lib/source.ts | 11 +- packages/@aws-cdk/aws-s3/lib/destination.ts | 6 +- .../notifications-resource-handler.ts | 10 +- .../notifications-resource.ts | 8 +- .../lib/state-machine-fragment.ts | 7 +- .../aws-stepfunctions/lib/states/state.ts | 7 +- .../aws-custom-resource.ts | 6 +- packages/monocdk/package.json | 2 - tools/cdk-build-tools/bin/cdk-build.ts | 9 +- tools/cdk-build-tools/config/eslintrc.js | 1 + tools/eslint-plugin-cdk/lib/index.ts | 1 + .../lib/private/import-cache.ts | 4 + .../lib/rules/no-qualified-construct.ts | 134 ++++++++++++++++++ 89 files changed, 639 insertions(+), 194 deletions(-) create mode 100644 tools/eslint-plugin-cdk/lib/rules/no-qualified-construct.ts diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/environment.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/environment.ts index dcff0d28960b4..d83c286f0cdd6 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/environment.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/environment.ts @@ -3,6 +3,10 @@ import * as ecs from '@aws-cdk/aws-ecs'; import * as cdk from '@aws-cdk/core'; import { EnvironmentCapacityType } from './extensions/extension-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Settings for the environment you want to deploy. * services within. @@ -64,11 +68,11 @@ export interface IEnvironment { * or it can create it's own VPC and cluster. By default it will create * a cluster with Fargate capacity. */ -export class Environment extends cdk.Construct implements IEnvironment { +export class Environment extends Construct implements IEnvironment { /** * Import an existing environment from its attributes. */ - public static fromEnvironmentAttributes(scope: cdk.Construct, id: string, attrs: EnvironmentAttributes): IEnvironment { + public static fromEnvironmentAttributes(scope: Construct, id: string, attrs: EnvironmentAttributes): IEnvironment { return new ImportedEnvironment(scope, id, attrs); } @@ -94,7 +98,7 @@ export class Environment extends cdk.Construct implements IEnvironment { private readonly scope: cdk.Construct; - constructor(scope: cdk.Construct, id: string, props?: EnvironmentProps) { + constructor(scope: Construct, id: string, props?: EnvironmentProps) { super(scope, id); this.scope = scope; @@ -139,13 +143,13 @@ export interface EnvironmentAttributes { cluster: ecs.ICluster; } -export class ImportedEnvironment extends cdk.Construct implements IEnvironment { +export class ImportedEnvironment extends Construct implements IEnvironment { public readonly capacityType: EnvironmentCapacityType; public readonly cluster: ecs.ICluster; public readonly id: string; public readonly vpc: ec2.IVpc; - constructor(scope: cdk.Construct, id: string, props: EnvironmentAttributes) { + constructor(scope: Construct, id: string, props: EnvironmentAttributes) { super(scope, id); this.id = id; diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts index 65f77a81c9fac..fb93375423798 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts @@ -9,6 +9,10 @@ import { Service } from '../service'; import { Container } from './container'; import { ServiceExtension, ServiceBuild } from './extension-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + // The version of the App Mesh envoy sidecar to add to the task. const APP_MESH_ENVOY_SIDECAR_VERSION = 'v1.15.1.0-prod'; @@ -63,7 +67,7 @@ export class AppMeshExtension extends ServiceExtension { } } - public prehook(service: Service, scope: cdk.Construct) { + public prehook(service: Service, scope: Construct) { this.parentService = service; this.scope = scope; diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/assign-public-ip.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/assign-public-ip.ts index 57f71764019b8..3c019d44867b4 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/assign-public-ip.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/assign-public-ip.ts @@ -1,12 +1,15 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as ecs from '@aws-cdk/aws-ecs'; import * as route53 from '@aws-cdk/aws-route53'; -import * as cdk from '@aws-cdk/core'; import { Service } from '../../service'; import { Container } from '../container'; import { ServiceExtension, ServiceBuild, EnvironmentCapacityType } from '../extension-interfaces'; import { TaskRecordManager } from './task-record-manager'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + export interface AssignPublicIpExtensionOptions { /** * Enable publishing task public IPs to a recordset in a Route 53 hosted zone. @@ -52,7 +55,7 @@ export class AssignPublicIpExtension extends ServiceExtension { return Boolean(this.dns); } - public prehook(service: Service, _scope: cdk.Construct) { + public prehook(service: Service, _scope: Construct) { super.prehook(service, _scope); if (service.capacityType != EnvironmentCapacityType.FARGATE) { diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/task-record-manager.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/task-record-manager.ts index 3772f4432cc04..67db42400ee5b 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/task-record-manager.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/task-record-manager.ts @@ -11,6 +11,10 @@ import * as sqs from '@aws-cdk/aws-sqs'; import * as cdk from '@aws-cdk/core'; import * as customresources from '@aws-cdk/custom-resources'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + export interface TaskRecordManagerProps { service: ecs.Ec2Service | ecs.FargateService; dnsZone: route53.IHostedZone; @@ -21,8 +25,8 @@ export interface TaskRecordManagerProps { * An event-driven serverless app to maintain a list of public ips in a Route 53 * hosted zone. */ -export class TaskRecordManager extends cdk.Construct { - constructor(scope: cdk.Construct, id: string, props: TaskRecordManagerProps) { +export class TaskRecordManager extends Construct { + constructor(scope: Construct, id: string, props: TaskRecordManagerProps) { super(scope, id); // Poison pills go here. diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/cloudwatch-agent.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/cloudwatch-agent.ts index cd59b24f27860..ceed938e995cb 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/cloudwatch-agent.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/cloudwatch-agent.ts @@ -1,9 +1,12 @@ import * as ecs from '@aws-cdk/aws-ecs'; import * as iam from '@aws-cdk/aws-iam'; -import * as cdk from '@aws-cdk/core'; import { Service } from '../service'; import { ServiceExtension } from './extension-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + const CLOUDWATCH_AGENT_IMAGE = 'amazon/cloudwatch-agent:latest'; /** @@ -28,7 +31,7 @@ export class CloudwatchAgentExtension extends ServiceExtension { super('cloudwatchAgent'); } - public prehook(service: Service, scope: cdk.Construct) { + public prehook(service: Service, scope: Construct) { this.parentService = service; this.scope = scope; } @@ -70,4 +73,4 @@ export class CloudwatchAgentExtension extends ServiceExtension { }); } } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/container.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/container.ts index 3ae65bfe6994b..1bbc61ff4f8f7 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/container.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/container.ts @@ -1,8 +1,11 @@ import * as ecs from '@aws-cdk/aws-ecs'; -import * as cdk from '@aws-cdk/core'; import { Service } from '../service'; import { ServiceExtension } from './extension-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Setting for the main application container of a service */ @@ -59,7 +62,7 @@ export class Container extends ServiceExtension { } // @ts-ignore - Ignore unused params that are required for abstract class extend - public prehook(service: Service, scope: cdk.Construct) { + public prehook(service: Service, scope: Construct) { this.parentService = service; } @@ -142,4 +145,4 @@ export class Container extends ServiceExtension { }); } } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/extension-interfaces.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/extension-interfaces.ts index bf1b213a25ba3..fa0d42602c563 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/extension-interfaces.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/extension-interfaces.ts @@ -2,6 +2,10 @@ import * as ecs from '@aws-cdk/aws-ecs'; import * as cdk from '@aws-cdk/core'; import { Service } from '../service'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * A list of the capacity types that are supported. These * capacity types may change the behavior of an extension. @@ -154,7 +158,7 @@ export abstract class ServiceExtension { * @param parent - The parent service which this extension has been added to * @param scope - The scope that this extension should create resources in */ - public prehook(parent: Service, scope: cdk.Construct) { + public prehook(parent: Service, scope: Construct) { this.parentService = parent; this.scope = scope; } diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/firelens.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/firelens.ts index 03c23e015eaf7..1dfc8e1f1b0b0 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/firelens.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/firelens.ts @@ -5,6 +5,10 @@ import { Service } from '../service'; import { Container } from './container'; import { ContainerMutatingHook, ServiceExtension } from './extension-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Settings for the hook which mutates the application container * to route logs through FireLens @@ -63,7 +67,7 @@ export class FireLensExtension extends ServiceExtension { super('firelens'); } - public prehook(service: Service, scope: cdk.Construct) { + public prehook(service: Service, scope: Construct) { this.parentService = service; // Create a log group for the service, into which FireLens diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/http-load-balancer.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/http-load-balancer.ts index c00481d1f424c..884477b4d38db 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/http-load-balancer.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/http-load-balancer.ts @@ -4,6 +4,10 @@ import * as cdk from '@aws-cdk/core'; import { Service } from '../service'; import { ServiceExtension, ServiceBuild } from './extension-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * This extension add a public facing load balancer for sending traffic * to one or more replicas of the application container @@ -17,7 +21,7 @@ export class HttpLoadBalancerExtension extends ServiceExtension { } // Before the service is created go ahead and create the load balancer itself. - public prehook(service: Service, scope: cdk.Construct) { + public prehook(service: Service, scope: Construct) { this.parentService = service; this.loadBalancer = new alb.ApplicationLoadBalancer(scope, `${this.parentService.id}-load-balancer`, { diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/xray.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/xray.ts index 3ba344f4133d8..5e9affe0ffa3a 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/xray.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/xray.ts @@ -4,6 +4,10 @@ import * as cdk from '@aws-cdk/core'; import { Service } from '../service'; import { ServiceExtension } from './extension-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + const XRAY_DAEMON_IMAGE = 'amazon/aws-xray-daemon:latest'; /** @@ -17,7 +21,7 @@ export class XRayExtension extends ServiceExtension { } // @ts-ignore - Ignore unused params that are required for abstract class extend - public prehook(service: Service, scope: cdk.Construct) { + public prehook(service: Service, scope: Construct) { this.parentService = service; } diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/lib/service.ts b/packages/@aws-cdk-containers/ecs-service-extensions/lib/service.ts index 29134a8c83260..c988c0592b6bf 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/lib/service.ts +++ b/packages/@aws-cdk-containers/ecs-service-extensions/lib/service.ts @@ -5,6 +5,10 @@ import { IEnvironment } from './environment'; import { EnvironmentCapacityType, ServiceBuild } from './extensions/extension-interfaces'; import { ServiceDescription } from './service-description'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * The settings for an ECS Service */ @@ -24,7 +28,7 @@ export interface ServiceProps { * A service builder class. This construct support various extensions * which can construct an ECS service progressively. */ -export class Service extends cdk.Construct { +export class Service extends Construct { /** * The underlying ECS service that was created */ @@ -74,7 +78,7 @@ export class Service extends cdk.Construct { private readonly scope: cdk.Construct; - constructor(scope: cdk.Construct, id: string, props: ServiceProps) { + constructor(scope: Construct, id: string, props: ServiceProps) { super(scope, id); this.scope = scope; diff --git a/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts b/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts index 03685cfc9c413..cd7f97e6629a1 100644 --- a/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts +++ b/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts @@ -6,6 +6,10 @@ import * as iam from '@aws-cdk/aws-iam'; import * as cxschema from '@aws-cdk/cloud-assembly-schema'; import * as cdk from '@aws-cdk/core'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + export interface PipelineDeployStackActionProps { /** * The CDK stack to be deployed. @@ -147,7 +151,7 @@ export class PipelineDeployStackAction implements codepipeline.IAction { }); } - public bind(scope: cdk.Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + public bind(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { if (this.stack.environment !== cdk.Stack.of(scope).environment) { // FIXME: Add the necessary to extend to stacks in a different account diff --git a/packages/@aws-cdk/aws-apigateway/lib/api-definition.ts b/packages/@aws-cdk/aws-apigateway/lib/api-definition.ts index 652c531de9c38..01be9ebd17c59 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/api-definition.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/api-definition.ts @@ -1,6 +1,9 @@ import * as s3 from '@aws-cdk/aws-s3'; import * as s3_assets from '@aws-cdk/aws-s3-assets'; -import * as cdk from '@aws-cdk/core'; + +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; /** * Represents an OpenAPI definition asset. @@ -80,7 +83,7 @@ export abstract class ApiDefinition { * @param scope The binding scope. Don't be smart about trying to down-cast or * assume it's initialized. You may just use it as a construct scope. */ - public abstract bind(scope: cdk.Construct): ApiDefinitionConfig; + public abstract bind(scope: Construct): ApiDefinitionConfig; } /** @@ -136,7 +139,7 @@ export class S3ApiDefinition extends ApiDefinition { this.bucketName = bucket.bucketName; } - public bind(_scope: cdk.Construct): ApiDefinitionConfig { + public bind(_scope: Construct): ApiDefinitionConfig { return { s3Location: { bucket: this.bucketName, @@ -164,7 +167,7 @@ export class InlineApiDefinition extends ApiDefinition { } } - public bind(_scope: cdk.Construct): ApiDefinitionConfig { + public bind(_scope: Construct): ApiDefinitionConfig { return { inlineDefinition: this.definition, }; @@ -182,7 +185,7 @@ export class AssetApiDefinition extends ApiDefinition { super(); } - public bind(scope: cdk.Construct): ApiDefinitionConfig { + public bind(scope: Construct): ApiDefinitionConfig { // If the same AssetAPIDefinition is used multiple times, retain only the first instantiation. if (this.asset === undefined) { this.asset = new s3_assets.Asset(scope, 'APIDefinition', { diff --git a/packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts b/packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts index e04bcef476fca..98ee1ba04acbf 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts @@ -5,6 +5,10 @@ import * as cdk from '@aws-cdk/core'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for defining a `AWS::ApiGatewayV2::Api` * @@ -288,7 +292,7 @@ export class CfnApiV2 extends cdk.CfnResource implements cdk.IInspectable { * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnApiV2Props = {}) { + constructor(scope: Construct, id: string, props: CfnApiV2Props = {}) { super(scope, id, { type: CfnApiV2.CFN_RESOURCE_TYPE_NAME, properties: props }); this.apiKeySelectionExpression = props.apiKeySelectionExpression; @@ -616,7 +620,7 @@ export class CfnApiMappingV2 extends cdk.CfnResource implements cdk.IInspectable * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnApiMappingV2Props) { + constructor(scope: Construct, id: string, props: CfnApiMappingV2Props) { super(scope, id, { type: CfnApiMappingV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'domainName', this); @@ -842,7 +846,7 @@ export class CfnAuthorizerV2 extends cdk.CfnResource implements cdk.IInspectable * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnAuthorizerV2Props) { + constructor(scope: Construct, id: string, props: CfnAuthorizerV2Props) { super(scope, id, { type: CfnAuthorizerV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'authorizerType', this); @@ -1047,7 +1051,7 @@ export class CfnDeploymentV2 extends cdk.CfnResource implements cdk.IInspectable * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnDeploymentV2Props) { + constructor(scope: Construct, id: string, props: CfnDeploymentV2Props) { super(scope, id, { type: CfnDeploymentV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); @@ -1192,7 +1196,7 @@ export class CfnDomainNameV2 extends cdk.CfnResource implements cdk.IInspectable * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnDomainNameV2Props) { + constructor(scope: Construct, id: string, props: CfnDomainNameV2Props) { super(scope, id, { type: CfnDomainNameV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'domainName', this); this.attrRegionalDomainName = cdk.Token.asString(this.getAtt('RegionalDomainName')); @@ -1546,7 +1550,7 @@ export class CfnIntegrationV2 extends cdk.CfnResource implements cdk.IInspectabl * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnIntegrationV2Props) { + constructor(scope: Construct, id: string, props: CfnIntegrationV2Props) { super(scope, id, { type: CfnIntegrationV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'integrationType', this); @@ -1762,7 +1766,7 @@ export class CfnIntegrationResponseV2 extends cdk.CfnResource implements cdk.IIn * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnIntegrationResponseV2Props) { + constructor(scope: Construct, id: string, props: CfnIntegrationResponseV2Props) { super(scope, id, { type: CfnIntegrationResponseV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'integrationId', this); @@ -1937,7 +1941,7 @@ export class CfnModelV2 extends cdk.CfnResource implements cdk.IInspectable { * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnModelV2Props) { + constructor(scope: Construct, id: string, props: CfnModelV2Props) { super(scope, id, { type: CfnModelV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'name', this); @@ -2205,7 +2209,7 @@ export class CfnRouteV2 extends cdk.CfnResource implements cdk.IInspectable { * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnRouteV2Props) { + constructor(scope: Construct, id: string, props: CfnRouteV2Props) { super(scope, id, { type: CfnRouteV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'routeKey', this); @@ -2452,7 +2456,7 @@ export class CfnRouteResponseV2 extends cdk.CfnResource implements cdk.IInspecta * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnRouteResponseV2Props) { + constructor(scope: Construct, id: string, props: CfnRouteResponseV2Props) { super(scope, id, { type: CfnRouteResponseV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'routeId', this); @@ -2757,7 +2761,7 @@ export class CfnStageV2 extends cdk.CfnResource implements cdk.IInspectable { * @param id - scoped id of the resource * @param props - resource properties */ - constructor(scope: cdk.Construct, id: string, props: CfnStageV2Props) { + constructor(scope: Construct, id: string, props: CfnStageV2Props) { super(scope, id, { type: CfnStageV2.CFN_RESOURCE_TYPE_NAME, properties: props }); cdk.requireProperty(props, 'apiId', this); cdk.requireProperty(props, 'stageName', this); diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/base-scalable-attribute.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/base-scalable-attribute.ts index ee955d6d120d1..762da275c33a5 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/base-scalable-attribute.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/base-scalable-attribute.ts @@ -1,10 +1,13 @@ import * as iam from '@aws-cdk/aws-iam'; -import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { ScalableTarget, ScalingSchedule, ServiceNamespace } from './scalable-target'; import { BasicStepScalingPolicyProps } from './step-scaling-policy'; import { BasicTargetTrackingScalingPolicyProps } from './target-tracking-scaling-policy'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Properties for a ScalableTableAttribute */ @@ -44,7 +47,7 @@ export interface BaseScalableAttributeProps extends EnableScalingProps { * - Don't expose all scaling methods (for example Dynamo tables don't support * Step Scaling, so the Dynamo subclass won't expose this method). */ -export abstract class BaseScalableAttribute extends cdk.Construct { +export abstract class BaseScalableAttribute extends CoreConstruct { private target: ScalableTarget; public constructor(scope: Construct, id: string, protected readonly props: BaseScalableAttributeProps) { diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts index 4cb7aa2328ebc..67021e74f71bf 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-action.ts @@ -3,6 +3,10 @@ import { Construct } from 'constructs'; import { CfnScalingPolicy } from './applicationautoscaling.generated'; import { IScalableTarget } from './scalable-target'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Properties for a scaling policy */ @@ -67,7 +71,7 @@ export interface StepScalingActionProps { * * This Action must be used as the target of a CloudWatch alarm to take effect. */ -export class StepScalingAction extends cdk.Construct { +export class StepScalingAction extends CoreConstruct { /** * ARN of the scaling policy */ diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts index 455e9ebbbd9e9..417ecf34f1970 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts @@ -5,6 +5,10 @@ import { Construct } from 'constructs'; import { IScalableTarget } from './scalable-target'; import { AdjustmentType, MetricAggregationType, StepScalingAction } from './step-scaling-action'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + export interface BasicStepScalingPolicyProps { /** * Metric to scale on. @@ -63,7 +67,7 @@ export interface StepScalingPolicyProps extends BasicStepScalingPolicyProps { * * Implemented using one or more CloudWatch alarms and Step Scaling Policies. */ -export class StepScalingPolicy extends cdk.Construct { +export class StepScalingPolicy extends CoreConstruct { public readonly lowerAlarm?: cloudwatch.Alarm; public readonly lowerAction?: StepScalingAction; public readonly upperAlarm?: cloudwatch.Alarm; @@ -210,7 +214,7 @@ class StepScalingAlarmAction implements cloudwatch.IAlarmAction { constructor(private readonly stepScalingAction: StepScalingAction) { } - public bind(_scope: cdk.Construct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig { + public bind(_scope: CoreConstruct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig { return { alarmActionArn: this.stepScalingAction.scalingPolicyArn }; } } diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts index 65146b754757b..2262f53e03522 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts @@ -4,6 +4,10 @@ import { Construct } from 'constructs'; import { CfnScalingPolicy } from './applicationautoscaling.generated'; import { IScalableTarget } from './scalable-target'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Base interface for target tracking props * @@ -115,7 +119,7 @@ export interface TargetTrackingScalingPolicyProps extends BasicTargetTrackingSca readonly scalingTarget: IScalableTarget; } -export class TargetTrackingScalingPolicy extends cdk.Construct { +export class TargetTrackingScalingPolicy extends CoreConstruct { /** * ARN of the scaling policy */ diff --git a/packages/@aws-cdk/aws-appmesh/lib/client-policy.ts b/packages/@aws-cdk/aws-appmesh/lib/client-policy.ts index 03236ee1c8f32..8f39b88399111 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/client-policy.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/client-policy.ts @@ -1,7 +1,10 @@ import * as acmpca from '@aws-cdk/aws-acmpca'; -import * as cdk from '@aws-cdk/core'; import { CfnVirtualNode } from './appmesh.generated'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + enum CertificateType { ACMPCA = 'acm', FILE = 'file', @@ -71,7 +74,7 @@ export abstract class ClientPolicy { /** * Returns Trust context based on trust type. */ - public abstract bind(scope: cdk.Construct): ClientPolicyConfig; + public abstract bind(scope: Construct): ClientPolicyConfig; } @@ -81,7 +84,7 @@ class ClientPolicyImpl extends ClientPolicy { private readonly certificateChain: string | undefined, private readonly certificateAuthorityArns: acmpca.ICertificateAuthority[] | undefined) { super(); } - public bind(_scope: cdk.Construct): ClientPolicyConfig { + public bind(_scope: Construct): ClientPolicyConfig { if (this.certificateType === CertificateType.ACMPCA && this.certificateAuthorityArns?.map(certificateArn => certificateArn.certificateAuthorityArn).length === 0) { throw new Error('You must provide at least one Certificate Authority when creating an ACM Trust ClientPolicy'); diff --git a/packages/@aws-cdk/aws-appmesh/lib/gateway-route-spec.ts b/packages/@aws-cdk/aws-appmesh/lib/gateway-route-spec.ts index 525bc4d2ba7e0..0a90fb1632ff9 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/gateway-route-spec.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/gateway-route-spec.ts @@ -1,8 +1,11 @@ -import * as cdk from '@aws-cdk/core'; import { CfnGatewayRoute } from './appmesh.generated'; import { Protocol } from './shared-interfaces'; import { IVirtualService } from './virtual-service'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * The criterion for determining a request match for this GatewayRoute */ @@ -119,7 +122,7 @@ export abstract class GatewayRouteSpec { * Called when the GatewayRouteSpec type is initialized. Can be used to enforce * mutual exclusivity with future properties */ - public abstract bind(scope: cdk.Construct): GatewayRouteSpecConfig; + public abstract bind(scope: Construct): GatewayRouteSpecConfig; } class HttpGatewayRouteSpec extends GatewayRouteSpec { @@ -147,7 +150,7 @@ class HttpGatewayRouteSpec extends GatewayRouteSpec { this.match = options.match; } - public bind(_scope: cdk.Construct): GatewayRouteSpecConfig { + public bind(_scope: Construct): GatewayRouteSpecConfig { const prefixPath = this.match ? this.match.prefixPath : '/'; if (prefixPath[0] != '/') { throw new Error(`Prefix Path must start with \'/\', got: ${prefixPath}`); @@ -190,7 +193,7 @@ class GrpcGatewayRouteSpec extends GatewayRouteSpec { this.routeTarget = options.routeTarget; } - public bind(_scope: cdk.Construct): GatewayRouteSpecConfig { + public bind(_scope: Construct): GatewayRouteSpecConfig { return { grpcSpecConfig: { action: { diff --git a/packages/@aws-cdk/aws-appmesh/lib/route-spec.ts b/packages/@aws-cdk/aws-appmesh/lib/route-spec.ts index b3ce09f0c0031..74b16976b69ca 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/route-spec.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/route-spec.ts @@ -1,8 +1,11 @@ -import * as cdk from '@aws-cdk/core'; import { CfnRoute } from './appmesh.generated'; import { Protocol, HttpTimeout, GrpcTimeout, TcpTimeout } from './shared-interfaces'; import { IVirtualNode } from './virtual-node'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for the Weighted Targets in the route */ @@ -176,7 +179,7 @@ export abstract class RouteSpec { * Called when the GatewayRouteSpec type is initialized. Can be used to enforce * mutual exclusivity with future properties */ - public abstract bind(scope: cdk.Construct): RouteSpecConfig; + public abstract bind(scope: Construct): RouteSpecConfig; } class HttpRouteSpec extends RouteSpec { @@ -208,7 +211,7 @@ class HttpRouteSpec extends RouteSpec { this.timeout = props.timeout; } - public bind(_scope: cdk.Construct): RouteSpecConfig { + public bind(_scope: Construct): RouteSpecConfig { const prefixPath = this.match ? this.match.prefixPath : '/'; if (prefixPath[0] != '/') { throw new Error(`Prefix Path must start with \'/\', got: ${prefixPath}`); @@ -246,7 +249,7 @@ class TcpRouteSpec extends RouteSpec { this.timeout = props.timeout; } - public bind(_scope: cdk.Construct): RouteSpecConfig { + public bind(_scope: Construct): RouteSpecConfig { return { tcpRouteSpec: { action: { @@ -270,7 +273,7 @@ class GrpcRouteSpec extends RouteSpec { this.timeout = props.timeout; } - public bind(_scope: cdk.Construct): RouteSpecConfig { + public bind(_scope: Construct): RouteSpecConfig { return { grpcRouteSpec: { action: { diff --git a/packages/@aws-cdk/aws-appmesh/lib/service-discovery.ts b/packages/@aws-cdk/aws-appmesh/lib/service-discovery.ts index b5fca6525c851..961357945a16b 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/service-discovery.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/service-discovery.ts @@ -1,7 +1,10 @@ import * as cloudmap from '@aws-cdk/aws-servicediscovery'; -import * as cdk from '@aws-cdk/core'; import { CfnVirtualNode } from './appmesh.generated'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Represents the properties needed to define CloudMap Service Discovery @@ -63,7 +66,7 @@ export abstract class ServiceDiscovery { /** * Binds the current object when adding Service Discovery to a VirtualNode */ - public abstract bind(scope: cdk.Construct): ServiceDiscoveryConfig; + public abstract bind(scope: Construct): ServiceDiscoveryConfig; } class DnsServiceDiscovery extends ServiceDiscovery { @@ -74,7 +77,7 @@ class DnsServiceDiscovery extends ServiceDiscovery { this.hostname = hostname; } - public bind(_scope: cdk.Construct): ServiceDiscoveryConfig { + public bind(_scope: Construct): ServiceDiscoveryConfig { return { dns: { hostname: this.hostname, @@ -93,7 +96,7 @@ class CloudMapServiceDiscovery extends ServiceDiscovery { this.instanceAttributes = options.instanceAttributes; } - public bind(_scope: cdk.Construct): ServiceDiscoveryConfig { + public bind(_scope: Construct): ServiceDiscoveryConfig { return { cloudmap: { namespaceName: this.service.namespace.namespaceName, diff --git a/packages/@aws-cdk/aws-appmesh/lib/shared-interfaces.ts b/packages/@aws-cdk/aws-appmesh/lib/shared-interfaces.ts index cbd574489f9c4..831db66e49e0c 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/shared-interfaces.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/shared-interfaces.ts @@ -1,6 +1,10 @@ import * as cdk from '@aws-cdk/core'; import { CfnVirtualGateway, CfnVirtualNode } from './appmesh.generated'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Represents timeouts for HTTP protocols. */ @@ -155,7 +159,7 @@ export abstract class AccessLog { * Called when the AccessLog type is initialized. Can be used to enforce * mutual exclusivity with future properties */ - public abstract bind(scope: cdk.Construct): AccessLogConfig; + public abstract bind(scope: Construct): AccessLogConfig; } /** @@ -174,7 +178,7 @@ class FileAccessLog extends AccessLog { this.filePath = filePath; } - public bind(_scope: cdk.Construct): AccessLogConfig { + public bind(_scope: Construct): AccessLogConfig { return { virtualNodeAccessLog: { file: { diff --git a/packages/@aws-cdk/aws-appmesh/lib/tls-certificate.ts b/packages/@aws-cdk/aws-appmesh/lib/tls-certificate.ts index 524eb079d8702..ec227fb13df99 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/tls-certificate.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/tls-certificate.ts @@ -1,7 +1,10 @@ import * as acm from '@aws-cdk/aws-certificatemanager'; -import * as cdk from '@aws-cdk/core'; import { CfnVirtualNode } from './appmesh.generated'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Enum of supported TLS modes */ @@ -93,7 +96,7 @@ export abstract class TlsCertificate { /** * Returns TLS certificate based provider. */ - public abstract bind(_scope: cdk.Construct): TlsCertificateConfig; + public abstract bind(_scope: Construct): TlsCertificateConfig; } @@ -119,7 +122,7 @@ class AcmTlsCertificate extends TlsCertificate { this.acmCertificate = props.certificate; } - bind(_scope: cdk.Construct): TlsCertificateConfig { + bind(_scope: Construct): TlsCertificateConfig { return { tlsCertificate: { acm: { @@ -159,7 +162,7 @@ class FileTlsCertificate extends TlsCertificate { this.privateKey = props.privateKeyPath; } - bind(_scope: cdk.Construct): TlsCertificateConfig { + bind(_scope: Construct): TlsCertificateConfig { return { tlsCertificate: { file: { diff --git a/packages/@aws-cdk/aws-appmesh/lib/virtual-gateway-listener.ts b/packages/@aws-cdk/aws-appmesh/lib/virtual-gateway-listener.ts index afe21479ede0c..9f081ffdefd60 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/virtual-gateway-listener.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/virtual-gateway-listener.ts @@ -4,6 +4,10 @@ import { validateHealthChecks } from './private/utils'; import { HealthCheck, Protocol } from './shared-interfaces'; import { TlsCertificate, TlsCertificateConfig } from './tls-certificate'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Represents the properties needed to define HTTP Listeners for a VirtualGateway */ @@ -95,7 +99,7 @@ export abstract class VirtualGatewayListener { * Called when the GatewayListener type is initialized. Can be used to enforce * mutual exclusivity */ - public abstract bind(scope: cdk.Construct): VirtualGatewayListenerConfig; + public abstract bind(scope: Construct): VirtualGatewayListenerConfig; } /** @@ -114,7 +118,7 @@ class VirtualGatewayListenerImpl extends VirtualGatewayListener { * Called when the GatewayListener type is initialized. Can be used to enforce * mutual exclusivity */ - public bind(scope: cdk.Construct): VirtualGatewayListenerConfig { + public bind(scope: Construct): VirtualGatewayListenerConfig { const tlsConfig = this.tlsCertificate?.bind(scope); return { listener: { diff --git a/packages/@aws-cdk/aws-appmesh/lib/virtual-node-listener.ts b/packages/@aws-cdk/aws-appmesh/lib/virtual-node-listener.ts index 332e7c5771d15..883d05583d5c7 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/virtual-node-listener.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/virtual-node-listener.ts @@ -4,6 +4,10 @@ import { validateHealthChecks } from './private/utils'; import { HealthCheck, Protocol, HttpTimeout, GrpcTimeout, TcpTimeout } from './shared-interfaces'; import { TlsCertificate, TlsCertificateConfig } from './tls-certificate'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for a VirtualNode listener */ @@ -111,7 +115,7 @@ export abstract class VirtualNodeListener { /** * Binds the current object when adding Listener to a VirtualNode */ - public abstract bind(scope: cdk.Construct): VirtualNodeListenerConfig; + public abstract bind(scope: Construct): VirtualNodeListenerConfig; } @@ -122,7 +126,7 @@ class VirtualNodeListenerImpl extends VirtualNodeListener { private readonly port: number = 8080, private readonly tlsCertificate: TlsCertificate | undefined) { super(); } - public bind(scope: cdk.Construct): VirtualNodeListenerConfig { + public bind(scope: Construct): VirtualNodeListenerConfig { const tlsConfig = this.tlsCertificate?.bind(scope); return { listener: { diff --git a/packages/@aws-cdk/aws-appmesh/lib/virtual-router-listener.ts b/packages/@aws-cdk/aws-appmesh/lib/virtual-router-listener.ts index 7a5e867d0b7c9..ced6279d78664 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/virtual-router-listener.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/virtual-router-listener.ts @@ -1,7 +1,10 @@ -import * as cdk from '@aws-cdk/core'; import { CfnVirtualRouter } from './appmesh.generated'; import { Protocol } from './shared-interfaces'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for a VirtualRouter listener */ @@ -56,7 +59,7 @@ export abstract class VirtualRouterListener { * Called when the VirtualRouterListener type is initialized. Can be used to enforce * mutual exclusivity */ - public abstract bind(scope: cdk.Construct): VirtualRouterListenerConfig; + public abstract bind(scope: Construct): VirtualRouterListenerConfig; } class VirtualRouterListenerImpl extends VirtualRouterListener { @@ -69,7 +72,7 @@ class VirtualRouterListenerImpl extends VirtualRouterListener { this.port = port ?? 8080; } - bind(_scope: cdk.Construct): VirtualRouterListenerConfig { + bind(_scope: Construct): VirtualRouterListenerConfig { return { listener: { portMapping: { diff --git a/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts b/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts index 86604a52d3404..5207897cd1786 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/scaling.test.ts @@ -7,6 +7,10 @@ import * as constructs from 'constructs'; import { nodeunitShim, Test } from 'nodeunit-shim'; import * as autoscaling from '../lib'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + nodeunitShim({ 'target tracking policies': { 'cpu utilization'(test: Test) { @@ -273,7 +277,7 @@ nodeunitShim({ }, }); -class ASGFixture extends cdk.Construct { +class ASGFixture extends Construct { public readonly vpc: ec2.Vpc; public readonly asg: autoscaling.AutoScalingGroup; diff --git a/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts b/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts index 93ac7d4b9913a..a36411c8504f3 100644 --- a/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts +++ b/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts @@ -2,6 +2,10 @@ import * as lambda from '@aws-cdk/aws-lambda'; import * as sns from '@aws-cdk/aws-sns'; import * as core from '@aws-cdk/core'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Collection of arbitrary properties */ @@ -28,7 +32,7 @@ export interface ICustomResourceProvider { * @param scope The resource that uses this provider. * @returns provider configuration */ - bind(scope: core.Construct): CustomResourceProviderConfig; + bind(scope: Construct): CustomResourceProviderConfig; } /** @@ -68,7 +72,7 @@ export class CustomResourceProvider implements ICustomResourceProvider { */ private constructor(public readonly serviceToken: string) { } - public bind(_: core.Construct): CustomResourceProviderConfig { + public bind(_: Construct): CustomResourceProviderConfig { return { serviceToken: this.serviceToken }; } } @@ -151,7 +155,7 @@ export interface CustomResourceProps { * @deprecated use `core.CustomResource` */ export class CustomResource extends core.CustomResource { - constructor(scope: core.Construct, id: string, props: CustomResourceProps) { + constructor(scope: Construct, id: string, props: CustomResourceProps) { super(scope, id, { pascalCaseProperties: true, properties: props.properties, diff --git a/packages/@aws-cdk/aws-cloudformation/lib/nested-stack.ts b/packages/@aws-cdk/aws-cloudformation/lib/nested-stack.ts index bb9481d2a75c2..81487ac1470b4 100644 --- a/packages/@aws-cdk/aws-cloudformation/lib/nested-stack.ts +++ b/packages/@aws-cdk/aws-cloudformation/lib/nested-stack.ts @@ -1,6 +1,10 @@ import * as sns from '@aws-cdk/aws-sns'; import * as core from '@aws-cdk/core'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Initialization props for the `NestedStack` construct. * @@ -63,7 +67,7 @@ export interface NestedStackProps { * @experimental */ export class NestedStack extends core.NestedStack { - constructor(scope: core.Construct, id: string, props: NestedStackProps = { }) { + constructor(scope: Construct, id: string, props: NestedStackProps = { }) { super(scope, id, { parameters: props.parameters, timeout: props.timeout, 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 e18bafe3736a8..5d2b63f9b88b0 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,10 @@ import * as lambda from '@aws-cdk/aws-lambda'; import * as cdk from '@aws-cdk/core'; import { CustomResource, CustomResourceProvider } from '../lib'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /* eslint-disable cdk/no-core-construct */ interface DemoResourceProps { @@ -17,10 +21,10 @@ interface DemoResourceProps { failCreate?: boolean; } -class DemoResource extends cdk.Construct { +class DemoResource extends Construct { public readonly response: string; - constructor(scope: cdk.Construct, id: string, props: DemoResourceProps) { + constructor(scope: Construct, id: string, props: DemoResourceProps) { super(scope, id); const resource = new CustomResource(this, 'Resource', { diff --git a/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts b/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts index 9f90779190d71..7015fe21bf948 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/test.resource.ts @@ -5,6 +5,10 @@ import * as cdk from '@aws-cdk/core'; import { Test, testCase } from 'nodeunit'; import { CustomResource, CustomResourceProvider } from '../lib'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /* eslint-disable cdk/no-core-construct */ /* eslint-disable quote-props */ @@ -212,10 +216,10 @@ export = testCase({ }, }); -class TestCustomResource extends cdk.Construct { +class TestCustomResource extends Construct { public readonly resource: CustomResource; - constructor(scope: cdk.Construct, id: string, opts: { removalPolicy?: cdk.RemovalPolicy } = {}) { + constructor(scope: Construct, id: string, opts: { removalPolicy?: cdk.RemovalPolicy } = {}) { super(scope, id); const singletonLambda = new lambda.SingletonFunction(this, 'Lambda', { 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 948b3390ebea1..518e3e728ec1a 100644 --- a/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts +++ b/packages/@aws-cdk/aws-cloudfront-origins/lib/s3-origin.ts @@ -3,6 +3,10 @@ import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; import { HttpOrigin } from './http-origin'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties to use to customize an S3 Origin. */ @@ -41,7 +45,7 @@ export class S3Origin implements cloudfront.IOrigin { new S3BucketOrigin(bucket, props); } - public bind(scope: cdk.Construct, options: cloudfront.OriginBindOptions): cloudfront.OriginBindConfig { + public bind(scope: Construct, options: cloudfront.OriginBindOptions): cloudfront.OriginBindConfig { return this.origin.bind(scope, options); } } @@ -61,7 +65,7 @@ class S3BucketOrigin extends cloudfront.OriginBase { } } - public bind(scope: cdk.Construct, options: cloudfront.OriginBindOptions): cloudfront.OriginBindConfig { + public bind(scope: Construct, options: cloudfront.OriginBindOptions): cloudfront.OriginBindConfig { if (!this.originAccessIdentity) { // Using a bucket from another stack creates a cyclic reference with // the bucket taking a dependency on the generated S3CanonicalUserId when `grantRead` is called, diff --git a/packages/@aws-cdk/aws-cloudwatch-actions/lib/appscaling.ts b/packages/@aws-cdk/aws-cloudwatch-actions/lib/appscaling.ts index 2241796f47d2b..a37f6badf5ecb 100644 --- a/packages/@aws-cdk/aws-cloudwatch-actions/lib/appscaling.ts +++ b/packages/@aws-cdk/aws-cloudwatch-actions/lib/appscaling.ts @@ -1,6 +1,9 @@ import * as appscaling from '@aws-cdk/aws-applicationautoscaling'; import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; -import * as cdk from '@aws-cdk/core'; + +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; /** * Use an ApplicationAutoScaling StepScalingAction as an Alarm Action @@ -13,7 +16,7 @@ export class ApplicationScalingAction implements cloudwatch.IAlarmAction { * Returns an alarm action configuration to use an ApplicationScaling StepScalingAction * as an alarm action */ - public bind(_scope: cdk.Construct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig { + public bind(_scope: Construct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig { return { alarmActionArn: this.stepScalingAction.scalingPolicyArn }; } } diff --git a/packages/@aws-cdk/aws-cloudwatch-actions/lib/autoscaling.ts b/packages/@aws-cdk/aws-cloudwatch-actions/lib/autoscaling.ts index 5ec6e62fe246c..2ce075d4cd129 100644 --- a/packages/@aws-cdk/aws-cloudwatch-actions/lib/autoscaling.ts +++ b/packages/@aws-cdk/aws-cloudwatch-actions/lib/autoscaling.ts @@ -1,6 +1,9 @@ import * as autoscaling from '@aws-cdk/aws-autoscaling'; import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; -import * as cdk from '@aws-cdk/core'; + +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; /** * Use an AutoScaling StepScalingAction as an Alarm Action @@ -13,7 +16,7 @@ export class AutoScalingAction implements cloudwatch.IAlarmAction { * Returns an alarm action configuration to use an AutoScaling StepScalingAction * as an alarm action */ - public bind(_scope: cdk.Construct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig { + public bind(_scope: Construct, _alarm: cloudwatch.IAlarm): cloudwatch.AlarmActionConfig { return { alarmActionArn: this.stepScalingAction.scalingPolicyArn }; } } diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts b/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts index 3cc51050341b0..fa900333ef0fa 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts @@ -6,6 +6,10 @@ import { Dimension, IMetric, MetricAlarmConfig, MetricConfig, MetricGraphConfig, import { dispatchMetric, metricKey } from './private/metric-util'; import { normalizeStatistic, parseStatistic } from './private/statistic'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + export type DimensionHash = {[dim: string]: any}; /** @@ -351,7 +355,7 @@ export class Metric implements IMetric { * Combines both properties that may adjust the metric (aggregation) as well * as alarm properties. */ - public createAlarm(scope: cdk.Construct, id: string, props: CreateAlarmOptions): Alarm { + public createAlarm(scope: Construct, id: string, props: CreateAlarmOptions): Alarm { return new Alarm(scope, id, { metric: this.with({ statistic: props.statistic, @@ -503,7 +507,7 @@ export class MathExpression implements IMetric { * Combines both properties that may adjust the metric (aggregation) as well * as alarm properties. */ - public createAlarm(scope: cdk.Construct, id: string, props: CreateAlarmOptions): Alarm { + public createAlarm(scope: Construct, id: string, props: CreateAlarmOptions): Alarm { return new Alarm(scope, id, { metric: this.with({ period: props.period, diff --git a/packages/@aws-cdk/aws-codebuild/lib/linux-gpu-build-image.ts b/packages/@aws-cdk/aws-codebuild/lib/linux-gpu-build-image.ts index b3f4c1d6dad61..6cbf5bcfc2f7e 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/linux-gpu-build-image.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/linux-gpu-build-image.ts @@ -8,6 +8,10 @@ import { ImagePullPrincipalType, IProject, } from './project'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + const mappingName = 'AwsDeepLearningContainersRepositoriesAccounts'; /** @@ -99,7 +103,7 @@ export class LinuxGpuBuildImage implements IBindableBuildImage { this.imageId = `${this.accountExpression}.dkr.ecr.${core.Aws.REGION}.${core.Aws.URL_SUFFIX}/${repositoryName}:${tag}`; } - public bind(scope: core.Construct, project: IProject, _options: BuildImageBindOptions): BuildImageConfig { + public bind(scope: Construct, project: IProject, _options: BuildImageBindOptions): BuildImageConfig { if (!this.account) { const scopeStack = core.Stack.of(scope); // Unfortunately, the account IDs of the DLC repositories are not the same in all regions. diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts index 1ba14d469120d..b4a300d887ad4 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts @@ -4,6 +4,10 @@ import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; import { Action } from '../action'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties common to all CloudFormation actions */ @@ -82,7 +86,7 @@ abstract class CloudFormationAction extends Action { this.props = props; } - protected bound(_scope: cdk.Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(_scope: Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { const singletonPolicy = SingletonPolicy.forRole(options.role); @@ -123,7 +127,7 @@ export class CloudFormationExecuteChangeSetAction extends CloudFormationAction { this.props2 = props; } - protected bound(scope: cdk.Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { SingletonPolicy.forRole(options.role).grantExecuteChangeSet(this.props2); @@ -259,7 +263,7 @@ abstract class CloudFormationDeployAction extends CloudFormationAction { return this.getDeploymentRole('property role()'); } - protected bound(scope: cdk.Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { if (this.props2.deploymentRole) { this._deploymentRole = this.props2.deploymentRole; @@ -359,7 +363,7 @@ export class CloudFormationCreateReplaceChangeSetAction extends CloudFormationDe this.props3 = props; } - protected bound(scope: cdk.Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { // the super call order is to preserve the existing order of statements in policies const actionConfig = super.bound(scope, stage, options); @@ -428,7 +432,7 @@ export class CloudFormationCreateUpdateStackAction extends CloudFormationDeployA this.props3 = props; } - protected bound(scope: cdk.Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { // the super call order is to preserve the existing order of statements in policies const actionConfig = super.bound(scope, stage, options); @@ -467,7 +471,7 @@ export class CloudFormationDeleteStackAction extends CloudFormationDeployAction this.props3 = props; } - protected bound(scope: cdk.Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { // the super call order is to preserve the existing order of statements in policies const actionConfig = super.bound(scope, stage, options); @@ -493,7 +497,7 @@ export class CloudFormationDeleteStackAction extends CloudFormationDeployAction * Statements created outside of this class are not considered when adding new * permissions. */ -class SingletonPolicy extends cdk.Construct implements iam.IGrantable { +class SingletonPolicy extends Construct implements iam.IGrantable { /** * Obtain a SingletonPolicy for a given role. * @param role the Role this policy is bound to. diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts index aa2d3be190029..b55d9742c514b 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts @@ -5,6 +5,10 @@ import * as cdk from '@aws-cdk/core'; import { BitBucketSourceAction } from '..'; import { Action } from '../action'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * The type of the CodeBuild action that determines its CodePipeline Category - * Build, or Test. @@ -132,7 +136,7 @@ export class CodeBuildAction extends Action { return this.variableExpression(variableName); } - protected bound(scope: cdk.Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(scope: Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { // check for a cross-account action if there are any outputs if ((this.actionProperties.outputs || []).length > 0) { diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/custom-action-registration.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/custom-action-registration.ts index ae75a1adeb5c0..41e34ac8a0b5d 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/custom-action-registration.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/custom-action-registration.ts @@ -1,5 +1,8 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline'; -import * as cdk from '@aws-cdk/core'; + +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; /** * The creation attributes used for defining a configuration property @@ -109,8 +112,8 @@ export interface CustomActionRegistrationProps { * representing your custom Action, extending the Action class, * and taking the `actionProperties` as properly typed, construction properties. */ -export class CustomActionRegistration extends cdk.Construct { - constructor(parent: cdk.Construct, id: string, props: CustomActionRegistrationProps) { +export class CustomActionRegistration extends Construct { + constructor(parent: Construct, id: string, props: CustomActionRegistrationProps) { super(parent, id); new codepipeline.CfnCustomActionType(this, 'Resource', { diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-provider.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-provider.ts index a739fc2f0ec6a..923b1a1e39e7c 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-provider.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-provider.ts @@ -3,6 +3,10 @@ import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { CustomActionRegistration } from '../custom-action-registration'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * A Jenkins provider. * @@ -103,7 +107,7 @@ export interface JenkinsProviderProps { readonly forTest?: boolean; } -export abstract class BaseJenkinsProvider extends cdk.Construct implements IJenkinsProvider { +export abstract class BaseJenkinsProvider extends CoreConstruct implements IJenkinsProvider { public abstract readonly providerName: string; public abstract readonly serverUrl: string; public readonly version: string; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts index 5ddfdb974c4e9..bf91f75b7359b 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts @@ -1,9 +1,12 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as sns from '@aws-cdk/aws-sns'; import * as subs from '@aws-cdk/aws-sns-subscriptions'; -import * as cdk from '@aws-cdk/core'; import { Action } from './action'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Construction properties of the {@link ManualApprovalAction}. */ @@ -60,7 +63,7 @@ export class ManualApprovalAction extends Action { return this._notificationTopic; } - protected bound(scope: cdk.Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(scope: Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { if (this.props.notificationTopic) { this._notificationTopic = this.props.notificationTopic; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/stepfunctions/invoke-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/stepfunctions/invoke-action.ts index ae05cd093892f..bf6c34ab505a8 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/stepfunctions/invoke-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/stepfunctions/invoke-action.ts @@ -4,6 +4,10 @@ import * as stepfunction from '@aws-cdk/aws-stepfunctions'; import * as cdk from '@aws-cdk/core'; import { Action } from '../action'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Represents the input for the StateMachine. */ @@ -121,7 +125,7 @@ export class StepFunctionInvokeAction extends Action { this.props = props; } - protected bound(_scope: cdk.Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): + protected bound(_scope: Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { // allow pipeline to invoke this step function options.role.addToPolicy(new iam.PolicyStatement({ diff --git a/packages/@aws-cdk/aws-codepipeline/lib/private/cross-region-support-stack.ts b/packages/@aws-cdk/aws-codepipeline/lib/private/cross-region-support-stack.ts index 33a81467a23d9..e52e6c7f68a40 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/private/cross-region-support-stack.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/private/cross-region-support-stack.ts @@ -2,6 +2,10 @@ import * as kms from '@aws-cdk/aws-kms'; import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + const REQUIRED_ALIAS_PREFIX = 'alias/'; /** @@ -42,10 +46,10 @@ export interface CrossRegionSupportConstructProps { readonly createKmsKey?: boolean; } -export class CrossRegionSupportConstruct extends cdk.Construct { +export class CrossRegionSupportConstruct extends Construct { public readonly replicationBucket: s3.IBucket; - constructor(scope: cdk.Construct, id: string, props: CrossRegionSupportConstructProps = {}) { + constructor(scope: Construct, id: string, props: CrossRegionSupportConstructProps = {}) { super(scope, id); const createKmsKey = props.createKmsKey ?? true; @@ -114,7 +118,7 @@ export class CrossRegionSupportStack extends cdk.Stack { */ public readonly replicationBucket: s3.IBucket; - constructor(scope: cdk.Construct, id: string, props: CrossRegionSupportStackProps) { + constructor(scope: Construct, id: string, props: CrossRegionSupportStackProps) { super(scope, id, { stackName: generateStackName(props), env: { diff --git a/packages/@aws-cdk/aws-dynamodb-global/lib/aws-dynamodb-global.ts b/packages/@aws-cdk/aws-dynamodb-global/lib/aws-dynamodb-global.ts index a76e2b8940abc..caa9eedec0c4d 100644 --- a/packages/@aws-cdk/aws-dynamodb-global/lib/aws-dynamodb-global.ts +++ b/packages/@aws-cdk/aws-dynamodb-global/lib/aws-dynamodb-global.ts @@ -2,6 +2,10 @@ import * as dynamodb from '@aws-cdk/aws-dynamodb'; import * as cdk from '@aws-cdk/core'; import { GlobalTableCoordinator } from './global-table-coordinator'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for the multiple DynamoDB tables to mash together into a * global table @@ -26,7 +30,7 @@ export interface GlobalTableProps extends cdk.StackProps, dynamodb.TableOptions * * @deprecated use `@aws-cdk/aws-dynamodb.Table.replicationRegions` instead */ -export class GlobalTable extends cdk.Construct { +export class GlobalTable extends Construct { /** * Creates the cloudformation custom resource that launches a lambda to tie it all together */ @@ -37,7 +41,7 @@ export class GlobalTable extends cdk.Construct { */ private readonly _regionalTables = new Array(); - constructor(scope: cdk.Construct, id: string, props: GlobalTableProps) { + constructor(scope: Construct, id: string, props: GlobalTableProps) { super(scope, id); cdk.Annotations.of(this).addWarning('The @aws-cdk/aws-dynamodb-global module has been deprecated in favor of @aws-cdk/aws-dynamodb.Table.replicationRegions'); diff --git a/packages/@aws-cdk/aws-dynamodb-global/lib/global-table-coordinator.ts b/packages/@aws-cdk/aws-dynamodb-global/lib/global-table-coordinator.ts index 0d1f8c3b42835..0acd9b1cdc3d6 100644 --- a/packages/@aws-cdk/aws-dynamodb-global/lib/global-table-coordinator.ts +++ b/packages/@aws-cdk/aws-dynamodb-global/lib/global-table-coordinator.ts @@ -4,12 +4,16 @@ import * as lambda from '@aws-cdk/aws-lambda'; import * as cdk from '@aws-cdk/core'; import { GlobalTableProps } from './aws-dynamodb-global'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * A stack that will make a Lambda that will launch a lambda to glue * together all the DynamoDB tables into a global table */ export class GlobalTableCoordinator extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props: GlobalTableProps) { + constructor(scope: Construct, id: string, props: GlobalTableProps) { super(scope, id, props); const lambdaFunction = new lambda.SingletonFunction(this, 'SingletonLambda', { code: lambda.Code.fromAsset(path.resolve(__dirname, '../', 'lambda-packages', 'aws-global-table-coordinator', 'lib')), 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 0ea254d29afa7..e7c65834019cc 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 @@ -3,13 +3,17 @@ import * as cdk from '@aws-cdk/core'; import * as constructs from 'constructs'; import * as ec2 from '../lib'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + const app = new cdk.App(); interface ConstructThatTakesAVpcProps { vpc: ec2.IVpc; } -class ConstructThatTakesAVpc extends cdk.Construct { +class ConstructThatTakesAVpc extends Construct { constructor(scope: constructs.Construct, id: string, _props: ConstructThatTakesAVpcProps) { super(scope, id); diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts index 3bcade2f49a73..769756999ad0c 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts @@ -11,6 +11,10 @@ import { LoadBalancerTarget } from '@aws-cdk/aws-route53-targets'; import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Describes the type of DNS record the service should create */ @@ -306,7 +310,7 @@ export interface ApplicationLoadBalancedTaskImageOptions { /** * The base class for ApplicationLoadBalancedEc2Service and ApplicationLoadBalancedFargateService services. */ -export abstract class ApplicationLoadBalancedServiceBase extends cdk.Construct { +export abstract class ApplicationLoadBalancedServiceBase extends CoreConstruct { /** * The desired number of instantiations of the task definition to keep running on the service. @@ -467,7 +471,7 @@ export abstract class ApplicationLoadBalancedServiceBase extends cdk.Construct { /** * Returns the default cluster. */ - protected getDefaultCluster(scope: cdk.Construct, vpc?: IVpc): Cluster { + protected getDefaultCluster(scope: CoreConstruct, vpc?: IVpc): Cluster { // magic string to avoid collision with user-defined constructs const DEFAULT_CLUSTER_ID = `EcsDefaultClusterMnL3mNNYN${vpc ? vpc.node.id : ''}`; const stack = cdk.Stack.of(scope); diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts index 8329db85f2792..ffdcb3b75912a 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts @@ -7,6 +7,10 @@ import { LoadBalancerTarget } from '@aws-cdk/aws-route53-targets'; import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Describes the type of DNS record the service should create */ @@ -256,7 +260,7 @@ export interface NetworkLoadBalancedTaskImageOptions { /** * The base class for NetworkLoadBalancedEc2Service and NetworkLoadBalancedFargateService services. */ -export abstract class NetworkLoadBalancedServiceBase extends cdk.Construct { +export abstract class NetworkLoadBalancedServiceBase extends CoreConstruct { /** * The desired number of instantiations of the task definition to keep running on the service. */ @@ -361,7 +365,7 @@ export abstract class NetworkLoadBalancedServiceBase extends cdk.Construct { /** * Returns the default cluster. */ - protected getDefaultCluster(scope: cdk.Construct, vpc?: IVpc): Cluster { + protected getDefaultCluster(scope: CoreConstruct, vpc?: IVpc): Cluster { // magic string to avoid collision with user-defined constructs const DEFAULT_CLUSTER_ID = `EcsDefaultClusterMnL3mNNYN${vpc ? vpc.node.id : ''}`; const stack = cdk.Stack.of(scope); diff --git a/packages/@aws-cdk/aws-ecs/lib/container-definition.ts b/packages/@aws-cdk/aws-ecs/lib/container-definition.ts index 1ac4ec541df85..b4d31c56133fc 100644 --- a/packages/@aws-cdk/aws-ecs/lib/container-definition.ts +++ b/packages/@aws-cdk/aws-ecs/lib/container-definition.ts @@ -10,6 +10,10 @@ import { EnvironmentFile, EnvironmentFileConfig } from './environment-file'; import { LinuxParameters } from './linux-parameters'; import { LogDriver, LogDriverConfig } from './log-drivers/log-driver'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * A secret environment variable. */ @@ -301,7 +305,7 @@ export interface ContainerDefinitionProps extends ContainerDefinitionOptions { /** * A container definition is used in a task definition to describe the containers that are launched as part of a task. */ -export class ContainerDefinition extends cdk.Construct { +export class ContainerDefinition extends CoreConstruct { /** * The Linux-specific modifications that are applied to the container, such as Linux kernel capabilities. */ diff --git a/packages/@aws-cdk/aws-ecs/lib/drain-hook/instance-drain-hook.ts b/packages/@aws-cdk/aws-ecs/lib/drain-hook/instance-drain-hook.ts index a11b6dce3bbb8..cb0f9a57d6288 100644 --- a/packages/@aws-cdk/aws-ecs/lib/drain-hook/instance-drain-hook.ts +++ b/packages/@aws-cdk/aws-ecs/lib/drain-hook/instance-drain-hook.ts @@ -9,6 +9,10 @@ import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { ICluster } from '../cluster'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + // Reference for the source in this package: // // https://github.com/aws-samples/ecs-refarch-cloudformation/blob/master/infrastructure/lifecyclehook.yaml @@ -49,7 +53,7 @@ export interface InstanceDrainHookProps { /** * A hook to drain instances from ECS traffic before they're terminated */ -export class InstanceDrainHook extends cdk.Construct { +export class InstanceDrainHook extends CoreConstruct { /** * Constructs a new instance of the InstanceDrainHook class. diff --git a/packages/@aws-cdk/aws-ecs/lib/images/tag-parameter-container-image.ts b/packages/@aws-cdk/aws-ecs/lib/images/tag-parameter-container-image.ts index de738d3c562e3..b033e8783a514 100644 --- a/packages/@aws-cdk/aws-ecs/lib/images/tag-parameter-container-image.ts +++ b/packages/@aws-cdk/aws-ecs/lib/images/tag-parameter-container-image.ts @@ -3,6 +3,10 @@ import * as cdk from '@aws-cdk/core'; import { ContainerDefinition } from '../container-definition'; import { ContainerImage, ContainerImageConfig } from '../container-image'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * A special type of {@link ContainerImage} that uses an ECR repository for the image, * but a CloudFormation Parameter for the tag of the image in that repository. @@ -21,7 +25,7 @@ export class TagParameterContainerImage extends ContainerImage { this.repository = repository; } - public bind(scope: cdk.Construct, containerDefinition: ContainerDefinition): ContainerImageConfig { + public bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig { this.repository.grantPull(containerDefinition.taskDefinition.obtainExecutionRole()); const imageTagParameter = new cdk.CfnParameter(scope, 'ImageTagParam'); this.imageTagParameter = imageTagParameter; diff --git a/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts b/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts index 45e792126fd20..b83b208552b95 100644 --- a/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts +++ b/packages/@aws-cdk/aws-ecs/lib/linux-parameters.ts @@ -2,6 +2,10 @@ import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { CfnTaskDefinition } from './ecs.generated'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * The properties for defining Linux-specific options that are applied to the container. */ @@ -24,7 +28,7 @@ export interface LinuxParametersProps { /** * Linux-specific options that are applied to the container. */ -export class LinuxParameters extends cdk.Construct { +export class LinuxParameters extends CoreConstruct { /** * Whether the init process is enabled */ diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts index 4dab6b23ba2b0..2ff867a4721a2 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-certificate.ts @@ -1,9 +1,12 @@ -import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { CfnListenerCertificate } from '../elasticloadbalancingv2.generated'; import { IListenerCertificate } from '../shared/listener-certificate'; import { IApplicationListener } from './application-listener'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Properties for adding a set of certificates to a listener */ @@ -36,7 +39,7 @@ export interface ApplicationListenerCertificateProps { /** * Add certificates to a listener */ -export class ApplicationListenerCertificate extends cdk.Construct { +export class ApplicationListenerCertificate extends CoreConstruct { constructor(scope: Construct, id: string, props: ApplicationListenerCertificateProps) { super(scope, id); diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts index edc0e04551f46..e109bc7624f9c 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener-rule.ts @@ -7,6 +7,10 @@ import { ListenerAction } from './application-listener-action'; import { IApplicationTargetGroup } from './application-target-group'; import { ListenerCondition } from './conditions'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Basic properties for defining a rule on a listener */ @@ -194,7 +198,7 @@ export interface RedirectResponse { /** * Define a new listener rule */ -export class ApplicationListenerRule extends cdk.Construct { +export class ApplicationListenerRule extends CoreConstruct { /** * The ARN of this rule */ diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts index f9155bb1430eb..0ff63805aab90 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts @@ -5,6 +5,10 @@ import { CfnTargetGroup } from '../elasticloadbalancingv2.generated'; import { Protocol, TargetType } from './enums'; import { Attributes, renderAttributes } from './util'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Basic properties of both Application and Network Target Groups */ @@ -145,7 +149,7 @@ export interface HealthCheck { /** * Define the target of a load balancer */ -export abstract class TargetGroupBase extends cdk.Construct implements ITargetGroup { +export abstract class TargetGroupBase extends CoreConstruct implements ITargetGroup { /** * The ARN of the target group */ diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/imported.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/imported.ts index 52643b49a97cd..59594c636d118 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/imported.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/imported.ts @@ -2,10 +2,14 @@ import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { ITargetGroup, TargetGroupImportProps } from './base-target-group'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Base internal class for existing target groups */ -export abstract class ImportedTargetGroupBase extends cdk.Construct implements ITargetGroup { +export abstract class ImportedTargetGroupBase extends CoreConstruct implements ITargetGroup { /** * ARN of the target group */ diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts index 8fa9d3361db33..6378f8ac0c8ed 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/helpers.ts @@ -1,9 +1,12 @@ 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, +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + +export class FakeSelfRegisteringTarget extends Construct implements elbv2.IApplicationLoadBalancerTarget, elbv2.INetworkLoadBalancerTarget, ec2.IConnectable { public readonly securityGroup: ec2.SecurityGroup; public readonly connections: ec2.Connections; diff --git a/packages/@aws-cdk/aws-elasticsearch/lib/elasticsearch-access-policy.ts b/packages/@aws-cdk/aws-elasticsearch/lib/elasticsearch-access-policy.ts index 78e0e4e8c5003..bb5a530211719 100644 --- a/packages/@aws-cdk/aws-elasticsearch/lib/elasticsearch-access-policy.ts +++ b/packages/@aws-cdk/aws-elasticsearch/lib/elasticsearch-access-policy.ts @@ -1,7 +1,10 @@ import * as iam from '@aws-cdk/aws-iam'; -import * as cdk from '@aws-cdk/core'; import * as cr from '@aws-cdk/custom-resources'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Construction properties for ElasticsearchAccessPolicy */ @@ -26,7 +29,7 @@ export interface ElasticsearchAccessPolicyProps { * Creates LogGroup resource policies. */ export class ElasticsearchAccessPolicy extends cr.AwsCustomResource { - constructor(scope: cdk.Construct, id: string, props: ElasticsearchAccessPolicyProps) { + constructor(scope: Construct, id: string, props: ElasticsearchAccessPolicyProps) { const policyDocument = new iam.PolicyDocument({ statements: props.accessPolicies, }); diff --git a/packages/@aws-cdk/aws-elasticsearch/lib/log-group-resource-policy.ts b/packages/@aws-cdk/aws-elasticsearch/lib/log-group-resource-policy.ts index 949f03aa61baa..e53eb9a913540 100644 --- a/packages/@aws-cdk/aws-elasticsearch/lib/log-group-resource-policy.ts +++ b/packages/@aws-cdk/aws-elasticsearch/lib/log-group-resource-policy.ts @@ -1,7 +1,10 @@ import * as iam from '@aws-cdk/aws-iam'; -import * as cdk from '@aws-cdk/core'; import * as cr from '@aws-cdk/custom-resources'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Construction properties for LogGroupResourcePolicy */ @@ -20,7 +23,7 @@ export interface LogGroupResourcePolicyProps { * Creates LogGroup resource policies. */ export class LogGroupResourcePolicy extends cr.AwsCustomResource { - constructor(scope: cdk.Construct, id: string, props: LogGroupResourcePolicyProps) { + constructor(scope: Construct, id: string, props: LogGroupResourcePolicyProps) { const policyDocument = new iam.PolicyDocument({ statements: props.policyStatements, }); diff --git a/packages/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts b/packages/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts index d0bbaca87f689..a4fdccd042e8f 100644 --- a/packages/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts +++ b/packages/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts @@ -2,6 +2,10 @@ import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; import * as cr from '@aws-cdk/custom-resources'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties to configure a log group resource policy */ @@ -20,7 +24,7 @@ export interface LogGroupResourcePolicyProps { * Creates LogGroup resource policies. */ export class LogGroupResourcePolicy extends cr.AwsCustomResource { - constructor(scope: cdk.Construct, id: string, props: LogGroupResourcePolicyProps) { + constructor(scope: Construct, id: string, props: LogGroupResourcePolicyProps) { const policyDocument = new iam.PolicyDocument({ statements: props.policyStatements, }); diff --git a/packages/@aws-cdk/aws-globalaccelerator/lib/endpoint-group.ts b/packages/@aws-cdk/aws-globalaccelerator/lib/endpoint-group.ts index a2532aecdffa0..b5c96bcd547ba 100644 --- a/packages/@aws-cdk/aws-globalaccelerator/lib/endpoint-group.ts +++ b/packages/@aws-cdk/aws-globalaccelerator/lib/endpoint-group.ts @@ -3,6 +3,10 @@ import { Construct } from 'constructs'; import * as ga from './globalaccelerator.generated'; import { IListener } from './listener'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * The interface of the EndpointGroup */ @@ -113,7 +117,7 @@ export interface EndpointGroupProps { /** * The class for endpoint configuration */ -export class EndpointConfiguration extends cdk.Construct { +export class EndpointConfiguration extends CoreConstruct { /** * The property containing all the configuration to be rendered */ 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 5b04bac60cd3f..f85f7514c91b6 100644 --- a/packages/@aws-cdk/aws-iam/test/example.attaching.lit.ts +++ b/packages/@aws-cdk/aws-iam/test/example.attaching.lit.ts @@ -2,7 +2,11 @@ import * as cdk from '@aws-cdk/core'; import * as constructs from 'constructs'; import { Group, Policy, User } from '../lib'; -export class ExampleConstruct extends cdk.Construct { +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + +export class ExampleConstruct extends Construct { constructor(scope: constructs.Construct, id: string) { super(scope, id); 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 ddbcb4cd5ea07..f13fae1c0837b 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,11 @@ -import * as cdk from '@aws-cdk/core'; import * as constructs from 'constructs'; import * as iam from '../lib'; -export class ExampleConstruct extends cdk.Construct { +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + +export class ExampleConstruct extends Construct { constructor(scope: constructs.Construct, id: string) { super(scope, id); 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 8eb514aae90da..6e2859ad24a60 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,11 @@ -import * as cdk from '@aws-cdk/core'; import * as constructs from 'constructs'; import { Group, ManagedPolicy } from '../lib'; -export class ExampleConstruct extends cdk.Construct { +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + +export class ExampleConstruct extends Construct { constructor(scope: constructs.Construct, id: string) { super(scope, id); 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 92ff9d2a96127..0a2c6eb9ecb48 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,11 @@ -import * as cdk from '@aws-cdk/core'; import * as constructs from 'constructs'; import { PolicyStatement, Role, ServicePrincipal } from '../lib'; -export class ExampleConstruct extends cdk.Construct { +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + +export class ExampleConstruct extends Construct { constructor(scope: constructs.Construct, id: string) { super(scope, id); diff --git a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts index 5e4e160eaa717..680a6f7330356 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts @@ -1,11 +1,14 @@ import * as fs from 'fs'; import * as path from 'path'; import * as lambda from '@aws-cdk/aws-lambda'; -import * as cdk from '@aws-cdk/core'; import { Bundling } from './bundling'; import { BundlingOptions } from './types'; import { callsites, findUp, LockFile, nodeMajorVersion } from './util'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for a NodejsFunction */ @@ -76,7 +79,7 @@ export interface NodejsFunctionProps extends lambda.FunctionOptions { * A Node.js Lambda function bundled using esbuild */ export class NodejsFunction extends lambda.Function { - constructor(scope: cdk.Construct, id: string, props: NodejsFunctionProps = {}) { + constructor(scope: Construct, id: string, props: NodejsFunctionProps = {}) { if (props.runtime && props.runtime.family !== lambda.RuntimeFamily.NODEJS) { throw new Error('Only `NODEJS` runtimes are supported.'); } diff --git a/packages/@aws-cdk/aws-lambda-python/lib/function.ts b/packages/@aws-cdk/aws-lambda-python/lib/function.ts index 77f794704e967..267245738cbe6 100644 --- a/packages/@aws-cdk/aws-lambda-python/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda-python/lib/function.ts @@ -1,9 +1,12 @@ import * as fs from 'fs'; import * as path from 'path'; import * as lambda from '@aws-cdk/aws-lambda'; -import * as cdk from '@aws-cdk/core'; import { bundle } from './bundling'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for a PythonFunction */ @@ -40,7 +43,7 @@ export interface PythonFunctionProps extends lambda.FunctionOptions { * A Python Lambda function */ export class PythonFunction extends lambda.Function { - constructor(scope: cdk.Construct, id: string, props: PythonFunctionProps) { + constructor(scope: Construct, id: string, props: PythonFunctionProps) { if (props.runtime && props.runtime.family !== lambda.RuntimeFamily.PYTHON) { throw new Error('Only `PYTHON` runtimes are supported.'); } diff --git a/packages/@aws-cdk/aws-lambda-python/lib/layer.ts b/packages/@aws-cdk/aws-lambda-python/lib/layer.ts index 8b090eed6a989..3299781bb413c 100644 --- a/packages/@aws-cdk/aws-lambda-python/lib/layer.ts +++ b/packages/@aws-cdk/aws-lambda-python/lib/layer.ts @@ -1,8 +1,11 @@ import * as path from 'path'; import * as lambda from '@aws-cdk/aws-lambda'; -import * as cdk from '@aws-cdk/core'; import { bundle } from './bundling'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Properties for PythonLayerVersion */ @@ -26,7 +29,7 @@ export interface PythonLayerVersionProps extends lambda.LayerVersionOptions { * @experimental */ export class PythonLayerVersion extends lambda.LayerVersion { - constructor(scope: cdk.Construct, id: string, props: PythonLayerVersionProps) { + constructor(scope: Construct, id: string, props: PythonLayerVersionProps) { const compatibleRuntimes = props.compatibleRuntimes ?? [lambda.Runtime.PYTHON_3_7]; // Ensure that all compatible runtimes are python diff --git a/packages/@aws-cdk/aws-lambda/lib/code.ts b/packages/@aws-cdk/aws-lambda/lib/code.ts index b2323008bb5fd..29cd3d02ae4de 100644 --- a/packages/@aws-cdk/aws-lambda/lib/code.ts +++ b/packages/@aws-cdk/aws-lambda/lib/code.ts @@ -5,6 +5,10 @@ import * as s3 from '@aws-cdk/aws-s3'; import * as s3_assets from '@aws-cdk/aws-s3-assets'; import * as cdk from '@aws-cdk/core'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Represents the Lambda Handler Code. */ @@ -112,7 +116,7 @@ export abstract class Code { * @param scope The binding scope. Don't be smart about trying to down-cast or * assume it's initialized. You may just use it as a construct scope. */ - public abstract bind(scope: cdk.Construct): CodeConfig; + public abstract bind(scope: Construct): CodeConfig; /** * Called after the CFN function resource has been created to allow the code @@ -191,7 +195,7 @@ export class S3Code extends Code { this.bucketName = bucket.bucketName; } - public bind(_scope: cdk.Construct): CodeConfig { + public bind(_scope: Construct): CodeConfig { return { s3Location: { bucketName: this.bucketName, @@ -220,7 +224,7 @@ export class InlineCode extends Code { } } - public bind(_scope: cdk.Construct): CodeConfig { + public bind(_scope: Construct): CodeConfig { return { inlineCode: this.code, }; @@ -241,7 +245,7 @@ export class AssetCode extends Code { super(); } - public bind(scope: cdk.Construct): CodeConfig { + public bind(scope: Construct): CodeConfig { // If the same AssetCode is used multiple times, retain only the first instantiation. if (!this.asset) { this.asset = new s3_assets.Asset(scope, 'Code', { @@ -327,7 +331,7 @@ export class CfnParametersCode extends Code { this._objectKeyParam = props.objectKeyParam; } - public bind(scope: cdk.Construct): CodeConfig { + public bind(scope: Construct): CodeConfig { if (!this._bucketNameParam) { this._bucketNameParam = new cdk.CfnParameter(scope, 'LambdaSourceBucketNameParameter', { type: 'String', @@ -422,7 +426,7 @@ export class EcrImageCode extends Code { super(); } - public bind(_: cdk.Construct): CodeConfig { + public bind(_: Construct): CodeConfig { this.repository.grantPull(new iam.ServicePrincipal('lambda.amazonaws.com')); return { @@ -467,7 +471,7 @@ export class AssetImageCode extends Code { super(); } - public bind(scope: cdk.Construct): CodeConfig { + public bind(scope: Construct): CodeConfig { const asset = new ecr_assets.DockerImageAsset(scope, 'AssetImage', { directory: this.directory, ...this.props, diff --git a/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts b/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts index f9dfefdfed9f6..2d024ad8e88e1 100644 --- a/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts +++ b/packages/@aws-cdk/aws-logs/lib/cross-account-destination.ts @@ -5,6 +5,10 @@ import { ILogGroup } from './log-group'; import { CfnDestination } from './logs.generated'; import { ILogSubscriptionDestination, LogSubscriptionDestinationConfig } from './subscription-filter'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Properties for a CrossAccountDestination */ @@ -93,7 +97,7 @@ export class CrossAccountDestination extends cdk.Resource implements ILogSubscri this.policyDocument.addStatements(statement); } - public bind(_scope: cdk.Construct, _sourceLogGroup: ILogGroup): LogSubscriptionDestinationConfig { + public bind(_scope: CoreConstruct, _sourceLogGroup: ILogGroup): LogSubscriptionDestinationConfig { return { arn: this.destinationArn }; } diff --git a/packages/@aws-cdk/aws-logs/lib/log-retention.ts b/packages/@aws-cdk/aws-logs/lib/log-retention.ts index 44f36e5891cbe..4056c0a0f09c9 100644 --- a/packages/@aws-cdk/aws-logs/lib/log-retention.ts +++ b/packages/@aws-cdk/aws-logs/lib/log-retention.ts @@ -5,6 +5,10 @@ import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { RetentionDays } from './log-group'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Construction properties for a LogRetention. */ @@ -65,7 +69,7 @@ export interface LogRetentionRetryOptions { * Log group can be created in the region that is different from stack region by * specifying `logGroupRegion` */ -export class LogRetention extends cdk.Construct { +export class LogRetention extends CoreConstruct { /** * The ARN of the LogGroup. @@ -124,7 +128,7 @@ export class LogRetention extends cdk.Construct { /** * Private provider Lambda function to support the log retention custom resource. */ -class LogRetentionFunction extends cdk.Construct { +class LogRetentionFunction extends CoreConstruct { public readonly functionArn: cdk.Reference; constructor(scope: Construct, id: string, props: LogRetentionProps) { diff --git a/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts b/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts index 9905362f4669a..9c2645f64ab43 100644 --- a/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts +++ b/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts @@ -1,10 +1,13 @@ import * as iam from '@aws-cdk/aws-iam'; import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; -import * as core from '@aws-cdk/core'; import { IEngine } from './engine'; import { EngineVersion } from './engine-version'; import { IParameterGroup, ParameterGroup } from './parameter-group'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * The extra options passed to the {@link IClusterEngine.bindToCluster} method. */ @@ -97,7 +100,7 @@ export interface IClusterEngine extends IEngine { /** * Method called when the engine is used to create a new cluster. */ - bindToCluster(scope: core.Construct, options: ClusterEngineBindOptions): ClusterEngineConfig; + bindToCluster(scope: Construct, options: ClusterEngineBindOptions): ClusterEngineConfig; } interface ClusterEngineBaseProps { @@ -130,7 +133,7 @@ abstract class ClusterEngineBase implements IClusterEngine { this.parameterGroupFamily = this.engineVersion ? `${this.engineType}${this.engineVersion.majorVersion}` : undefined; } - public bindToCluster(scope: core.Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { + public bindToCluster(scope: Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { const parameterGroup = options.parameterGroup ?? this.defaultParameterGroup(scope); return { parameterGroup, @@ -144,7 +147,7 @@ abstract class ClusterEngineBase implements IClusterEngine { * possibly an imported one, * if one wasn't provided by the customer explicitly. */ - protected abstract defaultParameterGroup(scope: core.Construct): IParameterGroup | undefined; + protected abstract defaultParameterGroup(scope: Construct): IParameterGroup | undefined; } interface MysqlClusterEngineBaseProps { @@ -166,7 +169,7 @@ abstract class MySqlClusterEngineBase extends ClusterEngineBase { }); } - public bindToCluster(scope: core.Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { + public bindToCluster(scope: Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { const config = super.bindToCluster(scope, options); const parameterGroup = options.parameterGroup ?? (options.s3ImportRole || options.s3ExportRole ? new ParameterGroup(scope, 'ClusterParameterGroup', { @@ -271,7 +274,7 @@ class AuroraClusterEngine extends MySqlClusterEngineBase { }); } - protected defaultParameterGroup(_scope: core.Construct): IParameterGroup | undefined { + protected defaultParameterGroup(_scope: Construct): IParameterGroup | undefined { // the default.aurora5.6 ParameterGroup is actually the default, // so just return undefined in this case return undefined; @@ -380,7 +383,7 @@ class AuroraMysqlClusterEngine extends MySqlClusterEngineBase { }); } - protected defaultParameterGroup(scope: core.Construct): IParameterGroup | undefined { + protected defaultParameterGroup(scope: Construct): IParameterGroup | undefined { return ParameterGroup.fromParameterGroupName(scope, 'AuroraMySqlDatabaseClusterEngineDefaultParameterGroup', `default.${this.parameterGroupFamily}`); } @@ -536,7 +539,7 @@ class AuroraPostgresClusterEngine extends ClusterEngineBase { }); } - public bindToCluster(scope: core.Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { + public bindToCluster(scope: Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { const config = super.bindToCluster(scope, options); // skip validation for unversioned as it might be supported/unsupported. we cannot reliably tell at compile-time if (this.engineVersion?.fullVersion) { @@ -550,7 +553,7 @@ class AuroraPostgresClusterEngine extends ClusterEngineBase { return config; } - protected defaultParameterGroup(scope: core.Construct): IParameterGroup | undefined { + protected defaultParameterGroup(scope: Construct): IParameterGroup | undefined { if (!this.parameterGroupFamily) { throw new Error('Could not create a new ParameterGroup for an unversioned aurora-postgresql cluster engine. ' + 'Please either use a versioned engine, or pass an explicit ParameterGroup when creating the cluster'); diff --git a/packages/@aws-cdk/aws-rds/lib/instance-engine.ts b/packages/@aws-cdk/aws-rds/lib/instance-engine.ts index f3f41a00df8b7..e2e425eb71736 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance-engine.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance-engine.ts @@ -1,10 +1,13 @@ import * as iam from '@aws-cdk/aws-iam'; import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; -import * as core from '@aws-cdk/core'; import { IEngine } from './engine'; import { EngineVersion } from './engine-version'; import { IOptionGroup, OptionGroup } from './option-group'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * The options passed to {@link IInstanceEngine.bind}. */ @@ -100,7 +103,7 @@ export interface IInstanceEngine extends IEngine { /** * Method called when the engine is used to create a new instance. */ - bindToInstance(scope: core.Construct, options: InstanceEngineBindOptions): InstanceEngineConfig; + bindToInstance(scope: Construct, options: InstanceEngineBindOptions): InstanceEngineConfig; } interface InstanceEngineBaseProps { @@ -134,7 +137,7 @@ abstract class InstanceEngineBase implements IInstanceEngine { this.engineFamily = props.engineFamily; } - public bindToInstance(_scope: core.Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { + public bindToInstance(_scope: Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { if (options.timezone && !this.supportsTimezone) { throw new Error(`timezone property can not be configured for ${this.engineType}`); } @@ -261,7 +264,7 @@ class MariaDbInstanceEngine extends InstanceEngineBase { }); } - public bindToInstance(scope: core.Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { + public bindToInstance(scope: Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { if (options.domain) { throw new Error(`domain property cannot be configured for ${this.engineType}`); } @@ -828,7 +831,7 @@ abstract class OracleInstanceEngineBase extends InstanceEngineBase { }); } - public bindToInstance(scope: core.Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { + public bindToInstance(scope: Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { const config = super.bindToInstance(scope, options); let optionGroup = options.optionGroup; @@ -1097,7 +1100,7 @@ abstract class SqlServerInstanceEngineBase extends InstanceEngineBase { }); } - public bindToInstance(scope: core.Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { + public bindToInstance(scope: Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { const config = super.bindToInstance(scope, options); let optionGroup = options.optionGroup; diff --git a/packages/@aws-cdk/aws-s3-assets/lib/asset.ts b/packages/@aws-cdk/aws-s3-assets/lib/asset.ts index cc730b82170de..938778d1381f4 100644 --- a/packages/@aws-cdk/aws-s3-assets/lib/asset.ts +++ b/packages/@aws-cdk/aws-s3-assets/lib/asset.ts @@ -9,6 +9,10 @@ import * as cxapi from '@aws-cdk/cx-api'; import { Construct } from 'constructs'; import { toSymlinkFollow } from './compat'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + const ARCHIVE_EXTENSIONS = ['.zip', '.jar']; export interface AssetOptions extends assets.CopyOptions, cdk.AssetOptions { @@ -54,7 +58,7 @@ export interface AssetProps extends AssetOptions { * An asset represents a local file or directory, which is automatically uploaded to S3 * and then can be referenced within a CDK application. */ -export class Asset extends cdk.Construct implements cdk.IAsset { +export class Asset extends CoreConstruct implements cdk.IAsset { /** * Attribute that represents the name of the bucket this asset exists in. */ diff --git a/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts b/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts index 352f350b91600..9e1c20ae02ef7 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts +++ b/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts @@ -9,6 +9,10 @@ import { AwsCliLayer } from '@aws-cdk/lambda-layer-awscli'; import { Construct } from 'constructs'; import { ISource, SourceConfig } from './source'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + export interface BucketDeploymentProps { /** * The sources from which to deploy the contents of this bucket. @@ -175,7 +179,7 @@ export interface BucketDeploymentProps { readonly vpcSubnets?: ec2.SubnetSelection; } -export class BucketDeployment extends cdk.Construct { +export class BucketDeployment extends CoreConstruct { constructor(scope: Construct, id: string, props: BucketDeploymentProps) { super(scope, id); diff --git a/packages/@aws-cdk/aws-s3-deployment/lib/source.ts b/packages/@aws-cdk/aws-s3-deployment/lib/source.ts index 6f0f877662891..558c32556c25c 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lib/source.ts +++ b/packages/@aws-cdk/aws-s3-deployment/lib/source.ts @@ -1,7 +1,10 @@ import * as iam from '@aws-cdk/aws-iam'; import * as s3 from '@aws-cdk/aws-s3'; import * as s3_assets from '@aws-cdk/aws-s3-assets'; -import * as cdk from '@aws-cdk/core'; + +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; export interface SourceConfig { /** @@ -33,7 +36,7 @@ export interface ISource { * Binds the source to a bucket deployment. * @param scope The construct tree context. */ - bind(scope: cdk.Construct, context?: DeploymentSourceContext): SourceConfig; + bind(scope: Construct, context?: DeploymentSourceContext): SourceConfig; } /** @@ -54,7 +57,7 @@ export class Source { */ public static bucket(bucket: s3.IBucket, zipObjectKey: string): ISource { return { - bind: (_: cdk.Construct, context?: DeploymentSourceContext) => { + bind: (_: Construct, context?: DeploymentSourceContext) => { if (!context) { throw new Error('To use a Source.bucket(), context must be provided'); } @@ -71,7 +74,7 @@ export class Source { */ public static asset(path: string, options?: s3_assets.AssetOptions): ISource { return { - bind(scope: cdk.Construct, context?: DeploymentSourceContext): SourceConfig { + bind(scope: Construct, context?: DeploymentSourceContext): SourceConfig { if (!context) { throw new Error('To use a Source.asset(), context must be provided'); } diff --git a/packages/@aws-cdk/aws-s3/lib/destination.ts b/packages/@aws-cdk/aws-s3/lib/destination.ts index 31a7ac94ef9ac..021aa80a803c4 100644 --- a/packages/@aws-cdk/aws-s3/lib/destination.ts +++ b/packages/@aws-cdk/aws-s3/lib/destination.ts @@ -1,6 +1,10 @@ import * as cdk from '@aws-cdk/core'; import { IBucket } from './bucket'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Implemented by constructs that can be used as bucket notification destinations. */ @@ -12,7 +16,7 @@ export interface IBucketNotificationDestination { * idempotency in each destination. * @param bucket The bucket object to bind to */ - bind(scope: cdk.Construct, bucket: IBucket): BucketNotificationDestinationConfig; + bind(scope: Construct, bucket: IBucket): BucketNotificationDestinationConfig; } /** diff --git a/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts b/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts index 4ceced2e93e2d..cd7427a5cbc6f 100644 --- a/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts +++ b/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts @@ -1,6 +1,10 @@ import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * A Lambda-based custom resource handler that provisions S3 bucket * notifications for a bucket. @@ -18,14 +22,14 @@ import * as cdk from '@aws-cdk/core'; * Sadly, we can't use @aws-cdk/aws-lambda as it will introduce a dependency * cycle, so this uses raw `cdk.Resource`s. */ -export class NotificationsResourceHandler extends cdk.Construct { +export class NotificationsResourceHandler extends Construct { /** * Defines a stack-singleton lambda function with the logic for a CloudFormation custom * resource that provisions bucket notification configuration for a bucket. * * @returns The ARN of the custom resource lambda function. */ - public static singleton(context: cdk.Construct) { + public static singleton(context: Construct) { const root = cdk.Stack.of(context); // well-known logical id to ensure stack singletonity @@ -44,7 +48,7 @@ export class NotificationsResourceHandler extends cdk.Construct { */ public readonly functionArn: string; - constructor(scope: cdk.Construct, id: string) { + constructor(scope: Construct, id: string) { super(scope, id); const role = new iam.Role(this, 'Role', { diff --git a/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts b/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts index 91bb688b28857..3c2194ddf7eb9 100644 --- a/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts +++ b/packages/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts @@ -3,6 +3,10 @@ import { Bucket, EventType, NotificationKeyFilter } from '../bucket'; import { BucketNotificationDestinationType, IBucketNotificationDestination } from '../destination'; import { NotificationsResourceHandler } from './notifications-resource-handler'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + interface NotificationsProps { /** * The bucket to manage notifications for. @@ -28,14 +32,14 @@ interface NotificationsProps { * @see * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig.html */ -export class BucketNotifications extends cdk.Construct { +export class BucketNotifications extends Construct { private readonly lambdaNotifications = new Array(); private readonly queueNotifications = new Array(); private readonly topicNotifications = new Array(); private resource?: cdk.CfnResource; private readonly bucket: Bucket; - constructor(scope: cdk.Construct, id: string, props: NotificationsProps) { + constructor(scope: Construct, id: string, props: NotificationsProps) { super(scope, id); this.bucket = props.bucket; } diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/state-machine-fragment.ts b/packages/@aws-cdk/aws-stepfunctions/lib/state-machine-fragment.ts index 929aed5b22219..0103ceb735499 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/state-machine-fragment.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/state-machine-fragment.ts @@ -1,13 +1,16 @@ -import * as cdk from '@aws-cdk/core'; import { Chain } from './chain'; import { Parallel, ParallelProps } from './states/parallel'; import { State } from './states/state'; import { IChainable, INextable } from './types'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct } from '@aws-cdk/core'; + /** * Base class for reusable state machine fragments */ -export abstract class StateMachineFragment extends cdk.Construct implements IChainable { +export abstract class StateMachineFragment extends Construct implements IChainable { /** * The start state of this state machine fragment */ diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts b/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts index c43a7bec159a8..02cceb6e64ed2 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts @@ -1,10 +1,13 @@ -import * as cdk from '@aws-cdk/core'; import { IConstruct, Construct, Node } from 'constructs'; import { Condition } from '../condition'; import { JsonPath } from '../fields'; import { StateGraph } from '../state-graph'; import { CatchProps, Errors, IChainable, INextable, RetryProps } from '../types'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Properties shared by all states */ @@ -60,7 +63,7 @@ export interface StateProps { /** * Base class for all other state classes */ -export abstract class State extends cdk.Construct implements IChainable { +export abstract class State extends CoreConstruct implements IChainable { /** * Add a prefix to the stateId of all States found in a construct tree */ diff --git a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts index 7a6e48a583d69..3a92062b779cb 100644 --- a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts +++ b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts @@ -7,6 +7,10 @@ import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; import { PHYSICAL_RESOURCE_ID_REFERENCE, flatten } from './runtime'; +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + /** * Reference to the physical resource id that can be passed to the AWS operation as a parameter. */ @@ -274,7 +278,7 @@ export interface AwsCustomResourceProps { * You can specify exactly which calls are invoked for the 'CREATE', 'UPDATE' and 'DELETE' life cycle events. * */ -export class AwsCustomResource extends cdk.Construct implements iam.IGrantable { +export class AwsCustomResource extends CoreConstruct implements iam.IGrantable { private static breakIgnoreErrorsCircuit(sdkCalls: Array, caller: string) { diff --git a/packages/monocdk/package.json b/packages/monocdk/package.json index 9b5c9e5580d99..8fe9748d9a862 100644 --- a/packages/monocdk/package.json +++ b/packages/monocdk/package.json @@ -277,8 +277,6 @@ "@aws-cdk/pipelines": "0.0.0", "@aws-cdk/region-info": "0.0.0", "@aws-cdk/yaml-cfn": "0.0.0", - "@aws-cdk/lambda-layer-awscli": "0.0.0", - "@aws-cdk/lambda-layer-kubectl": "0.0.0", "@types/fs-extra": "^8.1.1", "@types/node": "^10.17.48", "cdk-build-tools": "0.0.0", diff --git a/tools/cdk-build-tools/bin/cdk-build.ts b/tools/cdk-build-tools/bin/cdk-build.ts index d745de50aa2be..b4a5b38542292 100644 --- a/tools/cdk-build-tools/bin/cdk-build.ts +++ b/tools/cdk-build-tools/bin/cdk-build.ts @@ -26,9 +26,14 @@ async function main() { }) .option('gen', { type: 'boolean', - desc: 'execute gen script', + desc: 'Execute gen script', default: true, }) + .option('fix', { + type: 'boolean', + desc: 'Fix linter errors', + default: false, + }) .argv; const options = cdkBuildOptions(); @@ -46,7 +51,7 @@ async function main() { const overrides: CompilerOverrides = { eslint: args.eslint, jsii: args.jsii, tsc: args.tsc }; await compileCurrentPackage(options, timers, overrides); - await lintCurrentPackage(options, overrides); + await lintCurrentPackage(options, { ...overrides, fix: args.fix }); if (options.post) { await shell(options.post, { timers, env }); diff --git a/tools/cdk-build-tools/config/eslintrc.js b/tools/cdk-build-tools/config/eslintrc.js index 63608e69161a3..446af2c2e2ff4 100644 --- a/tools/cdk-build-tools/config/eslintrc.js +++ b/tools/cdk-build-tools/config/eslintrc.js @@ -42,6 +42,7 @@ module.exports = { ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'], rules: { 'cdk/no-core-construct': [ 'error' ], + 'cdk/no-qualified-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/eslint-plugin-cdk/lib/index.ts b/tools/eslint-plugin-cdk/lib/index.ts index aae510df35d54..94eef4dd8f57f 100644 --- a/tools/eslint-plugin-cdk/lib/index.ts +++ b/tools/eslint-plugin-cdk/lib/index.ts @@ -1,3 +1,4 @@ export const rules = { 'no-core-construct': require('./rules/no-core-construct'), + 'no-qualified-construct': require('./rules/no-qualified-construct'), }; diff --git a/tools/eslint-plugin-cdk/lib/private/import-cache.ts b/tools/eslint-plugin-cdk/lib/private/import-cache.ts index 7d78b2a421e93..04325645fdb5d 100644 --- a/tools/eslint-plugin-cdk/lib/private/import-cache.ts +++ b/tools/eslint-plugin-cdk/lib/private/import-cache.ts @@ -29,6 +29,10 @@ export class ImportCache { public find(key: ImportCacheKey): ImportCacheRecord | undefined { return this.records[hashed(key)]; } + + public get imports(): ImportCacheRecord[] { + return Object.values(this.records); + } } function hashed(key: {}): string { diff --git a/tools/eslint-plugin-cdk/lib/rules/no-qualified-construct.ts b/tools/eslint-plugin-cdk/lib/rules/no-qualified-construct.ts new file mode 100644 index 0000000000000..eb8a418cab58e --- /dev/null +++ b/tools/eslint-plugin-cdk/lib/rules/no-qualified-construct.ts @@ -0,0 +1,134 @@ +// +// This rule ensures that the `@aws-cdk/core.Construct` class is always +// referenced without a namespace qualifier (`Construct` instead of +// `xxx.Construct`). The fixer will automatically add an `import` statement +// separated from the main import group to reduce the chance for merge conflicts +// with v2-main. +// +// If there is already an import of `constructs.Construct` under the name +// `Construct`, we will import `core.Construct` as the alias `CoreConstruct` +// instead. +// + +import { AST, Rule } from 'eslint'; +import { ImportCache } from '../private/import-cache'; + +const importCache = new ImportCache(); + +export function create(context: Rule.RuleContext): Rule.NodeListener { + // skip core + if (context.getFilename().includes('@aws-cdk/core')) { + return {}; + } + + return { + // collect all "import" statements. we will later use them to determine + // exactly how to import `core.Construct`. + ImportDeclaration: node => { + for (const s of node.specifiers) { + const typeName = () => { + switch (s.type) { + case 'ImportSpecifier': return s.imported.name; + case 'ImportDefaultSpecifier': return s.local.name; + case 'ImportNamespaceSpecifier': return s.local.name; + } + }; + + importCache.record({ + fileName: context.getFilename(), + typeName: typeName(), + importNode: node, + localName: `${node.source.value}.${s.local.name}` + }); + } + }, + + // this captures `class X extends xxx.Construct` + ClassDeclaration: node => { + if (node.superClass?.type === 'MemberExpression') { + const sc = node.superClass; + // const qualifier = sc.object.type === 'Identifier' ? sc.object.name : undefined; + const baseClass = sc.property.type === 'Identifier' ? sc.property.name : undefined; + if (baseClass === 'Construct' && sc.range) { + report(context, node, sc.range); + } + } + }, + + // this captures using `xxx.Construct` as an identifier + Identifier: node => { + const typeAnnotation = (node as any).typeAnnotation?.typeAnnotation; + const type = typeAnnotation?.typeName; + if (type?.type === 'TSQualifiedName' && type?.right.name === 'Construct' && type?.left.name !== 'constructs') { + report(context, node, typeAnnotation.range); + } + }, + } +} + +/** + * Reports an error indicating that we found `xxx.Construct` usage, and apply + * the appropriate fix. + * @param context Rule context + * @param node Rule node (for the report) + * @param replaceRange Text range to replace + */ +function report(context: Rule.RuleContext, node: Rule.Node, replaceRange: AST.Range) { + context.report({ + message: 'To avoid merge conflicts with the v2-main branch, the "Construct" type must be referenced without a qualifier (e.g. "Construct" instead of "CoreConstruct")', + node, + fix: fixer => { + const imports = importCache.imports.filter(x => x.fileName === context.getFilename()); + const findImport = (x: string) => imports.find(i => i.localName === x); + + const coreConstruct = findImport('@aws-cdk/core.Construct') + const coreCoreConstruct = findImport('@aws-cdk/core.CoreConstruct'); + const constructsConstruct = findImport('constructs.Construct'); + + // determines whether we will replace with `Construct` or `CoreConstruct` + // based on whether this file already imported `constructs.Construct`. + let replaceBy: string | undefined; + + // determines whether an "import" statement should be added and it's + // contents. + let addImport: string | undefined; + + if (coreConstruct) { + // we already import `core.Construct` as `Construct` + replaceBy = 'Construct'; + } else if (coreCoreConstruct) { + // we already import `core.Construct` as `CoreConstruct` + replaceBy = 'CoreConstruct' + } else if (constructsConstruct) { + // we import `constructs.Construct`, so import and replace + // `core.Construct` with `CoreConstruct` + replaceBy = 'CoreConstruct'; + addImport = `import { Construct as ${replaceBy} } from '@aws-cdk/core';`; + } else { + // import `core.Construct` as `Construct` and replace + replaceBy = 'Construct'; + addImport = `import { ${replaceBy} } from '@aws-cdk/core';`; + } + + const fixes: Rule.Fix[] = [ + fixer.replaceTextRange(replaceRange, replaceBy) + ]; + + if (addImport) { + // find the last import statement in the file and add our import immediately after + const lastImport = imports[imports.length - 1]; + if (lastImport) { + fixes.push(fixer.insertTextAfter(lastImport.importNode, [ + "", + "", + "// keep this import separate from other imports to reduce chance for merge conflicts with v2-main", + "// eslint-disable-next-line no-duplicate-imports, import/order", + addImport, + ].join('\n'))); + } + } + + return fixes; + }, + }); +} \ No newline at end of file