Skip to content

Commit

Permalink
chore: migrate constructs to use "constructs" module (#10506)
Browse files Browse the repository at this point in the history
This commits expands on a previous [commit]. A few CDK modules
have been migrated to use the `Construct` and `IConstruct` from
the "constructs" module instead of the "@aws-cdk/core" module.

Migrating modules to use the "constructs" module, prevents merge
conflicts from arising in these files when the construct compatibility
layer in "@aws-cdk/core" module is removed in the v2 branch.

[commit]: c179699

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar authored Sep 29, 2020
1 parent 37723e9 commit a76428b
Show file tree
Hide file tree
Showing 291 changed files with 923 additions and 400 deletions.
5 changes: 4 additions & 1 deletion packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"cdk-build": {
"cloudformation": "Alexa::ASK",
"jest": true
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-accessanalyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"cdk-build": {
"cloudformation": "AWS::AccessAnalyzer",
"jest": true
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-acmpca/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"cdk-build": {
"cloudformation": "AWS::ACMPCA",
"jest": true
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-amazonmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"cdk-build": {
"cloudformation": "AWS::AmazonMQ",
"jest": true
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/api-key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, IResource as IResourceBase, Resource } from '@aws-cdk/core';
import { IResource as IResourceBase, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApiKey } from './apigateway.generated';
import { ResourceOptions } from './resource';
import { RestApi } from './restapi';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/authorizer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource, ResourceProps } from '@aws-cdk/core';
import { Resource, ResourceProps } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { AuthorizationType } from './method';
import { IRestApi } from './restapi';

Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as iam from '@aws-cdk/aws-iam';
import * as lambda from '@aws-cdk/aws-lambda';
import { Construct, Duration, Lazy, Stack } from '@aws-cdk/core';
import { Duration, Lazy, Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnAuthorizer } from '../apigateway.generated';
import { Authorizer, IAuthorizer } from '../authorizer';
import { IRestApi } from '../restapi';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/base-path-mapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource, Token } from '@aws-cdk/core';
import { Resource, Token } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnBasePathMapping } from './apigateway.generated';
import { IDomainName } from './domain-name';
import { IRestApi, RestApi } from './restapi';
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as crypto from 'crypto';
import { Construct, Lazy, RemovalPolicy, Resource, CfnResource } from '@aws-cdk/core';
import { Construct as CoreConstruct, Lazy, RemovalPolicy, Resource, CfnResource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnDeployment } from './apigateway.generated';
import { Method } from './method';
import { IRestApi, RestApi, SpecRestApi, RestApiBase } from './restapi';
Expand Down Expand Up @@ -132,7 +133,7 @@ class LatestDeploymentResource extends CfnDeployment {
private readonly originalLogicalId: string;
private readonly api: IRestApi;

constructor(scope: Construct, id: string, props: LatestDeploymentResourceProps) {
constructor(scope: CoreConstruct, id: string, props: LatestDeploymentResourceProps) {
super(scope, id, {
description: props.description,
restApiId: props.restApi.restApiId,
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/domain-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as acm from '@aws-cdk/aws-certificatemanager';
import { Construct, IResource, Resource, Token } from '@aws-cdk/core';
import { IResource, Resource, Token } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnDomainName } from './apigateway.generated';
import { BasePathMapping, BasePathMappingOptions } from './base-path-mapping';
import { EndpointType, IRestApi } from './restapi';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/gateway-response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, IResource, Resource } from '@aws-cdk/core';
import { IResource, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnGatewayResponse } from './apigateway.generated';
import { IRestApi } from './restapi';

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/lambda-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as lambda from '@aws-cdk/aws-lambda';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { LambdaIntegration } from './integrations';
import { Method } from './method';
import { ProxyResource, Resource } from './resource';
Expand Down Expand Up @@ -42,7 +42,7 @@ export interface LambdaRestApiProps extends RestApiProps {
* add resources and methods to the API.
*/
export class LambdaRestApi extends RestApi {
constructor(scope: cdk.Construct, id: string, props: LambdaRestApiProps) {
constructor(scope: Construct, id: string, props: LambdaRestApiProps) {
if ((props.options && props.options.defaultIntegration) || props.defaultIntegration) {
throw new Error('Cannot specify "defaultIntegration" since Lambda integration is automatically defined');
}
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource, Stack } from '@aws-cdk/core';
import { Resource, Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnMethod, CfnMethodProps } from './apigateway.generated';
import { Authorizer, IAuthorizer } from './authorizer';
import { Integration, IntegrationConfig } from './integration';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource } from '@aws-cdk/core';
import { Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnModel, CfnModelProps } from './apigateway.generated';
import * as jsonSchema from './json-schema';
import { IRestApi, RestApi } from './restapi';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/rate-limited-api-key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource } from '@aws-cdk/core';
import { Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { ApiKey, ApiKeyProps, IApiKey } from './api-key';
import { QuotaSettings, ThrottleSettings, UsagePlan, UsagePlanPerApiStage } from './usage-plan';

Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/requestvalidator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, IResource, Resource } from '@aws-cdk/core';
import { IResource, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnRequestValidator, CfnRequestValidatorProps } from './apigateway.generated';
import { IRestApi, RestApi } from './restapi';

Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, IResource as IResourceBase, Resource as ResourceConstruct } from '@aws-cdk/core';
import { IResource as IResourceBase, Resource as ResourceConstruct } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnResource, CfnResourceProps } from './apigateway.generated';
import { Cors, CorsOptions } from './cors';
import { Integration } from './integration';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IVpcEndpoint } from '@aws-cdk/aws-ec2';
import * as iam from '@aws-cdk/aws-iam';
import { CfnOutput, Construct, IResource as IResourceBase, Resource, Stack } from '@aws-cdk/core';
import { CfnOutput, IResource as IResourceBase, Resource, Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { ApiDefinition } from './api-definition';
import { ApiKey, ApiKeyOptions, IApiKey } from './api-key';
import { CfnAccount, CfnRestApi } from './apigateway.generated';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/stage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Duration, IResource, Resource, Stack, Token } from '@aws-cdk/core';
import { Duration, IResource, Resource, Stack, Token } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { AccessLogFormat, IAccessLogDestination } from './access-log';
import { CfnStage } from './apigateway.generated';
import { Deployment } from './deployment';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/usage-plan.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Lazy, Resource, Token } from '@aws-cdk/core';
import { Lazy, Resource, Token } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { IApiKey } from './api-key';
import { CfnUsagePlan, CfnUsagePlanKey } from './apigateway.generated';
import { Method } from './method';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/vpc-link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
import { Construct, IResource, Lazy, Resource } from '@aws-cdk/core';
import { IResource, Lazy, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnVpcLink } from './apigateway.generated';

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-apigateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
"compat": "cdk-compat"
},
"cdk-build": {
"cloudformation": "AWS::ApiGateway"
"cloudformation": "AWS::ApiGateway",
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/lib/common/domain-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ICertificate } from '@aws-cdk/aws-certificatemanager';
import { Construct, IResource, Resource, Token } from '@aws-cdk/core';
import { IResource, Resource, Token } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnDomainName, CfnDomainNameProps } from '../apigatewayv2.generated';

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/lib/http/api-mapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource } from '@aws-cdk/core';
import { Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApiMapping, CfnApiMappingProps } from '../apigatewayv2.generated';
import { IApiMapping, IDomainName } from '../common';
import { IHttpApi } from '../http/api';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Duration, IResource, Resource } from '@aws-cdk/core';
import { Duration, IResource, Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApi, CfnApiProps } from '../apigatewayv2.generated';
import { DefaultDomainMappingOptions } from '../http/stage';
import { IHttpRouteIntegration } from './integration';
Expand Down
9 changes: 7 additions & 2 deletions packages/@aws-cdk/aws-apigatewayv2/lib/http/integration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Construct, Resource } from '@aws-cdk/core';
import { Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnIntegration } from '../apigatewayv2.generated';
import { IIntegration } from '../common';
import { IHttpApi } from './api';
import { HttpMethod, IHttpRoute } from './route';

// v2 - keep this import as a separate section to reduce merge conflict when forward merging with the v2 branch.
// eslint-disable-next-line
import { Construct as CoreConstruct } from '@aws-cdk/core';

/**
* Represents an Integration for an HTTP API.
*/
Expand Down Expand Up @@ -126,7 +131,7 @@ export interface HttpRouteIntegrationBindOptions {
* If the `HttpRouteIntegration` being bound creates additional constructs,
* this will be used as their parent scope.
*/
readonly scope: Construct;
readonly scope: CoreConstruct;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/lib/http/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource } from '@aws-cdk/core';
import { Resource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnRoute, CfnRouteProps } from '../apigatewayv2.generated';
import { IRoute } from '../common';
import { IHttpApi } from './api';
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/lib/http/stage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Construct, Resource, Stack } from '@aws-cdk/core';
import { Resource, Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnStage } from '../apigatewayv2.generated';
import { CommonStageOptions, IDomainName, IStage } from '../common';
import { IHttpApi } from './api';
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"cdk-build": {
"cloudformation": "AWS::ApiGatewayV2",
"jest": true
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-appconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"cdk-build": {
"cloudformation": "AWS::AppConfig",
"jest": true
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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';
Expand Down Expand Up @@ -46,7 +47,7 @@ export interface BaseScalableAttributeProps extends EnableScalingProps {
export abstract class BaseScalableAttribute extends cdk.Construct {
private target: ScalableTarget;

public constructor(scope: cdk.Construct, id: string, protected readonly props: BaseScalableAttributeProps) {
public constructor(scope: Construct, id: string, protected readonly props: BaseScalableAttributeProps) {
super(scope, id);

this.target = new ScalableTarget(this, 'Target', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as iam from '@aws-cdk/aws-iam';
import { Construct, IResource, Lazy, Resource, withResolved } from '@aws-cdk/core';
import { IResource, Lazy, Resource, withResolved } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnScalableTarget } from './applicationautoscaling.generated';
import { Schedule } from './schedule';
import { BasicStepScalingPolicyProps, StepScalingPolicy } from './step-scaling-policy';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnScalingPolicy } from './applicationautoscaling.generated';
import { IScalableTarget } from './scalable-target';

Expand Down Expand Up @@ -74,7 +75,7 @@ export class StepScalingAction extends cdk.Construct {

private readonly adjustments = new Array<CfnScalingPolicy.StepAdjustmentProperty>();

constructor(scope: cdk.Construct, id: string, props: StepScalingActionProps) {
constructor(scope: Construct, id: string, props: StepScalingActionProps) {
super(scope, id);

// Cloudformation requires either the ResourceId, ScalableDimension, and ServiceNamespace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { findAlarmThresholds, normalizeIntervals } from '@aws-cdk/aws-autoscaling-common';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { IScalableTarget } from './scalable-target';
import { AdjustmentType, MetricAggregationType, StepScalingAction } from './step-scaling-action';

Expand Down Expand Up @@ -68,7 +69,7 @@ export class StepScalingPolicy extends cdk.Construct {
public readonly upperAlarm?: cloudwatch.Alarm;
public readonly upperAction?: StepScalingAction;

constructor(scope: cdk.Construct, id: string, props: StepScalingPolicyProps) {
constructor(scope: Construct, id: string, props: StepScalingPolicyProps) {
super(scope, id);

if (props.scalingSteps.length < 2) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnScalingPolicy } from './applicationautoscaling.generated';
import { IScalableTarget } from './scalable-target';

Expand Down Expand Up @@ -120,7 +121,7 @@ export class TargetTrackingScalingPolicy extends cdk.Construct {
*/
public readonly scalingPolicyArn: string;

constructor(scope: cdk.Construct, id: string, props: TargetTrackingScalingPolicyProps) {
constructor(scope: Construct, id: string, props: TargetTrackingScalingPolicyProps) {
if ((props.customMetric === undefined) === (props.predefinedMetric === undefined)) {
throw new Error('Exactly one of \'customMetric\' or \'predefinedMetric\' must be specified.');
}
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
"compat": "cdk-compat"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationAutoScaling"
"cloudformation": "AWS::ApplicationAutoScaling",
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-applicationinsights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"cdk-build": {
"cloudformation": "AWS::ApplicationInsights",
"jest": true
"jest": true,
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"keywords": [
"aws",
Expand Down
Loading

0 comments on commit a76428b

Please sign in to comment.