Skip to content

Commit 5b24583

Browse files
author
Elad Ben-Israel
authoredJan 7, 2019
fix(elbv2): unable to specify load balancer name (#1486)
Since #973, the renames of CFN properties from "name" to "xxxName" were removed. But the ELBv2 library still used `loadBalancerName`. The reason this was not discovered was because we are splatting `additionalProps` of type `any`, and this caused the type checker to stop verifying property names. Fixes #1481
1 parent b61c7c9 commit 5b24583

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed
 

Diff for: ‎packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export abstract class BaseLoadBalancer extends cdk.Construct implements route53.
104104
this.vpc = baseProps.vpc;
105105

106106
const resource = new CfnLoadBalancer(this, 'Resource', {
107-
loadBalancerName: baseProps.loadBalancerName,
107+
name: baseProps.loadBalancerName,
108108
subnets: subnets.map(s => s.subnetId),
109109
scheme: internetFacing ? 'internet-facing' : 'internal',
110110
loadBalancerAttributes: new cdk.Token(() => renderAttributes(this.attributes)),

Diff for: ‎packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.load-balancer.ts

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expect, haveResource, ResourcePart } from '@aws-cdk/assert';
22
import ec2 = require('@aws-cdk/aws-ec2');
33
import s3 = require('@aws-cdk/aws-s3');
44
import cdk = require('@aws-cdk/cdk');
5+
import { Stack } from '@aws-cdk/cdk';
56
import { Test } from 'nodeunit';
67
import elbv2 = require('../../lib');
78

@@ -186,4 +187,22 @@ export = {
186187

187188
test.done();
188189
},
190+
191+
'loadBalancerName'(test: Test) {
192+
// GIVEN
193+
const stack = new Stack();
194+
const vpc = new ec2.VpcNetwork(stack, 'Stack');
195+
196+
// WHEN
197+
new elbv2.ApplicationLoadBalancer(stack, 'ALB', {
198+
loadBalancerName: 'myLoadBalancer',
199+
vpc
200+
});
201+
202+
// THEN
203+
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer', {
204+
Name: 'myLoadBalancer'
205+
}));
206+
test.done();
207+
},
189208
};

Diff for: ‎packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/test.load-balancer.ts

+19
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,23 @@ export = {
7575

7676
test.done();
7777
},
78+
79+
'loadBalancerName'(test: Test) {
80+
// GIVEN
81+
const stack = new cdk.Stack();
82+
const vpc = new ec2.VpcNetwork(stack, 'Stack');
83+
84+
// WHEN
85+
new elbv2.NetworkLoadBalancer(stack, 'ALB', {
86+
loadBalancerName: 'myLoadBalancer',
87+
vpc
88+
});
89+
90+
// THEN
91+
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer', {
92+
Name: 'myLoadBalancer'
93+
}));
94+
test.done();
95+
}
96+
7897
};

0 commit comments

Comments
 (0)