Skip to content

Commit

Permalink
fix(elbv2): addAction ignores conditions (#8385)
Browse files Browse the repository at this point in the history
Elastic Load Balancer's ApplicationListener.addAction does not pass on conditions array to ApplicationListenerRule. 

This PR adds a line that passes on the conditions in the addAction function.

fixes #8328 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaizencc authored Jun 5, 2020
1 parent a3e23cd commit 729cc0b
Show file tree
Hide file tree
Showing 4 changed files with 766 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
// TargetGroup.registerListener is called inside ApplicationListenerRule.
new ApplicationListenerRule(this, id + 'Rule', {
listener: this,
conditions: props.conditions,
hostHeader: props.hostHeader,
pathPattern: props.pathPattern,
pathPatterns: props.pathPatterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,53 @@ export = {

test.done();
},

'Add Action with multiple Conditions'(test: Test) {
// GIVEN
const listener = lb.addListener('Listener', { port: 80 });

// WHEN
listener.addAction('Action1', {
action: elbv2.ListenerAction.forward([group1]),
});

listener.addAction('Action2', {
conditions: [
elbv2.ListenerCondition.hostHeaders(['example.com']),
elbv2.ListenerCondition.sourceIps(['1.1.1.1/32']),
],
priority: 10,
action: elbv2.ListenerAction.forward([group2]),
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::ListenerRule', {
Actions: [
{
TargetGroupArn: { Ref: 'TargetGroup2D571E5D7' },
Type: 'forward',
},
],
Conditions: [
{
Field: 'host-header',
HostHeaderConfig: {
Values: [
'example.com',
],
},
},
{
Field: 'source-ip',
SourceIpConfig: {
Values: [
'1.1.1.1/32',
],
},
},
],
}));

test.done();
},
};
Loading

0 comments on commit 729cc0b

Please sign in to comment.