Skip to content

Commit 7fb6fd6

Browse files
author
Elad Ben-Israel
authored
refactor(core): additional api cleanups (#2972)
Additional minor API cleanups in the core module (see breaking changes list). Updated physical names linter rule to verify that physical name property name is `cfnTypeName` and that it's type is either `PhysicalName` in case the name is optional and `string` if the name is required (fixes #2971). Moved all internal files in @aws-cdk/cdk under "private" BREAKING CHANGE: The deprecated `app.run()` has been removed (use `app.synth()`). * **core:** `CfnElement.refAsString` renamed to `ref` of `string` type. The `IResolvable` version have been removed. * **core:** `Resource.physicalName` is now a `string` instead of `PhysicalName`. If a physical name should be generated during deployment (i.e. not supplied to L1), the string will synthesize to `undefined`. * **core:** `IStringValue` renamed to `IStringProducer` * **core:** `Include` renamed to `CfnInclude` * **core:** `Cfn` prefix was added to the following types: `CfnCreationPolicy`, `CfnResourceAutoScalingCreationPolicy`, `CfnResourceAutoScalingCreationPolicy`, `CfnDeletionPolicy`, `CfnUpdatePolicy`, `CfnAutoScalingRollingUpdate`, `CfnAutoScalingReplacingUpdate`, `CfnAutoScalingScheduledAction`, `CfnCodeDeployLambdaAliasUpdate`, `CfnTag` `CfnRuleAssertion`, `CfnDynamicReferenceProps` * **core:** `deepMerge` is no longer exported. * **core:** `CfnOutputProps.export` was renamed to `exportName`. * **core:** `CfnOutput` all properties are now private * **core:** `StringListCfnOutput` has been removed
1 parent 67f6de0 commit 7fb6fd6

File tree

167 files changed

+759
-1206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+759
-1206
lines changed

packages/@aws-cdk/aws-apigateway/lib/api-key.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ export class ApiKey extends Resource implements IApiKey {
9292
description: props.description,
9393
enabled: props.enabled || true,
9494
generateDistinctId: props.generateDistinctId,
95-
name: this.physicalName.value,
95+
name: this.physicalName,
9696
stageKeys: this.renderStageKeys(props.resources)
9797
});
9898

99-
this.keyId = resource.refAsString;
99+
this.keyId = resource.ref;
100100
}
101101

102102
private renderStageKeys(resources: RestApi[] | undefined): CfnApiKey.StageKeyProperty[] | undefined {

packages/@aws-cdk/aws-apigateway/lib/deployment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Construct, DeletionPolicy, Lazy, Resource, Stack } from '@aws-cdk/cdk';
1+
import { CfnDeletionPolicy, Construct, Lazy, Resource, Stack } from '@aws-cdk/cdk';
22
import crypto = require('crypto');
33
import { CfnDeployment, CfnDeploymentProps } from './apigateway.generated';
44
import { IRestApi } from './restapi';
@@ -72,11 +72,11 @@ export class Deployment extends Resource {
7272
});
7373

7474
if (props.retainDeployments) {
75-
this.resource.options.deletionPolicy = DeletionPolicy.Retain;
75+
this.resource.options.deletionPolicy = CfnDeletionPolicy.Retain;
7676
}
7777

7878
this.api = props.api;
79-
this.deploymentId = Lazy.stringValue({ produce: () => this.resource.refAsString });
79+
this.deploymentId = Lazy.stringValue({ produce: () => this.resource.ref });
8080
}
8181

8282
/**

packages/@aws-cdk/aws-apigateway/lib/method.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class Method extends Resource {
123123

124124
const resource = new CfnMethod(this, 'Resource', methodProps);
125125

126-
this.methodId = resource.refAsString;
126+
this.methodId = resource.ref;
127127

128128
props.resource.restApi._attachMethod(this);
129129

packages/@aws-cdk/aws-apigateway/lib/resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export class Resource extends ResourceBase {
211211
};
212212
const resource = new CfnResource(this, 'Resource', resourceProps);
213213

214-
this.resourceId = resource.refAsString;
214+
this.resourceId = resource.ref;
215215
this.restApi = props.parent.restApi;
216216

217217
// render resource path (special case for root)

packages/@aws-cdk/aws-apigateway/lib/restapi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class RestApi extends Resource implements IRestApi {
203203
});
204204

205205
const resource = new CfnRestApi(this, 'Resource', {
206-
name: this.physicalName.value!,
206+
name: this.physicalName,
207207
description: props.description,
208208
policy: props.policy,
209209
failOnWarnings: props.failOnWarnings,
@@ -215,7 +215,7 @@ export class RestApi extends Resource implements IRestApi {
215215
parameters: props.parameters,
216216
});
217217

218-
this.restApiId = resource.refAsString;
218+
this.restApiId = resource.ref;
219219

220220
this.configureDeployment(props);
221221

packages/@aws-cdk/aws-apigateway/lib/stage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class Stage extends Resource {
197197
methodSettings,
198198
});
199199

200-
this.stageName = resource.refAsString;
200+
this.stageName = resource.ref;
201201
this.restApi = props.deployment.api;
202202
}
203203

packages/@aws-cdk/aws-apigateway/lib/usage-plan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class UsagePlan extends Resource {
165165

166166
this.apiStages.push(...(props.apiStages || []));
167167

168-
this.usagePlanId = resource.refAsString;
168+
this.usagePlanId = resource.ref;
169169

170170
// Add ApiKey when
171171
if (props.apiKey) {

packages/@aws-cdk/aws-apigateway/lib/vpc-link.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ export class VpcLink extends Resource {
4747
});
4848

4949
const cfnResource = new CfnVpcLink(this, 'Resource', {
50-
name: this.physicalName.value!,
50+
name: this.physicalName,
5151
description: props.description,
5252
targetArns: Lazy.listValue({ produce: () => this.renderTargets() })
5353
});
5454

55-
this.vpcLinkId = cfnResource.refAsString;
55+
this.vpcLinkId = cfnResource.ref;
5656

5757
if (props.targets) {
5858
this.addTargets(...props.targets);

packages/@aws-cdk/aws-apigateway/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@
9999
"props-physical-name:@aws-cdk/aws-apigateway.MethodProps",
100100
"props-physical-name:@aws-cdk/aws-apigateway.ProxyResourceProps",
101101
"props-physical-name:@aws-cdk/aws-apigateway.ResourceProps",
102-
"props-physical-name:@aws-cdk/aws-apigateway.StageProps",
103102
"props-physical-name:@aws-cdk/aws-apigateway.UsagePlanProps",
103+
"props-physical-name-type:@aws-cdk/aws-apigateway.StageProps.stageName",
104104
"props-physical-name:@aws-cdk/aws-apigateway.LambdaRestApiProps"
105105
]
106106
},

packages/@aws-cdk/aws-apigateway/test/test.lambda-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export = {
8181
runtime: lambda.Runtime.Nodejs810,
8282
});
8383
const alias = new lambda.Alias(stack, 'alias', {
84-
aliasName: cdk.PhysicalName.of('my-alias'),
84+
aliasName: 'my-alias',
8585
version: new lambda.Version(stack, 'version', {
8686
lambda: handler
8787
})

0 commit comments

Comments
 (0)