Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-elasticloadbalancing): add crossZone property #2787

Merged
merged 6 commits into from
Jun 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(aws-elasticloadbalancing): add crossZone property (#2786)
enable cross-zone load balancing by default to comply with AWS Console behaviour
ScOut3R committed Jun 12, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3a843843633a7942365a510e61b9867d85e563f3
Original file line number Diff line number Diff line change
@@ -691,7 +691,7 @@
"Protocol": "http"
}
],
"CrossZone": false,
"CrossZone": true,
"HealthCheck": {
"HealthyThreshold": "2",
"Interval": "30",
Original file line number Diff line number Diff line change
@@ -725,7 +725,7 @@
"Protocol": "http"
}
],
"CrossZone": false,
"CrossZone": true,
"Scheme": "internal",
"SecurityGroups": [
{
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ export interface LoadBalancerProps {
* This controls whether the load balancer evenly distributes requests
* across each availability zone
*
* @default - false.
* @default true
*/
readonly crossZone?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does true make more sense as a default value here? I would feel better with that as a default value, and it seems the ELB team agrees:

According to: https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-crosszone-lb.html

With the AWS Management Console, the option to enable cross-zone load balancing is selected by default.

Given that we kind of see the CDK as the "AWS console but without clicking", it makes sense to me that the recommended defaults would be the same between console and CDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rix0rrr good suggestion! I was just merely following the CloudFormation documentation.

I've updated my PR based on your recommendation. Let me know what you think.

}
@@ -236,7 +236,7 @@ export class LoadBalancer extends Resource implements IConnectable {
listeners: Lazy.anyValue({ produce: () => this.listeners }),
scheme: props.internetFacing ? 'internet-facing' : 'internal',
healthCheck: props.healthCheck && healthCheckToJSON(props.healthCheck),
crossZone: props.crossZone || false,
crossZone: (props.crossZone === undefined || props.crossZone) ? true : false
});
if (props.internetFacing) {
this.elb.node.addDependency(...subnets.map(s => s.internetConnectivityEstablished));
Original file line number Diff line number Diff line change
@@ -228,7 +228,7 @@
"Protocol": "http"
}
],
"CrossZone": false,
"CrossZone": true,
"HealthCheck": {
"HealthyThreshold": "2",
"Interval": "30",
Original file line number Diff line number Diff line change
@@ -112,7 +112,45 @@ export = {
}));

test.done();
}
},

'disable cross zone load balancing'(test: Test) {
// GIVEN
const stack = new Stack();
const vpc = new Vpc(stack, 'VCP');

// WHEN
new LoadBalancer(stack, 'LB', {
vpc,
crossZone: false,
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancing::LoadBalancer', {
CrossZone: false
}));

test.done();
},

'cross zone load balancing enabled by default'(test: Test) {
// GIVEN
const stack = new Stack();
const vpc = new Vpc(stack, 'VCP');

// WHEN
new LoadBalancer(stack, 'LB', {
vpc,
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancing::LoadBalancer', {
CrossZone: true
}));

test.done();
},

};

class FakeTarget implements ILoadBalancerTarget {