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

fix(elbv2): validate rule priority is a positive number #6222

Merged
merged 6 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
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