feat(nextjs-cdk-construct): Allow cache policies to be provided as props #2350
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our company has started to extensively use the CDK construct for next.js and it's been working great so far 🎉
However, since each app builds its own 3 unique cache policies, we have started to run into a limitation. AWS only allows you to have 20 cache policies per account. See
Cache policies per AWS account
in AWS docs here:https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html#limits-policies
Since all the next apps have the same 3 cache policies duplicated, we created 3 universal ones to share across all our apps. Then, we will simply import the shared 3 policies into our next apps.
EX:
This PR allows you to pass those policies into the construct so it will not make another 3 unique ones so you should be able to have as many next.js apps as you want in one account using this method!