canopycms-cdk 0.6.0 → 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/README.md +1 -1
- package/dist/constructs/cms-distribution.d.ts +1 -1
- package/dist/constructs/cms-service.d.ts +5 -5
- package/dist/constructs/cms-service.js +4 -4
- package/dist/constructs/editor-routing.d.ts +13 -4
- package/dist/constructs/editor-routing.js +22 -11
- package/package.json +4 -4
- package/worker/dist/index.js +949 -493
- package/worker/dist/index.js.sha256 +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ What changed in each release, for all five CanopyCMS packages, is in `node_modul
|
|
|
22
22
|
**`CanopyCmsDistribution`** — CloudFront + DNS (optional):
|
|
23
23
|
|
|
24
24
|
- ACM certificate with DNS validation
|
|
25
|
-
- CloudFront distribution with Lambda Function URL origin
|
|
25
|
+
- CloudFront distribution with Lambda Function URL origin; its read timeout follows the Lambda's (60 s by default, at most 120 s, CloudFront's default quota)
|
|
26
26
|
- Route53 A/AAAA alias records
|
|
27
27
|
- Cache policies: no-cache for API/editor, long-cache for static assets
|
|
28
28
|
- Response headers: framing protection (`frame-ancestors 'self'`), `nosniff`, HSTS, `X-Robots-Tag: noindex`
|
|
@@ -26,7 +26,7 @@ export interface CanopyCmsDistributionProps {
|
|
|
26
26
|
* First-touch branch provisioning does a full `git clone` onto EFS inside the
|
|
27
27
|
* request, so this is a real path.
|
|
28
28
|
*
|
|
29
|
-
* Capped at
|
|
29
|
+
* Capped at 120s (`MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT`), CloudFront's default quota.
|
|
30
30
|
*/
|
|
31
31
|
originReadTimeout?: Duration;
|
|
32
32
|
/**
|
|
@@ -25,10 +25,10 @@ export declare function withoutShellComments(...lines: string[]): string[];
|
|
|
25
25
|
* One constant rather than two matching literals, so the pair cannot drift;
|
|
26
26
|
* `cms-deploy.test.ts` asserts the emitted template keeps them equal.
|
|
27
27
|
*
|
|
28
|
-
* NOTE:
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* NOTE: the Lambda timeout may not exceed `MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT`
|
|
29
|
+
* (120s, CloudFront's default origin response timeout quota):
|
|
30
|
+
* `CanopyCmsDistribution` and `attachTo` fail at synth rather than deploying a
|
|
31
|
+
* configuration that would 504.
|
|
32
32
|
*/
|
|
33
33
|
export declare const DEFAULT_CMS_LAMBDA_TIMEOUT: Duration;
|
|
34
34
|
/**
|
|
@@ -47,7 +47,7 @@ export interface CanopyCmsServiceProps {
|
|
|
47
47
|
vpc?: ec2.IVpc;
|
|
48
48
|
/** Lambda memory in MB (default: 2048) */
|
|
49
49
|
memorySize?: number;
|
|
50
|
-
/** Lambda timeout (default: 60 seconds) */
|
|
50
|
+
/** Lambda timeout (default: 60 seconds; at most 120 seconds, see {@link DEFAULT_CMS_LAMBDA_TIMEOUT}) */
|
|
51
51
|
timeout?: Duration;
|
|
52
52
|
/**
|
|
53
53
|
* Cap on the CMS Lambda's concurrent invocations (default: 50).
|
|
@@ -577,10 +577,10 @@ function assertGitHubAuthProps(props) {
|
|
|
577
577
|
* One constant rather than two matching literals, so the pair cannot drift;
|
|
578
578
|
* `cms-deploy.test.ts` asserts the emitted template keeps them equal.
|
|
579
579
|
*
|
|
580
|
-
* NOTE:
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
580
|
+
* NOTE: the Lambda timeout may not exceed `MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT`
|
|
581
|
+
* (120s, CloudFront's default origin response timeout quota):
|
|
582
|
+
* `CanopyCmsDistribution` and `attachTo` fail at synth rather than deploying a
|
|
583
|
+
* configuration that would 504.
|
|
584
584
|
*/
|
|
585
585
|
export const DEFAULT_CMS_LAMBDA_TIMEOUT = Duration.seconds(60);
|
|
586
586
|
/**
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Construct } from 'constructs';
|
|
2
2
|
import { Duration, aws_cloudfront as cloudfront, aws_lambda as lambda } from 'aws-cdk-lib';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The longest origin read timeout these constructs accept: CloudFront's default
|
|
5
|
+
* quota for "Response timeout per origin" (1-120 s; 30 s unset; CloudFront Developer Guide,
|
|
6
|
+
* Quotas > General quotas on distributions).
|
|
7
|
+
*
|
|
8
|
+
* A cap rather than a pass-through of a raised quota because the editor's client
|
|
9
|
+
* deadline sits just above it (`REQUEST_TIMEOUT_MS` in canopycms
|
|
10
|
+
* `api/request-deadline.ts`, pinned by `request-deadline-pin.test.ts`) and cannot
|
|
11
|
+
* see the account's quota: a longer origin would be given up on by the browser
|
|
12
|
+
* before CloudFront answers.
|
|
13
|
+
*/
|
|
4
14
|
export declare const MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT: Duration;
|
|
5
15
|
/**
|
|
6
16
|
* The routes the editor needs from the CMS Lambda on a distribution it shares
|
|
@@ -21,9 +31,8 @@ export declare const EDITOR_PATH_PATTERNS: readonly ["/edit", "/edit/*", "/api/c
|
|
|
21
31
|
*/
|
|
22
32
|
export declare function cloudFrontPathPatternMatches(pattern: string, path: string): boolean;
|
|
23
33
|
/**
|
|
24
|
-
* Throws when the origin read timeout exceeds
|
|
25
|
-
*
|
|
26
|
-
* takes a higher, quota-raised value.
|
|
34
|
+
* Throws when the origin read timeout exceeds {@link MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT},
|
|
35
|
+
* so a configuration the editor's deadline cannot cover fails at synth, not mid-deploy.
|
|
27
36
|
*/
|
|
28
37
|
export declare function assertOriginReadTimeout(readTimeout: Duration, owner: string): void;
|
|
29
38
|
/**
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { Construct } from 'constructs';
|
|
2
2
|
import { Annotations, Duration, Stack, aws_cloudfront as cloudfront, aws_cloudfront_origins as origins, } from 'aws-cdk-lib';
|
|
3
3
|
import { ASSETS_PATH_PATTERN, ASSETS_TRANSFORM_PATH_PATTERN } from './asset-support.js';
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The longest origin read timeout these constructs accept: CloudFront's default
|
|
6
|
+
* quota for "Response timeout per origin" (1-120 s; 30 s unset; CloudFront Developer Guide,
|
|
7
|
+
* Quotas > General quotas on distributions).
|
|
8
|
+
*
|
|
9
|
+
* A cap rather than a pass-through of a raised quota because the editor's client
|
|
10
|
+
* deadline sits just above it (`REQUEST_TIMEOUT_MS` in canopycms
|
|
11
|
+
* `api/request-deadline.ts`, pinned by `request-deadline-pin.test.ts`) and cannot
|
|
12
|
+
* see the account's quota: a longer origin would be given up on by the browser
|
|
13
|
+
* before CloudFront answers.
|
|
14
|
+
*/
|
|
15
|
+
export const MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT = Duration.seconds(120);
|
|
6
16
|
/**
|
|
7
17
|
* The routes the editor needs from the CMS Lambda on a distribution it shares
|
|
8
18
|
* with a site: the editor page and the catch-all API route `canopycms init`
|
|
@@ -72,17 +82,18 @@ export function cloudFrontPathPatternMatches(pattern, path) {
|
|
|
72
82
|
return g === glob.length;
|
|
73
83
|
}
|
|
74
84
|
/**
|
|
75
|
-
* Throws when the origin read timeout exceeds
|
|
76
|
-
*
|
|
77
|
-
* takes a higher, quota-raised value.
|
|
85
|
+
* Throws when the origin read timeout exceeds {@link MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT},
|
|
86
|
+
* so a configuration the editor's deadline cannot cover fails at synth, not mid-deploy.
|
|
78
87
|
*/
|
|
79
88
|
export function assertOriginReadTimeout(readTimeout, owner) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`
|
|
84
|
-
`
|
|
85
|
-
`
|
|
89
|
+
const max = MAX_CLOUDFRONT_ORIGIN_READ_TIMEOUT.toSeconds();
|
|
90
|
+
if (readTimeout.toSeconds() > max) {
|
|
91
|
+
throw new Error(`${owner}: originReadTimeout is ${readTimeout.toSeconds()}s, but these constructs ` +
|
|
92
|
+
`support at most ${max}s, CloudFront's default quota for "Response timeout per ` +
|
|
93
|
+
`origin" (Service Quotas > CloudFront). Raising that quota does not lift this ` +
|
|
94
|
+
`limit: the editor's request deadline is set just above ${max}s. Lower the CMS ` +
|
|
95
|
+
`Lambda's timeout to ${max}s or less. A shorter origin timeout than the Lambda's ` +
|
|
96
|
+
`would 504 at the edge on requests that actually succeed.`);
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canopycms-cdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "AWS CDK constructs and EC2 worker for CanopyCMS deployment",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"aws-cdk-lib": "^2.260.0",
|
|
36
36
|
"constructs": "^10.0.0",
|
|
37
|
-
"canopycms": "0.
|
|
37
|
+
"canopycms": "0.7.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"aws-cdk-lib": {
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"tsx": "^4.19.0",
|
|
61
61
|
"typescript": "^5.6.3",
|
|
62
62
|
"vitest": "^4.1.0",
|
|
63
|
-
"canopycms": "0.
|
|
64
|
-
"canopycms-auth-clerk": "0.
|
|
63
|
+
"canopycms": "0.7.0",
|
|
64
|
+
"canopycms-auth-clerk": "0.7.0"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "rm -rf dist && tsc && node ../../scripts/add-js-extensions.mjs dist",
|