canopycms-cdk 0.0.68-int.112 → 0.0.68-int.114
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 +9 -6
- package/dist/constructs/cms-service.d.ts +23 -3
- package/dist/constructs/cms-service.js +231 -85
- package/dist/constructs/worker-bundle.d.ts +8 -2
- package/dist/constructs/worker-bundle.js +26 -3
- package/dist/constructs/worker-lifecycle.d.ts +19 -1
- package/dist/constructs/worker-lifecycle.js +27 -4
- package/dist/constructs/worker-units.d.ts +99 -0
- package/dist/constructs/worker-units.js +398 -0
- package/package.json +8 -5
- package/worker/canopy-github.service +81 -0
- package/worker/canopy-github.socket +16 -0
- package/worker/canopy-worker.service +48 -31
- package/worker/dist/index.js +22706 -18160
- package/worker/dist/index.js.contract +1 -1
- package/worker/dist/index.js.sha256 +1 -1
- package/worker/dist/instance-files.sh +365 -0
- package/worker/gateway.env.example +25 -0
package/README.md
CHANGED
|
@@ -29,11 +29,12 @@ Use `CanopyCmsDistribution` when the CMS gets its own domain. To serve the edito
|
|
|
29
29
|
|
|
30
30
|
### EC2 Worker
|
|
31
31
|
|
|
32
|
-
The `worker/` directory contains the EC2
|
|
32
|
+
The `worker/` directory contains the EC2 instance's entrypoint for AWS deployments, run as two services:
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
34
|
+
- the worker, with no network and no secret, starts the `CmsWorker` daemon from `canopycms` core and writes the Clerk auth cache;
|
|
35
|
+
- the GitHub gateway (`index.js gateway`) reads the secrets from AWS Secrets Manager and does everything the worker needs from GitHub, Clerk and AWS.
|
|
36
|
+
|
|
37
|
+
`worker/` also holds the three systemd units and `gateway.env.example`, for an install without the construct ([Installing the units by hand](../../docs/deploying-to-aws.md#installing-the-units-by-hand)).
|
|
37
38
|
|
|
38
39
|
The `CmsWorker` class itself lives in `canopycms/worker/cms-worker` and is cloud-agnostic. This package re-exports it for convenience.
|
|
39
40
|
|
|
@@ -66,10 +67,12 @@ const cmsDist = new CanopyCmsDistribution(this, 'CmsDist', {
|
|
|
66
67
|
```
|
|
67
68
|
CloudFront → Lambda Function URL → Lambda (VPC, no internet)
|
|
68
69
|
↕ EFS
|
|
69
|
-
EC2
|
|
70
|
+
EC2 worker (no network)
|
|
71
|
+
↕ unix socket
|
|
72
|
+
GitHub gateway (internet) → GitHub
|
|
70
73
|
```
|
|
71
74
|
|
|
72
|
-
Lambda handles all CMS operations using local EFS storage. The EC2 worker handles
|
|
75
|
+
Lambda handles all CMS operations using local EFS storage. The EC2 worker handles the operations that need GitHub or Clerk (GitHub push/PR, auth cache refresh), through the GitHub gateway beside it on the instance, which holds every secret and cannot see EFS. The Lambda and the worker communicate via the shared EFS filesystem.
|
|
73
76
|
|
|
74
77
|
See [ARCHITECTURE.md](../../ARCHITECTURE.md#deployment-architecture) for details.
|
|
75
78
|
|
|
@@ -4,6 +4,14 @@ import type { IBucket } from 'aws-cdk-lib/aws-s3';
|
|
|
4
4
|
import type * as sns from 'aws-cdk-lib/aws-sns';
|
|
5
5
|
import type { WorkerCode } from './worker-bundle.js';
|
|
6
6
|
import type { CanopyCmsAttachOptions } from './editor-routing.js';
|
|
7
|
+
/**
|
|
8
|
+
* `lines` without their shell comment lines, outside heredoc bodies, so the comments stay in this
|
|
9
|
+
* file and out of the 16 KiB EC2 allows user data. A `#!` line is kept, and every line of a
|
|
10
|
+
* heredoc is kept as written. Only the quoted form, a line ending `<< 'DELIM'`, may open one: any
|
|
11
|
+
* other `<<` is refused, since its body would be read as commands and comments here.
|
|
12
|
+
* @internal Exported for tests.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withoutShellComments(...lines: string[]): string[];
|
|
7
15
|
/**
|
|
8
16
|
* Default CMS Lambda timeout.
|
|
9
17
|
*
|
|
@@ -113,11 +121,11 @@ export interface CanopyCmsServiceProps {
|
|
|
113
121
|
*/
|
|
114
122
|
workerCode?: WorkerCode;
|
|
115
123
|
/**
|
|
116
|
-
* ADDITIONAL Secrets Manager ARNs the worker may read.
|
|
124
|
+
* ADDITIONAL Secrets Manager ARNs the worker instance's role may read.
|
|
117
125
|
*
|
|
118
126
|
* You do NOT need to repeat `githubTokenSecretArn` or
|
|
119
|
-
* `clerkSecretKeySecretArn` here — those are unioned into the
|
|
120
|
-
* policy automatically. Use this only for secrets the construct does not
|
|
127
|
+
* `clerkSecretKeySecretArn` here — those are unioned into the instance
|
|
128
|
+
* role's policy automatically. Use this only for secrets the construct does not
|
|
121
129
|
* know about.
|
|
122
130
|
*/
|
|
123
131
|
secretsArns?: string[];
|
|
@@ -307,6 +315,18 @@ export interface CanopyCmsServiceProps {
|
|
|
307
315
|
* drift.
|
|
308
316
|
*/
|
|
309
317
|
settingsBranch?: string;
|
|
318
|
+
/**
|
|
319
|
+
* Branches the worker never pushes, deletes or opens a pull request from, beside `baseBranch`
|
|
320
|
+
* and GitHub's default branch, which it always protects (default: none). Each entry is a branch
|
|
321
|
+
* name or a glob in which `*` matches any run of characters, `/` included (`release/*`),
|
|
322
|
+
* matched case-sensitively, as GitHub names refs. No entry may start with `canopycms-settings-`:
|
|
323
|
+
* a glob never matches a settings branch, and protecting one by name would stop the deployment's
|
|
324
|
+
* settings reaching GitHub. At most 1024 entries, and fewer when long: synth refuses any set
|
|
325
|
+
* that could take the worker's user data past EC2's 16 KiB. Stamped, comma-separated, into the
|
|
326
|
+
* GitHub gateway's `CANOPYCMS_PROTECTED_BRANCHES` (the worker's, for a bundle older than the
|
|
327
|
+
* split), and validated at synth.
|
|
328
|
+
*/
|
|
329
|
+
protectedBranches?: string[];
|
|
310
330
|
/**
|
|
311
331
|
* Deployment name (default: 'prod'). Namespaces the settings branch
|
|
312
332
|
* (`canopycms-settings-{deploymentName}`) so this stack's CMS Lambda/worker
|