Skip to content

Commit

Permalink
feat(aws-elasticloadbalancing): add crossZone property (aws#2786)
Browse files Browse the repository at this point in the history
enable cross-zone load balancing by default to comply with AWS Console behaviour
  • Loading branch information
ScOut3R committed Jun 12, 2019
1 parent 58de24d commit 3a84384
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
"Protocol": "http"
}
],
"CrossZone": false,
"CrossZone": true,
"HealthCheck": {
"HealthyThreshold": "2",
"Interval": "30",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@
"Protocol": "http"
}
],
"CrossZone": false,
"CrossZone": true,
"Scheme": "internal",
"SecurityGroups": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
"Protocol": "http"
}
],
"CrossZone": false,
"CrossZone": true,
"HealthCheck": {
"HealthyThreshold": "2",
"Interval": "30",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3a84384

Please sign in to comment.