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(elasticloadbalancingv2): imported listener ignores conditions attribute #9939

Merged
merged 2 commits into from
Aug 24, 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 @@ -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