cdk-nextjs 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +2404 -2723
- package/.jsii.tabl.json +1 -1
- package/API.md +1681 -1930
- package/CLAUDE.md +2 -1
- package/README.md +429 -130
- package/assets/lambdas/post-deploy/post-deploy.lambda/index.js +148 -169
- package/assets/lambdas/redeploy-stage/redeploy-stage.lambda/index.js +875 -0
- package/docs/adapter-runtime.md +185 -0
- package/docs/breaking-changes.md +667 -4
- package/docs/caching-guide.md +156 -112
- package/docs/cdk-nextjs-cfn-exec-policy.json +2 -1
- package/docs/development-guide.md +1 -1
- package/docs/harness-coverage.md +598 -0
- package/docs/init-cache-deployment.md +32 -1
- package/docs/next-build-output-guide.md +30 -20
- package/examples/README.md +5 -1
- package/lib/adapter/__fixtures__/app-playground-base-path.json +4926 -0
- package/lib/adapter/__fixtures__/app-playground.json +4917 -0
- package/lib/adapter/__fixtures__/pages-i18n.json +1728 -0
- package/lib/adapter/adapter.mjs +1548 -185
- package/lib/adapter/adapter.test.js +106 -0
- package/lib/adapter/aws-cache-store.d.ts +489 -0
- package/lib/adapter/aws-cache-store.js +1004 -0
- package/lib/adapter/aws-cache-store.test.d.ts +1 -0
- package/lib/adapter/aws-cache-store.test.js +361 -0
- package/lib/adapter/build-outputs.d.ts +80 -0
- package/lib/adapter/build-outputs.js +852 -0
- package/lib/adapter/build-outputs.test.d.ts +1 -0
- package/lib/adapter/build-outputs.test.js +861 -0
- package/lib/adapter/cache-handler.d.ts +9 -2
- package/lib/adapter/cache-handler.js +72 -96
- package/lib/adapter/cache-handler.mjs +18956 -17774
- package/lib/adapter/cache-handler.test.js +263 -31
- package/lib/adapter/cache-kinds.d.ts +32 -0
- package/lib/adapter/cache-kinds.js +35 -0
- package/lib/adapter/cache-kinds.test.d.ts +1 -0
- package/lib/adapter/cache-kinds.test.js +69 -0
- package/lib/adapter/cache-utils.d.ts +90 -0
- package/lib/adapter/cache-utils.js +199 -4
- package/lib/adapter/cache-utils.test.d.ts +1 -0
- package/lib/adapter/cache-utils.test.js +179 -0
- package/lib/adapter/function-groups.d.ts +215 -0
- package/lib/adapter/function-groups.js +1099 -0
- package/lib/adapter/function-groups.test.d.ts +1 -0
- package/lib/adapter/function-groups.test.js +743 -0
- package/lib/adapter/init-cache.d.ts +6 -0
- package/lib/adapter/init-cache.js +245 -0
- package/lib/adapter/init-cache.test.d.ts +1 -0
- package/lib/adapter/init-cache.test.js +137 -0
- package/lib/adapter/local-file-cache-handler.d.ts +23 -0
- package/lib/adapter/local-file-cache-handler.js +52 -1
- package/lib/adapter/memory-cache-handler.d.ts +26 -17
- package/lib/adapter/memory-cache-handler.js +32 -50
- package/lib/adapter/memory-cache-handler.test.js +105 -85
- package/lib/adapter/s3-cache-handler.d.ts +179 -40
- package/lib/adapter/s3-cache-handler.js +807 -277
- package/lib/adapter/s3-cache-handler.test.js +1186 -31
- package/lib/adapter/use-cache-common.d.ts +90 -0
- package/lib/adapter/use-cache-common.js +250 -0
- package/lib/adapter/use-cache-common.test.d.ts +1 -0
- package/lib/adapter/use-cache-common.test.js +646 -0
- package/lib/adapter/use-cache-default-handler.d.ts +24 -0
- package/lib/adapter/use-cache-default-handler.js +90 -0
- package/lib/adapter/use-cache-default-handler.mjs +38645 -0
- package/lib/adapter/use-cache-handlers.test.d.ts +1 -0
- package/lib/adapter/use-cache-handlers.test.js +349 -0
- package/lib/adapter/use-cache-remote-handler.d.ts +26 -0
- package/lib/adapter/use-cache-remote-handler.js +186 -0
- package/lib/{image-optimization/handler.mjs → adapter/use-cache-remote-handler.mjs} +33572 -38798
- package/lib/generated-structs/OptionalNextjsApiProps.d.ts +59 -0
- package/lib/generated-structs/OptionalNextjsApiProps.js +3 -0
- package/lib/generated-structs/OptionalNextjsCacheProps.d.ts +15 -6
- package/lib/generated-structs/OptionalNextjsCacheProps.js +1 -1
- package/lib/generated-structs/OptionalNextjsContainersProps.d.ts +25 -11
- package/lib/generated-structs/OptionalNextjsContainersProps.js +1 -1
- package/lib/generated-structs/OptionalNextjsDistributionProps.d.ts +31 -9
- package/lib/generated-structs/OptionalNextjsDistributionProps.js +1 -1
- package/lib/generated-structs/OptionalNextjsPostDeployProps.d.ts +8 -0
- package/lib/generated-structs/OptionalNextjsPostDeployProps.js +1 -1
- package/lib/generated-structs/OptionalPostDeployCustomResourceProperties.d.ts +6 -4
- package/lib/generated-structs/OptionalPostDeployCustomResourceProperties.js +1 -1
- package/lib/index.d.ts +6 -7
- package/lib/index.js +2 -4
- package/lib/lambdas/post-deploy/prune-cache-bucket.d.ts +7 -3
- package/lib/lambdas/post-deploy/prune-cache-bucket.js +57 -71
- package/lib/lambdas/post-deploy/prune-cache-bucket.test.d.ts +1 -0
- package/lib/lambdas/post-deploy/prune-cache-bucket.test.js +114 -0
- package/lib/lambdas/post-deploy/prune-revalidation-table.d.ts +1 -0
- package/lib/lambdas/post-deploy/prune-revalidation-table.js +23 -31
- package/lib/lambdas/post-deploy/prune-revalidation-table.test.d.ts +1 -0
- package/lib/lambdas/post-deploy/prune-revalidation-table.test.js +71 -0
- package/lib/lambdas/post-deploy/prune-s3.d.ts +14 -5
- package/lib/lambdas/post-deploy/prune-s3.js +41 -12
- package/lib/lambdas/post-deploy/prune-s3.test.js +97 -18
- package/lib/lambdas/redeploy-stage/redeploy-stage-function.d.ts +13 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage-function.js +55 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.d.ts +24 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.js +68 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.lambda.d.ts +20 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.lambda.js +24 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.test.d.ts +1 -0
- package/lib/lambdas/redeploy-stage/redeploy-stage.test.js +93 -0
- package/lib/nextjs-api.d.ts +102 -18
- package/lib/nextjs-api.js +338 -38
- package/lib/nextjs-api.test.js +537 -1
- package/lib/nextjs-build/global-containers.Dockerfile +15 -10
- package/lib/nextjs-build/nextjs-build.d.ts +339 -63
- package/lib/nextjs-build/nextjs-build.js +684 -327
- package/lib/nextjs-build/nextjs-build.test.d.ts +1 -0
- package/lib/nextjs-build/nextjs-build.test.js +412 -0
- package/lib/nextjs-build/patch-fetch.js +1 -1
- package/lib/nextjs-build/patch-fetch.test.js +166 -11
- package/lib/nextjs-build/regional-containers.Dockerfile +17 -10
- package/lib/nextjs-cache.d.ts +82 -4
- package/lib/nextjs-cache.js +186 -10
- package/lib/nextjs-cache.test.js +176 -1
- package/lib/nextjs-compute/nextjs-compute-base-props.d.ts +21 -8
- package/lib/nextjs-compute/nextjs-compute-base-props.js +41 -1
- package/lib/nextjs-compute/nextjs-compute-base-props.test.d.ts +1 -0
- package/lib/nextjs-compute/nextjs-compute-base-props.test.js +44 -0
- package/lib/nextjs-compute/nextjs-containers.d.ts +19 -0
- package/lib/nextjs-compute/nextjs-containers.js +57 -20
- package/lib/nextjs-compute/nextjs-functions.d.ts +122 -7
- package/lib/nextjs-compute/nextjs-functions.js +113 -67
- package/lib/nextjs-compute/nextjs-functions.test.d.ts +1 -0
- package/lib/nextjs-compute/nextjs-functions.test.js +99 -0
- package/lib/nextjs-distribution.d.ts +194 -23
- package/lib/nextjs-distribution.js +535 -62
- package/lib/nextjs-distribution.test.d.ts +1 -0
- package/lib/nextjs-distribution.test.js +697 -0
- package/lib/nextjs-post-deploy.d.ts +13 -5
- package/lib/nextjs-post-deploy.js +13 -10
- package/lib/nextjs-post-deploy.test.d.ts +1 -0
- package/lib/nextjs-post-deploy.test.js +34 -0
- package/lib/nextjs-static-assets.d.ts +17 -4
- package/lib/nextjs-static-assets.js +22 -5
- package/lib/root-constructs/nextjs-base-construct.d.ts +102 -58
- package/lib/root-constructs/nextjs-base-construct.js +139 -47
- package/lib/root-constructs/nextjs-global-containers.d.ts +18 -20
- package/lib/root-constructs/nextjs-global-containers.js +20 -71
- package/lib/root-constructs/nextjs-global-functions.d.ts +26 -28
- package/lib/root-constructs/nextjs-global-functions.js +52 -70
- package/lib/root-constructs/nextjs-regional-containers.d.ts +18 -5
- package/lib/root-constructs/nextjs-regional-containers.js +8 -15
- package/lib/root-constructs/nextjs-regional-functions.d.ts +22 -18
- package/lib/root-constructs/nextjs-regional-functions.js +8 -26
- package/lib/runtime/api-gateway-path.d.ts +34 -0
- package/lib/runtime/api-gateway-path.js +71 -0
- package/lib/runtime/api-gateway-path.test.d.ts +1 -0
- package/lib/runtime/api-gateway-path.test.js +65 -0
- package/lib/runtime/case-redirect.d.ts +22 -0
- package/lib/runtime/case-redirect.js +63 -0
- package/lib/runtime/case-redirect.test.d.ts +1 -0
- package/lib/runtime/case-redirect.test.js +32 -0
- package/lib/runtime/core.d.ts +234 -0
- package/lib/runtime/core.js +1213 -0
- package/lib/runtime/core.test.d.ts +1 -0
- package/lib/runtime/core.test.js +1678 -0
- package/lib/runtime/deployment-root.d.ts +13 -0
- package/lib/runtime/deployment-root.js +29 -0
- package/lib/runtime/dispatch.d.ts +331 -0
- package/lib/runtime/dispatch.js +751 -0
- package/lib/runtime/dispatch.test.d.ts +1 -0
- package/lib/runtime/dispatch.test.js +853 -0
- package/lib/runtime/entrypoints.d.ts +57 -0
- package/lib/runtime/entrypoints.js +115 -0
- package/lib/runtime/http/abort-signal.d.ts +6 -0
- package/lib/runtime/http/abort-signal.js +19 -0
- package/lib/runtime/http/abort-signal.test.d.ts +1 -0
- package/lib/runtime/http/abort-signal.test.js +49 -0
- package/lib/runtime/http/node-server.d.ts +38 -0
- package/lib/runtime/http/node-server.js +99 -0
- package/lib/runtime/http/node-server.test.d.ts +1 -0
- package/lib/runtime/http/node-server.test.js +96 -0
- package/lib/runtime/http/node-sink.d.ts +16 -0
- package/lib/runtime/http/node-sink.js +48 -0
- package/lib/runtime/http/node-sink.test.d.ts +1 -0
- package/lib/runtime/http/node-sink.test.js +66 -0
- package/lib/runtime/http/request.d.ts +62 -0
- package/lib/runtime/http/request.js +134 -0
- package/lib/runtime/http/request.test.d.ts +1 -0
- package/lib/runtime/http/request.test.js +103 -0
- package/lib/runtime/http/response.d.ts +77 -0
- package/lib/runtime/http/response.js +229 -0
- package/lib/runtime/http/response.test.d.ts +1 -0
- package/lib/runtime/http/response.test.js +178 -0
- package/lib/runtime/http/sink.d.ts +73 -0
- package/lib/runtime/http/sink.js +188 -0
- package/lib/runtime/http/sink.test.d.ts +1 -0
- package/lib/runtime/http/sink.test.js +257 -0
- package/lib/runtime/image-utils.d.ts +78 -0
- package/lib/runtime/image-utils.js +129 -0
- package/lib/runtime/image-utils.test.d.ts +1 -0
- package/lib/runtime/image-utils.test.js +237 -0
- package/lib/runtime/image.d.ts +76 -0
- package/lib/runtime/image.js +296 -0
- package/lib/runtime/image.test.d.ts +1 -0
- package/lib/runtime/image.test.js +405 -0
- package/lib/runtime/lambda-event.d.ts +4 -0
- package/lib/runtime/lambda-event.js +113 -0
- package/lib/runtime/lambda-event.test.d.ts +1 -0
- package/lib/runtime/lambda-event.test.js +119 -0
- package/lib/runtime/lambda.mjs +41595 -0
- package/lib/runtime/load-module.d.ts +8 -0
- package/lib/runtime/load-module.js +35 -0
- package/lib/runtime/manifest.d.ts +215 -0
- package/lib/runtime/manifest.js +118 -0
- package/lib/runtime/middleware.d.ts +43 -0
- package/lib/runtime/middleware.js +113 -0
- package/lib/runtime/middleware.test.d.ts +1 -0
- package/lib/runtime/middleware.test.js +259 -0
- package/lib/runtime/next-modules.d.ts +55 -0
- package/lib/runtime/next-modules.js +124 -0
- package/lib/runtime/next-modules.test.d.ts +1 -0
- package/lib/runtime/next-modules.test.js +34 -0
- package/lib/runtime/public-files.d.ts +32 -0
- package/lib/runtime/public-files.js +117 -0
- package/lib/runtime/public-files.test.d.ts +1 -0
- package/lib/runtime/public-files.test.js +97 -0
- package/lib/runtime/server.mjs +41588 -0
- package/lib/runtime/static-files.d.ts +50 -0
- package/lib/runtime/static-files.js +266 -0
- package/lib/runtime/static-files.test.d.ts +1 -0
- package/lib/runtime/static-files.test.js +118 -0
- package/lib/runtime/util.d.ts +28 -0
- package/lib/runtime/util.js +79 -0
- package/lib/utils/base-path.d.ts +106 -13
- package/lib/utils/base-path.js +254 -41
- package/lib/utils/base-path.test.js +219 -51
- package/lib/utils/get-architecture.d.ts +7 -8
- package/lib/utils/get-architecture.js +12 -13
- package/lib/utils/zip-directory.d.ts +14 -0
- package/lib/utils/zip-directory.js +121 -0
- package/lib/utils/zip-directory.test.d.ts +1 -0
- package/lib/utils/zip-directory.test.js +99 -0
- package/package.json +22 -3
- package/scripts/capture-adapter-fixture.mjs +325 -0
- package/scripts/e2e-deploy.sh +398 -0
- package/scripts/e2e-harness/README.md +707 -0
- package/scripts/e2e-harness/app.js +370 -0
- package/scripts/e2e-harness/common.sh +249 -0
- package/scripts/e2e-harness/screen.mjs +302 -0
- package/scripts/e2e-harness/stage-proxy.mjs +145 -0
- package/scripts/e2e-harness/type-filters.mjs +47 -0
- package/scripts/e2e-logs.sh +75 -0
- package/scripts/e2e-offline.sh +91 -0
- package/scripts/e2e-sweep.sh +370 -0
- package/scripts/e2e-warm.sh +114 -0
- package/scripts/zero-config-build.mjs +418 -0
- package/docs/1k-concurrent-users-executions.png +0 -0
- package/docs/plans/adapter-runtime-release.md +0 -362
- package/docs/plans/phase-0-image-function-opt-in.md +0 -295
- package/lib/generated-structs/OptionalDockerImageFunctionProps.d.ts +0 -425
- package/lib/generated-structs/OptionalDockerImageFunctionProps.js +0 -3
- package/lib/image-optimization/handler-utils.d.ts +0 -34
- package/lib/image-optimization/handler-utils.js +0 -83
- package/lib/image-optimization/handler-utils.test.js +0 -178
- package/lib/nextjs-build/functions.Dockerfile +0 -31
- package/lib/nextjs-compute/nextjs-image-function.d.ts +0 -53
- package/lib/nextjs-compute/nextjs-image-function.js +0 -59
- package/lib/utils/experimental-flags.d.ts +0 -24
- package/lib/utils/experimental-flags.js +0 -30
- /package/lib/{image-optimization/handler-utils.test.d.ts → adapter/adapter.test.d.ts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IDistribution } from "aws-cdk-lib/aws-cloudfront";
|
|
1
2
|
import { ITableV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
2
3
|
import { IVpc } from "aws-cdk-lib/aws-ec2";
|
|
3
4
|
import { IBucket } from "aws-cdk-lib/aws-s3";
|
|
@@ -5,11 +6,12 @@ import { Construct } from "constructs";
|
|
|
5
6
|
import { NextjsType } from "../constants";
|
|
6
7
|
import { OptionalNextjsBuildProps } from "../generated-structs/OptionalNextjsBuildProps";
|
|
7
8
|
import { OptionalNextjsCacheProps } from "../generated-structs/OptionalNextjsCacheProps";
|
|
9
|
+
import { OptionalNextjsPostDeployProps } from "../generated-structs/OptionalNextjsPostDeployProps";
|
|
8
10
|
import { NextjsBuild } from "../nextjs-build/nextjs-build";
|
|
9
11
|
import { NextjsCache, NextjsCacheOverrides } from "../nextjs-cache";
|
|
10
12
|
import { NextjsComputeBaseProps } from "../nextjs-compute/nextjs-compute-base-props";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
+
import { NextjsFunctionGroup, NextjsFunctions } from "../nextjs-compute/nextjs-functions";
|
|
14
|
+
import { NextjsPostDeploy, NextjsPostDeployOverrides } from "../nextjs-post-deploy";
|
|
13
15
|
import { NextjsStaticAssets, NextjsStaticAssetsOverrides, NextjsStaticAssetsProps } from "../nextjs-static-assets";
|
|
14
16
|
/**
|
|
15
17
|
* Base overrides for the props passed to constructs within root/top-level Next.js constructs
|
|
@@ -17,22 +19,15 @@ import { NextjsStaticAssets, NextjsStaticAssetsOverrides, NextjsStaticAssetsProp
|
|
|
17
19
|
export interface NextjsBaseConstructOverrides {
|
|
18
20
|
readonly nextjsBuildProps?: OptionalNextjsBuildProps;
|
|
19
21
|
readonly nextjsCacheProps?: OptionalNextjsCacheProps;
|
|
22
|
+
readonly nextjsPostDeployProps?: OptionalNextjsPostDeployProps;
|
|
20
23
|
readonly nextjsStaticAssetsProps?: NextjsStaticAssetsProps;
|
|
21
24
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Adds the overrides that only apply to the two Functions `NextjsType`s. The
|
|
24
|
-
* Containers types serve `_next/image` from the standalone server itself and
|
|
25
|
-
* have no Lambda functions to configure, so they would silently ignore these.
|
|
26
|
-
*/
|
|
27
|
-
export interface NextjsFunctionsConstructOverrides extends NextjsBaseConstructOverrides {
|
|
28
|
-
readonly nextjsFunctionsProps?: NextjsFunctionsProps;
|
|
29
|
-
readonly nextjsImageFunctionProps?: NextjsImageFunctionProps;
|
|
30
|
-
}
|
|
31
25
|
/**
|
|
32
26
|
* Base overrides for constructs shared between all root/top-level Next.js constructs.
|
|
33
27
|
*/
|
|
34
28
|
export interface NextjsBaseOverrides {
|
|
35
29
|
readonly nextjsCache?: NextjsCacheOverrides;
|
|
30
|
+
readonly nextjsPostDeploy?: NextjsPostDeployOverrides;
|
|
36
31
|
readonly nextjsStaticAssets?: NextjsStaticAssetsOverrides;
|
|
37
32
|
}
|
|
38
33
|
export interface NextjsBaseProps {
|
|
@@ -50,12 +45,18 @@ export interface NextjsBaseProps {
|
|
|
50
45
|
* static assets from S3 using the request path as the object key, so the two
|
|
51
46
|
* have to be identical and a mismatch 404s all of them. Setting a different
|
|
52
47
|
* value throws.
|
|
53
|
-
* - `NextjsRegionalFunctions`:
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
48
|
+
* - `NextjsRegionalFunctions`: leave this unset and it follows your app's
|
|
49
|
+
* `basePath` minus the prefix API Gateway strips before matching resources —
|
|
50
|
+
* the stage (`deployOptions.stageName`, default `prod`), or the base path
|
|
51
|
+
* mapping of a custom domain set in `restApiProps.domainName`. So
|
|
52
|
+
* `basePath: "/prod"` mounts at the root, `"/prod/base"` under `base`, and
|
|
53
|
+
* `"/docs"` behind a custom domain mapped at the root under `docs`. On the
|
|
54
|
+
* execute-api endpoint an app `basePath` that doesn't start with the stage
|
|
55
|
+
* warns, since its links will miss the stage. If you set this, the app's
|
|
56
|
+
* `basePath` must end with it. A domain attached later with
|
|
57
|
+
* `addDomainName()` is not seen at synth; set this explicitly then — to
|
|
58
|
+
* `"/"` when that domain's base path mapping strips your app's whole
|
|
59
|
+
* `basePath`, which mounts every resource at the root.
|
|
59
60
|
* - `NextjsRegionalContainers`: only namespaces the S3 bucket. The ALB sends
|
|
60
61
|
* every path to the container, which serves its own static assets, so this
|
|
61
62
|
* is unconstrained.
|
|
@@ -76,28 +77,26 @@ export interface NextjsBaseProps {
|
|
|
76
77
|
readonly buildDirectory: string;
|
|
77
78
|
/**
|
|
78
79
|
* Bring your own S3 bucket for cache storage. When provided, cdk-nextjs
|
|
79
|
-
* will use this bucket instead of creating a new one.
|
|
80
|
-
* prefixed with `buildId` so multiple deployments can safely share one bucket.
|
|
81
|
-
*/
|
|
82
|
-
readonly cacheBucket?: IBucket;
|
|
83
|
-
/**
|
|
84
|
-
* Path to API Route Handler that returns HTTP 200 to ensure compute health.
|
|
85
|
-
* @example "/api/health"
|
|
86
|
-
* @example
|
|
87
|
-
* // api/health/route.ts
|
|
88
|
-
* import { NextResponse } from "next/server";
|
|
80
|
+
* will use this bucket instead of creating a new one.
|
|
89
81
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
82
|
+
* The bucket must be dedicated to this one deployment. Don't share it with
|
|
83
|
+
* another deployment (another branch, stage, or app): every deploy's
|
|
84
|
+
* post-deploy step deletes every object under a top-level prefix other than
|
|
85
|
+
* the current `buildId/`, which includes every other deployment's cache.
|
|
93
86
|
*/
|
|
94
|
-
readonly
|
|
87
|
+
readonly cacheBucket?: IBucket;
|
|
95
88
|
/**
|
|
96
89
|
* Bring your own DynamoDB table for revalidation metadata. When provided,
|
|
97
90
|
* cdk-nextjs will use this table instead of creating a new one. The table
|
|
98
91
|
* must have `pk` (String) as partition key and `sk` (String) as sort key.
|
|
99
|
-
*
|
|
100
|
-
*
|
|
92
|
+
* Enable TTL on its `ttl` attribute too: each tag revalidation writes a
|
|
93
|
+
* revalidation log row that expires through it, and without TTL those rows
|
|
94
|
+
* accumulate.
|
|
95
|
+
*
|
|
96
|
+
* The table must be dedicated to this one deployment. Don't share it with
|
|
97
|
+
* another deployment (another branch, stage, or app): every deploy's
|
|
98
|
+
* post-deploy step deletes the entries of the build it last recorded in the
|
|
99
|
+
* table, which with a shared table is another deployment's live build.
|
|
101
100
|
*/
|
|
102
101
|
readonly revalidationTable?: ITableV2;
|
|
103
102
|
/**
|
|
@@ -109,7 +108,13 @@ export interface NextjsBaseProps {
|
|
|
109
108
|
/**
|
|
110
109
|
* Bring your own S3 bucket for static assets. When provided, cdk-nextjs
|
|
111
110
|
* will deploy static assets to this bucket instead of creating a new one.
|
|
112
|
-
*
|
|
111
|
+
*
|
|
112
|
+
* Unlike `cacheBucket`, this one can be shared, but only between deployments
|
|
113
|
+
* with different `basePath`s (so different S3 key prefixes). Pruning only
|
|
114
|
+
* touches `<basePath>/_next/`, so it leaves the others' assets alone. Two
|
|
115
|
+
* deployments under the same prefix overwrite each other's `public/` files
|
|
116
|
+
* and prune each other's `_next/` assets once they are past the prune
|
|
117
|
+
* TTL (30 days by default).
|
|
113
118
|
*/
|
|
114
119
|
readonly staticAssetsBucket?: IBucket;
|
|
115
120
|
/**
|
|
@@ -138,7 +143,7 @@ export declare abstract class NextjsBaseConstruct extends Construct {
|
|
|
138
143
|
abstract get url(): string;
|
|
139
144
|
protected readonly nextjsType: NextjsType;
|
|
140
145
|
protected readonly baseProps: NextjsBaseConstructProps;
|
|
141
|
-
protected readonly constructOverrides?:
|
|
146
|
+
protected readonly constructOverrides?: NextjsBaseConstructOverrides;
|
|
142
147
|
/**
|
|
143
148
|
* The `basePath` everything downstream is built from: the `basePath` prop when
|
|
144
149
|
* set, otherwise the app's own `basePath` for the `NextjsType`s where the two
|
|
@@ -147,52 +152,91 @@ export declare abstract class NextjsBaseConstruct extends Construct {
|
|
|
147
152
|
*/
|
|
148
153
|
protected readonly resolvedBasePath?: string;
|
|
149
154
|
constructor(scope: Construct, id: string, props: NextjsBaseConstructProps, nextjsType: NextjsType);
|
|
155
|
+
/**
|
|
156
|
+
* Warns when a path-style `assetPrefix` would 404 every bundle on this
|
|
157
|
+
* `NextjsType` — see {@link isAssetPrefixUnserved} for which combinations those
|
|
158
|
+
* are and why a prefix equal to the app's `basePath` is not one of them.
|
|
159
|
+
*
|
|
160
|
+
* Warn rather than throw: it is the app's config, the deployment otherwise
|
|
161
|
+
* works, and an absolute `assetPrefix` (already reduced to `""` by
|
|
162
|
+
* `relativeAssetPrefix`) is the supported way to serve assets from
|
|
163
|
+
* elsewhere.
|
|
164
|
+
*/
|
|
165
|
+
private warnUnservedAssetPrefix;
|
|
150
166
|
/**
|
|
151
167
|
* For the Global `NextjsType`s the key prefix isn't a free choice: it has to be
|
|
152
168
|
* `basePath` (see `resolveBasePath`). A `destinationKeyPrefix` override that
|
|
153
169
|
* moves the objects elsewhere has no way to tell the distribution about it —
|
|
154
|
-
* unlike the image
|
|
170
|
+
* unlike the functions' image optimizer and `NextjsApi`, which read
|
|
155
171
|
* `NextjsStaticAssets.keyPrefix` — so fail at synth rather than 404 every
|
|
156
172
|
* static request.
|
|
157
173
|
*/
|
|
158
174
|
private validateStaticAssetsKeyPrefix;
|
|
175
|
+
/**
|
|
176
|
+
* The prefix API Gateway will strip, read from the same `restApiProps`
|
|
177
|
+
* override `NextjsApi` builds its `RestApi` from. Only meaningful for
|
|
178
|
+
* `REGIONAL_FUNCTIONS`, and read before `NextjsApi` exists because the
|
|
179
|
+
* resolved `basePath` also decides the static assets' S3 key prefix.
|
|
180
|
+
*
|
|
181
|
+
* A domain attached later with `api.addDomainName()` is invisible here, the
|
|
182
|
+
* same limitation `NextjsApi.url` documents.
|
|
183
|
+
*/
|
|
184
|
+
private apiGatewayPrefix;
|
|
159
185
|
/**
|
|
160
186
|
* Finds construct overrides (if present) on props for any `NextjsType`
|
|
161
187
|
*/
|
|
162
188
|
private getConstructOverrides;
|
|
189
|
+
/**
|
|
190
|
+
* `overrides.nextjsFunctions`, which only the two Functions root constructs
|
|
191
|
+
* declare. Cast for the same reason as {@link functionGroups}.
|
|
192
|
+
*/
|
|
193
|
+
private get functionsOverrides();
|
|
194
|
+
/**
|
|
195
|
+
* `functionGroups`, which only the two Functions root constructs accept —
|
|
196
|
+
* Containers deploy one task definition and have no 250 MB package limit to
|
|
197
|
+
* split around.
|
|
198
|
+
*
|
|
199
|
+
* Read off `baseProps` with a cast for the same reason as
|
|
200
|
+
* {@link getConstructOverrides}: `createNextjsBuild` and
|
|
201
|
+
* `createNextjsFunctions` are shared here, but the prop is declared on the
|
|
202
|
+
* subclasses, so nothing weaker than a cast can see it. Adding it to
|
|
203
|
+
* `NextjsBaseProps` would offer it to Containers, where it does nothing.
|
|
204
|
+
*/
|
|
205
|
+
protected get functionGroups(): NextjsFunctionGroup[] | undefined;
|
|
163
206
|
/**
|
|
164
207
|
* The health check path as the running app actually serves it.
|
|
165
208
|
*
|
|
166
|
-
*
|
|
167
|
-
* the path to the container unchanged, and the
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
|
|
178
|
-
|
|
209
|
+
* Both consumers of this hit the app directly — the ALB target group forwards
|
|
210
|
+
* the path to the container unchanged, and the container's `wget` probe targets
|
|
211
|
+
* the local server — so the prefix that matters is the app's own `basePath`,
|
|
212
|
+
* not `resolvedBasePath` (which for `REGIONAL_CONTAINERS` is only an S3
|
|
213
|
+
* namespace). Left unprefixed, an app with a `basePath` 404s every health
|
|
214
|
+
* check, so the target never turns healthy and the deployment rolls back.
|
|
215
|
+
* `healthCheckPath` is therefore the path as the app routes it, without
|
|
216
|
+
* `basePath`; one that carries the prefix already gets it twice, which is the
|
|
217
|
+
* 0.6.2 breaking change for anyone who prefixed by hand to work around this.
|
|
218
|
+
*
|
|
219
|
+
* Takes the path as an argument rather than reading it off `baseProps`: only
|
|
220
|
+
* the two Containers root constructs declare `healthCheckPath`, since they're
|
|
221
|
+
* the only ones with something to health-check.
|
|
222
|
+
*/
|
|
223
|
+
protected resolvedHealthCheckPath(healthCheckPath: string): string;
|
|
179
224
|
/**
|
|
180
225
|
* Get compute base props for both Lambda functions and containers
|
|
181
226
|
*/
|
|
182
227
|
protected computeBaseProps(): NextjsComputeBaseProps;
|
|
228
|
+
/**
|
|
229
|
+
* Runs after the init cache upload: invalidating the CDN before the new
|
|
230
|
+
* cache is in place would only re-cache the responses the invalidation was
|
|
231
|
+
* meant to drop, and CloudFormation infers no ordering between the two
|
|
232
|
+
* custom resources on its own.
|
|
233
|
+
*/
|
|
234
|
+
protected createNextjsPostDeploy(distribution?: IDistribution): NextjsPostDeploy;
|
|
183
235
|
private createNextjsBuild;
|
|
184
236
|
private createNextjsCache;
|
|
185
237
|
private createNextjsStaticAssets;
|
|
186
238
|
/**
|
|
187
239
|
* Shared by `NextjsGlobalFunctions` and `NextjsRegionalFunctions`.
|
|
188
240
|
*/
|
|
189
|
-
protected createNextjsFunctions(
|
|
190
|
-
/**
|
|
191
|
-
* Shared by `NextjsGlobalFunctions` and `NextjsRegionalFunctions`, the only
|
|
192
|
-
* two `NextjsType`s for which `NextjsBuild` produces an image optimization
|
|
193
|
-
* asset. Only called when the dedicated image optimization Lambda is
|
|
194
|
-
* enabled, which is what makes the missing-asset check below an invariant
|
|
195
|
-
* violation rather than a supported configuration.
|
|
196
|
-
*/
|
|
197
|
-
protected createNextjsImageFunction(overrides?: NextjsImageFunctionOverrides): NextjsImageFunction;
|
|
241
|
+
protected createNextjsFunctions(): NextjsFunctions;
|
|
198
242
|
}
|