Skip to content

Commit 3f86603

Browse files
authored
fix: remove CloudFormation property renames (#973)
The construct id parameter used to be a property called `name` in the props object, and so properties called `name` were renamed to `xxxName` (where `xxx` is the name of the resource). Since we now pass names as a constructor argument, we can get rid of the properly rename mechanism. BREAKING CHANGE: if you use L1s, you may need to change some `XxxName` properties back into `Name`. These will match the CloudFormation property names. Fixes #852.
1 parent 770f9aa commit 3f86603

File tree

17 files changed

+37
-92
lines changed

17 files changed

+37
-92
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class RestApi extends RestApiRef implements cdk.IDependable {
176176
super(parent, id);
177177

178178
const resource = new cloudformation.RestApiResource(this, 'Resource', {
179-
restApiName: props.restApiName || id,
179+
name: props.restApiName || id,
180180
description: props.description,
181181
policy: props.policy,
182182
failOnWarnings: props.failOnWarnings,

packages/@aws-cdk/aws-codebuild/lib/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ export class Project extends ProjectRef {
522522
encryptionKey: props.encryptionKey && props.encryptionKey.keyArn,
523523
badgeEnabled: props.badge,
524524
cache,
525-
projectName: props.projectName,
525+
name: props.projectName,
526526
});
527527

528528
this.projectArn = resource.projectArn;

packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class Pipeline extends cdk.Construct implements events.IEventRuleTarget {
9797
stages: new cdk.Token(() => this.renderStages()) as any,
9898
roleArn: this.role.roleArn,
9999
restartExecutionOnUpdate: props && props.restartExecutionOnUpdate,
100-
pipelineName: props && props.pipelineName,
100+
name: props && props.pipelineName,
101101
});
102102

103103
// this will produce a DependsOn for both the role and the policy resources.

packages/@aws-cdk/aws-events/lib/rule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class EventRule extends EventRuleRef {
7474
super(parent, name);
7575

7676
const resource = new cloudformation.RuleResource(this, 'Resource', {
77-
ruleName: props.ruleName,
77+
name: props.ruleName,
7878
description: props.description,
7979
state: props.enabled == null ? 'ENABLED' : (props.enabled ? 'ENABLED' : 'DISABLED'),
8080
scheduleExpression: new Token(() => this.scheduleExpression),

packages/@aws-cdk/aws-kinesis/lib/stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export class Stream extends StreamRef {
297297
const { streamEncryption, encryptionKey } = this.parseEncryption(props);
298298

299299
this.stream = new cloudformation.StreamResource(this, "Resource", {
300-
streamName: props.streamName,
300+
name: props.streamName,
301301
retentionPeriodHours,
302302
shardCount,
303303
streamEncryption

packages/@aws-cdk/aws-lambda/lib/alias.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class Alias extends FunctionRef {
8686
this.underlyingLambda = props.version.lambda;
8787

8888
const alias = new cloudformation.AliasResource(this, 'Resource', {
89-
aliasName: props.aliasName,
89+
name: props.aliasName,
9090
description: props.description,
9191
functionName: this.underlyingLambda.functionName,
9292
functionVersion: props.version.functionVersion,

packages/@aws-cdk/aws-route53/lib/hosted-zone.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ function toVpcProperty(vpc: ec2.VpcNetworkRef): cloudformation.HostedZoneResourc
125125
}
126126

127127
function determineHostedZoneProps(props: PublicHostedZoneProps) {
128-
const hostedZoneName = props.zoneName + '.';
128+
const name = props.zoneName + '.';
129129
const hostedZoneConfig = props.comment ? { comment: props.comment } : undefined;
130130
const queryLoggingConfig = props.queryLogsLogGroupArn ? { cloudWatchLogsLogGroupArn: props.queryLogsLogGroupArn } : undefined;
131131

132-
return { hostedZoneName, hostedZoneConfig, queryLoggingConfig };
132+
return { name, hostedZoneConfig, queryLoggingConfig };
133133
}

packages/@aws-cdk/aws-route53/lib/records/txt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class TXTRecord extends Construct {
2323

2424
new cloudformation.RecordSetResource(this, 'Resource', {
2525
hostedZoneId: parent.hostedZoneId,
26-
recordSetName: determineFullyQualifiedDomainName(props.recordName, parent),
26+
name: determineFullyQualifiedDomainName(props.recordName, parent),
2727
type: 'TXT',
2828
resourceRecords: [recordValue],
2929
ttl: ttl.toString()

packages/@aws-cdk/aws-route53/lib/records/zone-delegation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ZoneDelegationRecord extends Construct {
4040

4141
new cloudformation.RecordSetResource(this, 'Resource', {
4242
hostedZoneId: parent.hostedZoneId,
43-
recordSetName: determineFullyQualifiedDomainName(props.delegatedZoneName, parent),
43+
name: determineFullyQualifiedDomainName(props.delegatedZoneName, parent),
4444
type: 'NS',
4545
ttl: ttl.toString(),
4646
comment: props.comment,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect, haveResource } from '@aws-cdk/assert';
2+
import cdk = require('@aws-cdk/cdk');
3+
import { Test } from 'nodeunit';
4+
import ssm = require('../lib');
5+
6+
export = {
7+
'association name is rendered properly in L1 construct'(test: Test) {
8+
// GIVEN
9+
const stack = new cdk.Stack();
10+
11+
// WHEN
12+
new ssm.cloudformation.AssociationResource(stack, 'Assoc', {
13+
name: 'document',
14+
});
15+
16+
// THEN
17+
expect(stack).to(haveResource('AWS::SSM::Association', {
18+
Name: 'document',
19+
}));
20+
test.done();
21+
}
22+
};

0 commit comments

Comments
 (0)