Skip to content
Open
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 @@ -45,6 +45,12 @@ new elbv2.ApplicationLoadBalancer(stack, 'Http2EnabledTrue', {
http2Enabled: true,
});

new elbv2.ApplicationLoadBalancer(stack, 'DropInvalidHeaderFieldsFalse', {
vpc,
internetFacing: true,
dropInvalidHeaderFields: false,
});

new integ.IntegTest(app, 'Elbv2Test', {
testCases: [stack],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const vpc = new ec2.Vpc(stack, 'VPC', {
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LB', {
vpc,
internetFacing: true,
dropInvalidHeaderFields: false,
});

const listener = lb.addListener('Listener', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic

if (props.http2Enabled !== undefined) { this.setAttribute('routing.http2.enabled', props.http2Enabled ? 'true' : 'false'); }
if (props.idleTimeout !== undefined) { this.setAttribute('idle_timeout.timeout_seconds', props.idleTimeout.toSeconds().toString()); }
if (props.dropInvalidHeaderFields) { this.setAttribute('routing.http.drop_invalid_header_fields.enabled', 'true'); }
if (props.dropInvalidHeaderFields !== undefined) { this.setAttribute('routing.http.drop_invalid_header_fields.enabled', props.dropInvalidHeaderFields ? 'true' : 'false'); }
if (props.desyncMitigationMode !== undefined) { this.setAttribute('routing.http.desync_mitigation_mode', props.desyncMitigationMode); }
if (props.preserveHostHeader) { this.setAttribute('routing.http.preserve_host_header.enabled', 'true'); }
if (props.xAmznTlsVersionAndCipherSuiteHeaders) { this.setAttribute('routing.http.x_amzn_tls_version_and_cipher_suite.enabled', 'true'); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1519,4 +1519,51 @@ describe('tests', () => {
}).toThrow('dual-stack without public IPv4 address can only be used with internet-facing scheme.');
});
});

describe('Drop Invalid Header Fields', () => {
test.each([true, false])('sets dropInvalidHeaderFields to %s', (dropInvalidHeaderFields) => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Stack');

// WHEN
new elbv2.ApplicationLoadBalancer(stack, 'LB', {
vpc,
dropInvalidHeaderFields,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::LoadBalancer', {
LoadBalancerAttributes: Match.arrayWith([
{
Key: 'routing.http.drop_invalid_header_fields.enabled',
Value: String(dropInvalidHeaderFields),
},
]),
});
});

test('dropInvalidHeaderFields is not set when undefined', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Stack');

// WHEN
new elbv2.ApplicationLoadBalancer(stack, 'LB', {
vpc,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::LoadBalancer', {
LoadBalancerAttributes: Match.not(
Match.arrayWith([
{
Key: 'routing.http.drop_invalid_header_fields.enabled',
Value: Match.anyValue(),
},
]),
),
});
});
});
});
Loading