question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cloudfront: Maximum number of allowlisted headers in Cache Policy is incorrectly set to 10

See original GitHub issue

After upgrading our CDK CLI version and library for cloudfront we ran into the following error:

Error: Maximum allowed headers in Cache Policy is 10; got 13.

This seems to be enforced via https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-cloudfront/lib/cache-policy.ts#L234.

The maximum amount of 10 headers is in fact a soft limit that can be increased through AWS support (which we did) and should therefore not be treated as a hard limit here. See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html#limits-policies.

It seems this if check is not in place for cookies or querystrings though, so there are no issues there.

Reproduction Steps

Create a cache policy with more than 10 whitelisted headers in the headerBehavior.

const exampleCachePolicy = new cloudfront.CachePolicy(this, 'ExampleCachePolicy', {
            cachePolicyName: 'example-policy',
            headerBehavior: cloudfront.CacheHeaderBehavior.allowList(
                'Header-1',
                'Header-2',
                'Header-3',
                'Header-4',
                'Header-5',
                'Header-6',
                'Header-7',
                'Header-8',
                'Header-9',
                'Header-10',
                'Header-11'
            ),
        });

What did you expect to happen?

The cache policy’s creation/update should be based on the account’s proper quotas instead of failing on the hardcoded check within the cdk lib. F.e. if the account had its quota increased to 20, it should only fail if there are >20 headers in the allowList.

What actually happened?

The cdk diff fails with Error: Maximum allowed headers in Cache Policy is 10; got 11.

Environment

  • CDK CLI Version : 1.95.1 (build ed2bbe6)
  • Framework Version:
  • Node.js Version: v15.12.0
  • OS : Debian
  • Language (Version): TypeScript

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
njlynchcommented, Mar 31, 2021

Thanks for the report; when the validation was created, we missed the fact it was a soft (increasable) limit. We unfortunately can’t dynamically validate the limit client-side based on each account’s limits, but we can remove the validation entirely and leave it to CloudFormation to enforce.

1reaction
robertdcommented, Mar 31, 2021

@njlynch @encron Sorry about that. I’ve somehow missed that this was a soft limit. Also, PR #13907 has been created to revert similar checks in Origin Request Policy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quotas - Amazon CloudFront
Lists the quotas (formerly referred to as limits) for Amazon CloudFront, such as the quotas on ... 10. Request a higher quota. Headers...
Read more >
Caching with Fastify and AWS Cloudfront
We'll use fastify as a web server and Amazon CloudFront as CDN, in order to optimize HTTP response times via HTTP caching headers....
Read more >
Caching configuration best practices | Fastly Help Guides
You can use cache control headers to set policies that determine how long your data is cached. Fastly looks for caching information in...
Read more >
Serverless Framework - AWS Lambda Events - CloudFront
Distribution configuration contains origins and behaviors which are used to define how to cache and deliver content from other services. Origin is the...
Read more >
Troubleshooting Omnibus GitLab installation issues
Double check that there are no typos or that the configuration file does not ... of GitLab and the proxy headers set in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found