Skip to content

Commit cc08440

Browse files
author
Conroy
committed
fixed bug in elbv2
1 parent 42bfda6 commit cc08440

File tree

4 files changed

+766
-0
lines changed

4 files changed

+766
-0
lines changed

packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
244244
// TargetGroup.registerListener is called inside ApplicationListenerRule.
245245
new ApplicationListenerRule(this, id + 'Rule', {
246246
listener: this,
247+
conditions: props.conditions,
247248
hostHeader: props.hostHeader,
248249
pathPattern: props.pathPattern,
249250
pathPatterns: props.pathPatterns,

packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.actions.ts

+49
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,53 @@ export = {
182182

183183
test.done();
184184
},
185+
186+
'Add Action with multiple Conditions'(test: Test) {
187+
// GIVEN
188+
const listener = lb.addListener('Listener', { port: 80 });
189+
190+
// WHEN
191+
listener.addAction('Action1', {
192+
action: elbv2.ListenerAction.forward([group1]),
193+
});
194+
195+
listener.addAction('Action2', {
196+
conditions: [
197+
elbv2.ListenerCondition.hostHeaders(['example.com']),
198+
elbv2.ListenerCondition.sourceIps(['1.1.1.1/32']),
199+
],
200+
priority: 10,
201+
action: elbv2.ListenerAction.forward([group2]),
202+
});
203+
204+
// THEN
205+
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::ListenerRule', {
206+
Actions: [
207+
{
208+
TargetGroupArn: { Ref: 'TargetGroup2D571E5D7' },
209+
Type: 'forward',
210+
},
211+
],
212+
Conditions: [
213+
{
214+
Field: 'host-header',
215+
HostHeaderConfig: {
216+
Values: [
217+
'example.com',
218+
],
219+
},
220+
},
221+
{
222+
Field: 'source-ip',
223+
SourceIpConfig: {
224+
Values: [
225+
'1.1.1.1/32',
226+
],
227+
},
228+
},
229+
],
230+
}));
231+
232+
test.done();
233+
},
185234
};

0 commit comments

Comments
 (0)