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(elbv2): fix setting proxyProtocolV2 to false #4596

Merged
merged 2 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -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();
},
};