Skip to content

Commit

Permalink
fix(elbv2): validate rule priority is a positive number (#6222)
Browse files Browse the repository at this point in the history
* fix(elasticloadbalancingv2): logAccessLogs in Base Load Balancer

Moving the method logAccessLogs to the Base Load Balancer, so both types
of Load Balancer (Network and Application) can use the method.

closes #3794

* fix(elbv2): Validating if priority is greater than ZERO

The Application Load Balancer does not accepts priority equal or less
than ZERO. Throws an error if passes ZERO or less.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
rzamana and mergify[bot] authored Feb 11, 2020
1 parent a1294d3 commit 1fbaafe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ export class ApplicationListenerRule extends cdk.Construct {
throw new Error(`'${providedActions}' specified together, specify only one`);
}

if (props.priority <= 0) {
throw new Error('Priority must have value greater than or equal to 1');
}

this.listener = props.listener;

const resource = new CfnListenerRule(this, 'Resource', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,30 @@ export = {
test.done();
},

'Throws when specifying priority 0'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LoadBalancer', {
vpc
});
const listener = lb.addListener('Listener', {
port: 80
});

// THEN
test.throws(() => new elbv2.ApplicationListenerRule(stack, 'Rule', {
listener,
priority: 0,
pathPattern: '/hello',
fixedResponse: {
statusCode: '500'
}
}), Error, 'Priority must have value greater than or equal to 1');

test.done();
},

'Throws when specifying both target groups and redirect reponse'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit 1fbaafe

Please sign in to comment.