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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nextjs-cdk-construct): Allow cache policies to be provided as props #2350

Merged
merged 1 commit into from Feb 18, 2022

Conversation

jadenv
Copy link
Contributor

@jadenv jadenv commented Feb 16, 2022

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:

nextStaticsCachePolicy: CachePolicy.fromCachePolicyId(
      scope,
      'NextImageCache',
      'unique-cache-policy-id-here'
    )

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!

@slsnextbot
Copy link
Collaborator

Handler Size Report

No changes to handler sizes.

Base Handler Sizes (kB) (commit ecb03a6)

{
    "Lambda": {
        "Default Lambda": {
            "Standard": 1524,
            "Minified": 668
        },
        "Image Lambda": {
            "Standard": 1488,
            "Minified": 800
        }
    },
    "Lambda@Edge": {
        "Default Lambda": {
            "Standard": 1534,
            "Minified": 673
        },
        "Default Lambda V2": {
            "Standard": 1526,
            "Minified": 670
        },
        "API Lambda": {
            "Standard": 634,
            "Minified": 318
        },
        "Image Lambda": {
            "Standard": 1496,
            "Minified": 805
        },
        "Regeneration Lambda": {
            "Standard": 1187,
            "Minified": 546
        },
        "Regeneration Lambda V2": {
            "Standard": 1253,
            "Minified": 573
        }
    }
}

New Handler Sizes (kB) (commit 000d0ef)

{
    "Lambda": {
        "Default Lambda": {
            "Standard": 1524,
            "Minified": 668
        },
        "Image Lambda": {
            "Standard": 1488,
            "Minified": 800
        }
    },
    "Lambda@Edge": {
        "Default Lambda": {
            "Standard": 1534,
            "Minified": 673
        },
        "Default Lambda V2": {
            "Standard": 1526,
            "Minified": 670
        },
        "API Lambda": {
            "Standard": 634,
            "Minified": 318
        },
        "Image Lambda": {
            "Standard": 1496,
            "Minified": 805
        },
        "Regeneration Lambda": {
            "Standard": 1187,
            "Minified": 546
        },
        "Regeneration Lambda V2": {
            "Standard": 1253,
            "Minified": 573
        }
    }
}

@codecov
Copy link

codecov bot commented Feb 16, 2022

Codecov Report

Merging #2350 (000d0ef) into master (ecb03a6) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2350      +/-   ##
==========================================
+ Coverage   83.55%   83.58%   +0.02%     
==========================================
  Files         102      102              
  Lines        3679     3685       +6     
  Branches     1176     1182       +6     
==========================================
+ Hits         3074     3080       +6     
  Misses        593      593              
  Partials       12       12              
Impacted Files Coverage 螖
...rless-components/nextjs-cdk-construct/src/index.ts 93.91% <100.00%> (+0.33%) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update ecb03a6...000d0ef. Read the comment docs.

@dphang dphang merged commit 68b7717 into serverless-nextjs:master Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants