Skip to content

Commit

Permalink
fix(elasticloadbalancingv2): imported listener ignores conditions att…
Browse files Browse the repository at this point in the history
…ribute

New conditions attribute usage was fixed in #8385 for owned listeners, but
missed imported listeners.

fixes #9262
fixes #9320
fixes #9643
  • Loading branch information
njlynch committed Aug 24, 2020
1 parent fdddb10 commit 7702785
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ class ImportedApplicationListener extends Resource implements IApplicationListen
// New rule
new ApplicationListenerRule(this, id, {
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 @@ -464,6 +464,38 @@ export = {
test.done();
},

'Can call addTargetGroups on imported listener with conditions prop'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
const listener = elbv2.ApplicationListener.fromApplicationListenerAttributes(stack, 'Listener', {
listenerArn: 'ieks',
securityGroupId: 'sg-12345',
});
const group = new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', { vpc, port: 80 });

// WHEN
listener.addTargetGroups('Gruuup', {
priority: 30,
conditions: [elbv2.ListenerCondition.hostHeaders(['example.com'])],
targetGroups: [group],
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::ListenerRule', {
ListenerArn: 'ieks',
Priority: 30,
Actions: [
{
TargetGroupArn: { Ref: 'TargetGroup3D7CD9B8' },
Type: 'forward',
},
],
}));

test.done();
},

'Can depend on eventual listener via TargetGroup'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit 7702785

Please sign in to comment.