From e7ce821d210f3aa8098f66beb9b8c47f878ffc5d Mon Sep 17 00:00:00 2001 From: Nick Lynch Date: Wed, 31 Mar 2021 14:37:55 +0100 Subject: [PATCH] fix(cloudfront): Cache Policy headers enforce soft limit of 10 Validation was added in #13425 to enforce a limit of the number of headers allowed in the allow list for a Cache Policy; that limit is a soft limit and should not be hard-enforced in code. fixes #13903 This reverts commit e08213fd2b5c27ce8b5dd2d22ebbff1dc1b48a1c. --- packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts | 3 --- .../@aws-cdk/aws-cloudfront/test/cache-policy.test.ts | 11 ----------- 2 files changed, 14 deletions(-) diff --git a/packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts b/packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts index a71569e89f02d..0d851e8a886ef 100644 --- a/packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts +++ b/packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts @@ -231,9 +231,6 @@ export class CacheHeaderBehavior { if (headers.length === 0) { throw new Error('At least one header to allow must be provided'); } - if (headers.length > 10) { - throw new Error(`Maximum allowed headers in Cache Policy is 10; got ${headers.length}.`); - } return new CacheHeaderBehavior('whitelist', headers); } diff --git a/packages/@aws-cdk/aws-cloudfront/test/cache-policy.test.ts b/packages/@aws-cdk/aws-cloudfront/test/cache-policy.test.ts index 07d2752de4e2c..7216d798a7e75 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/cache-policy.test.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/cache-policy.test.ts @@ -96,17 +96,6 @@ describe('CachePolicy', () => { expect(() => new CachePolicy(stack, 'CachePolicy6', { cachePolicyName: 'My_Policy' })).not.toThrow(); }); - test('throws if more than 10 CacheHeaderBehavior headers are being passed', () => { - const errorMessage = /Maximum allowed headers in Cache Policy is 10; got (.*?)/; - expect(() => new CachePolicy(stack, 'CachePolicy1', { - headerBehavior: CacheHeaderBehavior.allowList('Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'sed', 'do', 'eiusmod'), - })).toThrow(errorMessage); - - expect(() => new CachePolicy(stack, 'CachePolicy2', { - headerBehavior: CacheHeaderBehavior.allowList('Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'sed', 'do'), - })).not.toThrow(); - }); - test('does not throw if cachePolicyName is a token', () => { expect(() => new CachePolicy(stack, 'CachePolicy', { cachePolicyName: Aws.STACK_NAME,