Skip to content

Commit

Permalink
fix(elbv2): fix disabling proxy protocol v2 attribute for NetworkTarg…
Browse files Browse the repository at this point in the history
…etGroup (#4596)

fixes #4574
  • Loading branch information
v-do authored and mergify[bot] committed Oct 23, 2019
1 parent 203a605 commit 8b598c4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class NetworkTargetGroup extends TargetGroupBase implements INetworkTarge

this.listeners = [];

if (props.proxyProtocolV2) {
this.setAttribute('proxy_protocol_v2.enabled', 'true');
if (props.proxyProtocolV2 != null) {
this.setAttribute('proxy_protocol_v2.enabled', props.proxyProtocolV2 ? 'true' : 'false');
}

this.addTarget(...(props.targets || []));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { expect, haveResource } from '@aws-cdk/assert';
import cdk = require('@aws-cdk/core');
import { Test } from 'nodeunit';
import elbv2 = require('../../lib');

export = {
'Enable proxy protocol v2 attribute for target group'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

// WHEN
new elbv2.NetworkTargetGroup(stack, 'Group', {
port: 80,
proxyProtocolV2: true
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
TargetGroupAttributes: [
{
Key: 'proxy_protocol_v2.enabled',
Value: 'true'
}
]
}));

test.done();
},

'Disable proxy protocol v2 for attribute target group'(test: Test) {
// GIVEN
const stack = new cdk.Stack();

// WHEN
new elbv2.NetworkTargetGroup(stack, 'Group', {
port: 80,
proxyProtocolV2: false
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
TargetGroupAttributes: [
{
Key: 'proxy_protocol_v2.enabled',
Value: 'false'
}
]
}));

test.done();
},
};

0 comments on commit 8b598c4

Please sign in to comment.