@jaykingson/cdk-toolbox 0.0.1 → 0.0.2
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 +4 -0
- package/dist/bingo-blocks.mjs +418 -0
- package/package.json +3 -2
- package/src/bingo-blocks/blockCdkApps/blockCdkApps.ts +437 -0
- package/src/bingo-blocks/index.ts +3 -2
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@ vite-plus monorepo for shared CDK constructs and deployment apps. The published
|
|
|
11
11
|
| `apps/cdk-app-ephemeral` | Ephemeral PR stacks (deploy on PR, destroy on merge) |
|
|
12
12
|
| `apps/cdk-app-non-ephemeral` | Permanent main stack (deploy on main only) |
|
|
13
13
|
|
|
14
|
+
## Scaffold
|
|
15
|
+
|
|
16
|
+
`cdkToolbox()` writes a CDK app when the package name is `cdk-app`, and an account-setup app (GitHub OIDC provider plus a deploy role) when the package name is `cdk-account-setup`. vite-plus-base 0.0.17 places those two apps for `vp create @jaykingson:monorepo -- --plugins cdk-toolbox`. Any other package only receives the CDK devDependencies.
|
|
17
|
+
|
|
14
18
|
## Quick start
|
|
15
19
|
|
|
16
20
|
```bash
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { base, blockPackageJson } from "@jaykingson/vite-plus-base/bingo";
|
|
2
|
+
//#region src/bingo-blocks/blockCdkApps/blockCdkApps.ts
|
|
3
|
+
/**
|
|
4
|
+
* Versions already used by this repo's CDK apps. Package-scoped bingo writes a
|
|
5
|
+
* missing name as a devDependency range. An existing specifier, including
|
|
6
|
+
* `catalog:`, is left alone. Package scope cannot add catalog pins.
|
|
7
|
+
*/
|
|
8
|
+
const CDK_DEV_DEPENDENCIES = {
|
|
9
|
+
"aws-cdk": "2.1144.0",
|
|
10
|
+
"aws-cdk-lib": "2.272.0",
|
|
11
|
+
constructs: "^10.8.1"
|
|
12
|
+
};
|
|
13
|
+
const CDK_APP_PACKAGE = "cdk-app";
|
|
14
|
+
const ACCOUNT_SETUP_PACKAGE = "cdk-account-setup";
|
|
15
|
+
const blockCdkApps = base.createBlock({
|
|
16
|
+
about: { name: "CDK Apps" },
|
|
17
|
+
produce({ options }) {
|
|
18
|
+
const extensions = [blockPackageJson({ properties: { devDependencies: { ...CDK_DEV_DEPENDENCIES } } })];
|
|
19
|
+
const scaffold = scaffoldPackage("name" in options && typeof options.name === "string" ? options.name : void 0);
|
|
20
|
+
if (!scaffold) return { extensions };
|
|
21
|
+
return {
|
|
22
|
+
extensions,
|
|
23
|
+
files: scaffold === CDK_APP_PACKAGE ? cdkAppFiles() : accountSetupFiles()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
function scaffoldPackage(name) {
|
|
28
|
+
if (name === CDK_APP_PACKAGE || name === ACCOUNT_SETUP_PACKAGE) return name;
|
|
29
|
+
}
|
|
30
|
+
function cdkAppFiles() {
|
|
31
|
+
return {
|
|
32
|
+
".gitignore": "cdk.out\n",
|
|
33
|
+
"cdk.json": cdkJson(),
|
|
34
|
+
"vite.config.ts": applicationConfig(),
|
|
35
|
+
bin: { "app.ts": CDK_APP_BIN },
|
|
36
|
+
lib: {
|
|
37
|
+
"cdk-app-stack.ts": CDK_APP_STACK,
|
|
38
|
+
"cdk-app-stack.test.ts": CDK_APP_STACK_TEST
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function accountSetupFiles() {
|
|
43
|
+
return {
|
|
44
|
+
".gitignore": "cdk.out\n",
|
|
45
|
+
"cdk.json": cdkJson(),
|
|
46
|
+
"vite.config.ts": applicationConfig(),
|
|
47
|
+
bin: { "app.ts": ACCOUNT_SETUP_BIN },
|
|
48
|
+
lib: {
|
|
49
|
+
"account-setup-stack.ts": ACCOUNT_SETUP_STACK,
|
|
50
|
+
"account-setup-stack.test.ts": ACCOUNT_SETUP_STACK_TEST,
|
|
51
|
+
"github-repository.ts": GITHUB_REPOSITORY,
|
|
52
|
+
"github-repository.test.ts": GITHUB_REPOSITORY_TEST
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function cdkJson() {
|
|
57
|
+
return `${JSON.stringify({
|
|
58
|
+
app: "node bin/app.ts",
|
|
59
|
+
requireApproval: "never",
|
|
60
|
+
context: { "@aws-cdk/core:target-partitions": ["aws", "aws-cn"] }
|
|
61
|
+
}, null, 2)}\n`;
|
|
62
|
+
}
|
|
63
|
+
function applicationConfig() {
|
|
64
|
+
return `import { cdkToolbox } from "@jaykingson/cdk-toolbox/bingo-blocks";
|
|
65
|
+
import { defineApplicationConfig } from "@jaykingson/vite-plus-base";
|
|
66
|
+
|
|
67
|
+
export default defineApplicationConfig({
|
|
68
|
+
bingo: {
|
|
69
|
+
plugins: [cdkToolbox()],
|
|
70
|
+
},
|
|
71
|
+
run: {
|
|
72
|
+
tasks: {
|
|
73
|
+
synth: {
|
|
74
|
+
command: "cdk synth",
|
|
75
|
+
cache: false,
|
|
76
|
+
},
|
|
77
|
+
diff: {
|
|
78
|
+
command: "cdk diff",
|
|
79
|
+
cache: false,
|
|
80
|
+
},
|
|
81
|
+
deploy: {
|
|
82
|
+
command: "cdk deploy --all",
|
|
83
|
+
cache: false,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
test: {
|
|
88
|
+
environment: "node",
|
|
89
|
+
include: ["lib/**/*.test.ts"],
|
|
90
|
+
exclude: ["**/node_modules/**", "**/.git/**", "cdk.out/**"],
|
|
91
|
+
passWithNoTests: true,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
`;
|
|
95
|
+
}
|
|
96
|
+
const CDK_APP_BIN = `#!/usr/bin/env node
|
|
97
|
+
import { App } from "aws-cdk-lib";
|
|
98
|
+
|
|
99
|
+
import { CdkAppStack } from "../lib/cdk-app-stack.ts";
|
|
100
|
+
|
|
101
|
+
const app = new App();
|
|
102
|
+
new CdkAppStack(app, "CdkAppStack");
|
|
103
|
+
`;
|
|
104
|
+
const CDK_APP_STACK = `import { CfnOutput, Stack, type StackProps } from "aws-cdk-lib";
|
|
105
|
+
import { Construct } from "constructs";
|
|
106
|
+
|
|
107
|
+
export class CdkAppStack extends Stack {
|
|
108
|
+
constructor(scope: Construct, id: string, props?: StackProps) {
|
|
109
|
+
super(scope, id, props);
|
|
110
|
+
|
|
111
|
+
new CfnOutput(this, "StackName", {
|
|
112
|
+
value: this.stackName,
|
|
113
|
+
description: "Name of the scaffolded CDK stack.",
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
const CDK_APP_STACK_TEST = `import { App } from "aws-cdk-lib";
|
|
119
|
+
import { Template } from "aws-cdk-lib/assertions";
|
|
120
|
+
import { describe, it } from "vite-plus/test";
|
|
121
|
+
|
|
122
|
+
import { CdkAppStack } from "./cdk-app-stack.ts";
|
|
123
|
+
|
|
124
|
+
describe("CdkAppStack", () => {
|
|
125
|
+
it("synthesizes without AWS credentials", () => {
|
|
126
|
+
const app = new App();
|
|
127
|
+
const stack = new CdkAppStack(app, "CdkAppStack");
|
|
128
|
+
const template = Template.fromStack(stack);
|
|
129
|
+
|
|
130
|
+
template.hasOutput("StackName", {});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
`;
|
|
134
|
+
const ACCOUNT_SETUP_BIN = `#!/usr/bin/env node
|
|
135
|
+
import { readFileSync } from "node:fs";
|
|
136
|
+
import { dirname, join } from "node:path";
|
|
137
|
+
import { fileURLToPath } from "node:url";
|
|
138
|
+
import { App } from "aws-cdk-lib";
|
|
139
|
+
|
|
140
|
+
import { AccountSetupStack } from "../lib/account-setup-stack.ts";
|
|
141
|
+
import { resolveGitHubRepository } from "../lib/github-repository.ts";
|
|
142
|
+
|
|
143
|
+
const app = new App();
|
|
144
|
+
const rootManifest = readRootManifest();
|
|
145
|
+
const repository = resolveGitHubRepository({
|
|
146
|
+
contextOwner: app.node.tryGetContext("githubOwner"),
|
|
147
|
+
contextName: app.node.tryGetContext("githubRepo"),
|
|
148
|
+
env: process.env,
|
|
149
|
+
repositoryUrl: rootManifest.repositoryUrl,
|
|
150
|
+
packageName: rootManifest.name,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
new AccountSetupStack(app, "AccountSetupStack", {
|
|
154
|
+
repositoryOwner: repository.owner,
|
|
155
|
+
repositoryName: repository.name,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
function readRootManifest(): { name?: string; repositoryUrl?: string } {
|
|
159
|
+
try {
|
|
160
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
161
|
+
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as {
|
|
162
|
+
name?: unknown;
|
|
163
|
+
repository?: unknown;
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
name: typeof manifest.name === "string" ? manifest.name : undefined,
|
|
167
|
+
repositoryUrl: repositoryUrl(manifest.repository),
|
|
168
|
+
};
|
|
169
|
+
} catch {
|
|
170
|
+
return {};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function repositoryUrl(repository: unknown): string | undefined {
|
|
175
|
+
if (typeof repository === "string") {
|
|
176
|
+
return repository;
|
|
177
|
+
}
|
|
178
|
+
if (repository && typeof repository === "object" && "url" in repository) {
|
|
179
|
+
const url = (repository as { url?: unknown }).url;
|
|
180
|
+
return typeof url === "string" ? url : undefined;
|
|
181
|
+
}
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
const ACCOUNT_SETUP_STACK = `import { Aws, CfnOutput, Stack, type StackProps } from "aws-cdk-lib";
|
|
186
|
+
import {
|
|
187
|
+
OidcProviderNative,
|
|
188
|
+
PolicyStatement,
|
|
189
|
+
Role,
|
|
190
|
+
WebIdentityPrincipal,
|
|
191
|
+
} from "aws-cdk-lib/aws-iam";
|
|
192
|
+
import { Construct } from "constructs";
|
|
193
|
+
|
|
194
|
+
const BOOTSTRAP_QUALIFIER = "hnb659fds";
|
|
195
|
+
const BOOTSTRAP_REGION = "us-east-1";
|
|
196
|
+
const BOOTSTRAP_ROLE_NAMES = [
|
|
197
|
+
"deploy-role",
|
|
198
|
+
"file-publishing-role",
|
|
199
|
+
"image-publishing-role",
|
|
200
|
+
"lookup-role",
|
|
201
|
+
"cfn-exec-role",
|
|
202
|
+
] as const;
|
|
203
|
+
|
|
204
|
+
const GITHUB_OIDC_URL = "https://token.actions.githubusercontent.com";
|
|
205
|
+
const GITHUB_OIDC_AUDIENCE = "sts.amazonaws.com";
|
|
206
|
+
|
|
207
|
+
export type AccountSetupStackProps = StackProps & {
|
|
208
|
+
repositoryOwner?: string;
|
|
209
|
+
repositoryName?: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export class AccountSetupStack extends Stack {
|
|
213
|
+
constructor(scope: Construct, id: string, props: AccountSetupStackProps = {}) {
|
|
214
|
+
super(scope, id, props);
|
|
215
|
+
|
|
216
|
+
const owner = props.repositoryOwner ?? "owner";
|
|
217
|
+
const name = props.repositoryName ?? "repo";
|
|
218
|
+
const repository = \`\${owner}/\${name}\`;
|
|
219
|
+
|
|
220
|
+
const provider = new OidcProviderNative(this, "GitHubProvider", {
|
|
221
|
+
url: GITHUB_OIDC_URL,
|
|
222
|
+
clientIds: [GITHUB_OIDC_AUDIENCE],
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const deployRole = new Role(this, "DeployRole", {
|
|
226
|
+
roleName: "GitHubActionsCdkDeployRole",
|
|
227
|
+
description: \`Allows GitHub Actions from \${repository} to deploy CDK stacks.\`,
|
|
228
|
+
assumedBy: new WebIdentityPrincipal(provider.openIdConnectProviderArn, {
|
|
229
|
+
StringEquals: {
|
|
230
|
+
"token.actions.githubusercontent.com:aud": GITHUB_OIDC_AUDIENCE,
|
|
231
|
+
},
|
|
232
|
+
StringLike: {
|
|
233
|
+
// owner/name subjects. Immutable numeric subjects are a later polish.
|
|
234
|
+
"token.actions.githubusercontent.com:sub": \`repo:\${repository}:*\`,
|
|
235
|
+
},
|
|
236
|
+
}),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
deployRole.addToPolicy(
|
|
240
|
+
new PolicyStatement({
|
|
241
|
+
actions: ["sts:AssumeRole"],
|
|
242
|
+
resources: BOOTSTRAP_ROLE_NAMES.map(
|
|
243
|
+
(roleName) =>
|
|
244
|
+
\`arn:\${Aws.PARTITION}:iam::\${Aws.ACCOUNT_ID}:role/cdk-\${BOOTSTRAP_QUALIFIER}-\${roleName}-\${Aws.ACCOUNT_ID}-\${BOOTSTRAP_REGION}\`,
|
|
245
|
+
),
|
|
246
|
+
}),
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
new CfnOutput(this, "GitHubActionsDeployRoleArn", {
|
|
250
|
+
value: deployRole.roleArn,
|
|
251
|
+
description: "Assume this role from GitHub Actions via OIDC.",
|
|
252
|
+
});
|
|
253
|
+
new CfnOutput(this, "GitHubActionsOidcProviderArn", {
|
|
254
|
+
value: provider.openIdConnectProviderArn,
|
|
255
|
+
description: "GitHub Actions OIDC provider ARN.",
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
`;
|
|
260
|
+
const ACCOUNT_SETUP_STACK_TEST = `import { App } from "aws-cdk-lib";
|
|
261
|
+
import { Template } from "aws-cdk-lib/assertions";
|
|
262
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
263
|
+
|
|
264
|
+
import { AccountSetupStack } from "./account-setup-stack.ts";
|
|
265
|
+
|
|
266
|
+
describe("AccountSetupStack", () => {
|
|
267
|
+
it("synthesizes a GitHub OIDC provider and deploy role without AWS credentials", () => {
|
|
268
|
+
const app = new App();
|
|
269
|
+
const stack = new AccountSetupStack(app, "AccountSetupStack", {
|
|
270
|
+
repositoryOwner: "octo",
|
|
271
|
+
repositoryName: "aws-ops",
|
|
272
|
+
});
|
|
273
|
+
const template = Template.fromStack(stack);
|
|
274
|
+
|
|
275
|
+
template.resourceCountIs("AWS::IAM::OIDCProvider", 1);
|
|
276
|
+
template.hasResourceProperties("AWS::IAM::Role", {
|
|
277
|
+
RoleName: "GitHubActionsCdkDeployRole",
|
|
278
|
+
});
|
|
279
|
+
expect(JSON.stringify(template.toJSON())).toContain("repo:octo/aws-ops:*");
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
`;
|
|
283
|
+
const GITHUB_REPOSITORY = `const GITHUB_SLUG = /^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/;
|
|
284
|
+
const GITHUB_URL = /github\\.com[:/]([^/]+)\\/([^/#?\\s]+?)(?:\\.git)?$/;
|
|
285
|
+
|
|
286
|
+
export type GitHubRepository = {
|
|
287
|
+
owner: string;
|
|
288
|
+
name: string;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export function resolveGitHubRepository(input: {
|
|
292
|
+
contextOwner?: unknown;
|
|
293
|
+
contextName?: unknown;
|
|
294
|
+
env?: Record<string, string | undefined>;
|
|
295
|
+
repositoryUrl?: string;
|
|
296
|
+
packageName?: string;
|
|
297
|
+
}): GitHubRepository {
|
|
298
|
+
const context = pair(input.contextOwner, input.contextName);
|
|
299
|
+
if (context) {
|
|
300
|
+
return context;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const fromEnv = parseSlug(input.env?.GITHUB_REPOSITORY);
|
|
304
|
+
if (fromEnv) {
|
|
305
|
+
return fromEnv;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const fromUrl = parseRepositoryUrl(input.repositoryUrl);
|
|
309
|
+
if (fromUrl) {
|
|
310
|
+
return fromUrl;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return { owner: "owner", name: input.packageName || "repo" };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function pair(owner: unknown, name: unknown): GitHubRepository | undefined {
|
|
317
|
+
if (typeof owner !== "string" || typeof name !== "string") {
|
|
318
|
+
return undefined;
|
|
319
|
+
}
|
|
320
|
+
const trimmedOwner = owner.trim();
|
|
321
|
+
const trimmedName = name.trim();
|
|
322
|
+
if (!trimmedOwner || !trimmedName) {
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
return { owner: trimmedOwner, name: trimmedName };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function parseSlug(value: string | undefined): GitHubRepository | undefined {
|
|
329
|
+
const trimmed = value?.trim();
|
|
330
|
+
if (!trimmed || !GITHUB_SLUG.test(trimmed)) {
|
|
331
|
+
return undefined;
|
|
332
|
+
}
|
|
333
|
+
const [owner, name] = trimmed.split("/");
|
|
334
|
+
if (!owner || !name) {
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
return { owner, name };
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function parseRepositoryUrl(value: string | undefined): GitHubRepository | undefined {
|
|
341
|
+
const trimmed = value?.trim();
|
|
342
|
+
if (!trimmed) {
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
const slug = parseSlug(trimmed);
|
|
346
|
+
if (slug) {
|
|
347
|
+
return slug;
|
|
348
|
+
}
|
|
349
|
+
const match = GITHUB_URL.exec(trimmed);
|
|
350
|
+
const owner = match?.[1];
|
|
351
|
+
const name = match?.[2];
|
|
352
|
+
if (!owner || !name) {
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
return { owner, name };
|
|
356
|
+
}
|
|
357
|
+
`;
|
|
358
|
+
const GITHUB_REPOSITORY_TEST = `import { describe, expect, it } from "vite-plus/test";
|
|
359
|
+
|
|
360
|
+
import { resolveGitHubRepository } from "./github-repository.ts";
|
|
361
|
+
|
|
362
|
+
describe("resolveGitHubRepository", () => {
|
|
363
|
+
it("prefers CDK context, then GitHub env, then the repository URL", () => {
|
|
364
|
+
expect(
|
|
365
|
+
resolveGitHubRepository({
|
|
366
|
+
contextOwner: "from-context",
|
|
367
|
+
contextName: "repo",
|
|
368
|
+
env: { GITHUB_REPOSITORY: "from-env/repo" },
|
|
369
|
+
repositoryUrl: "https://github.com/from-url/repo",
|
|
370
|
+
}),
|
|
371
|
+
).toEqual({ owner: "from-context", name: "repo" });
|
|
372
|
+
|
|
373
|
+
expect(
|
|
374
|
+
resolveGitHubRepository({
|
|
375
|
+
env: { GITHUB_REPOSITORY: "from-env/repo" },
|
|
376
|
+
repositoryUrl: "git+https://github.com/from-url/repo.git",
|
|
377
|
+
}),
|
|
378
|
+
).toEqual({ owner: "from-env", name: "repo" });
|
|
379
|
+
|
|
380
|
+
expect(
|
|
381
|
+
resolveGitHubRepository({
|
|
382
|
+
repositoryUrl: "https://github.com/from-url/repo.git",
|
|
383
|
+
packageName: "aws-ops",
|
|
384
|
+
}),
|
|
385
|
+
).toEqual({ owner: "from-url", name: "repo" });
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it("falls back to the package name so synth still has a subject", () => {
|
|
389
|
+
expect(resolveGitHubRepository({ packageName: "aws-ops" })).toEqual({
|
|
390
|
+
owner: "owner",
|
|
391
|
+
name: "aws-ops",
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
`;
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/bingo-blocks/blockCdkPreflight/blockCdkPreflight.ts
|
|
398
|
+
const cdkPreflightRange = "^1.20.19";
|
|
399
|
+
const blockCdkPreflight = base.createBlock({
|
|
400
|
+
about: { name: "CDK Preflight" },
|
|
401
|
+
produce() {
|
|
402
|
+
return { extensions: [blockPackageJson({ properties: { devDependencies: { "cdk-preflight": cdkPreflightRange } } })] };
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/bingo-blocks/index.ts
|
|
407
|
+
function cdkToolbox() {
|
|
408
|
+
return base.createPreset({
|
|
409
|
+
about: { name: "cdk-toolbox" },
|
|
410
|
+
blocks: [
|
|
411
|
+
blockPackageJson,
|
|
412
|
+
blockCdkPreflight,
|
|
413
|
+
blockCdkApps
|
|
414
|
+
]
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
//#endregion
|
|
418
|
+
export { blockCdkApps, blockCdkPreflight, cdkToolbox };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaykingson/cdk-toolbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "CDK apps and bingo blocks for vite-plus-base.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"src/bingo-blocks/index.ts",
|
|
13
|
-
"src/bingo-blocks/blockCdkPreflight/blockCdkPreflight.ts"
|
|
13
|
+
"src/bingo-blocks/blockCdkPreflight/blockCdkPreflight.ts",
|
|
14
|
+
"src/bingo-blocks/blockCdkApps/blockCdkApps.ts"
|
|
14
15
|
],
|
|
15
16
|
"type": "module",
|
|
16
17
|
"exports": {
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { base, blockPackageJson } from "@jaykingson/vite-plus-base/bingo";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Versions already used by this repo's CDK apps. Package-scoped bingo writes a
|
|
5
|
+
* missing name as a devDependency range. An existing specifier, including
|
|
6
|
+
* `catalog:`, is left alone. Package scope cannot add catalog pins.
|
|
7
|
+
*/
|
|
8
|
+
const CDK_DEV_DEPENDENCIES = {
|
|
9
|
+
"aws-cdk": "2.1144.0",
|
|
10
|
+
"aws-cdk-lib": "2.272.0",
|
|
11
|
+
constructs: "^10.8.1",
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
const CDK_APP_PACKAGE = "cdk-app";
|
|
15
|
+
const ACCOUNT_SETUP_PACKAGE = "cdk-account-setup";
|
|
16
|
+
|
|
17
|
+
type ScaffoldPackage = typeof CDK_APP_PACKAGE | typeof ACCOUNT_SETUP_PACKAGE;
|
|
18
|
+
|
|
19
|
+
export const blockCdkApps = base.createBlock({
|
|
20
|
+
about: {
|
|
21
|
+
name: "CDK Apps",
|
|
22
|
+
},
|
|
23
|
+
produce({ options }) {
|
|
24
|
+
const extensions = [
|
|
25
|
+
blockPackageJson({
|
|
26
|
+
properties: {
|
|
27
|
+
devDependencies: { ...CDK_DEV_DEPENDENCIES },
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
];
|
|
31
|
+
const name = "name" in options && typeof options.name === "string" ? options.name : undefined;
|
|
32
|
+
const scaffold = scaffoldPackage(name);
|
|
33
|
+
if (!scaffold) {
|
|
34
|
+
return { extensions };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
extensions,
|
|
39
|
+
files: scaffold === CDK_APP_PACKAGE ? cdkAppFiles() : accountSetupFiles(),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function scaffoldPackage(name: string | undefined): ScaffoldPackage | undefined {
|
|
45
|
+
if (name === CDK_APP_PACKAGE || name === ACCOUNT_SETUP_PACKAGE) {
|
|
46
|
+
return name;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function cdkAppFiles() {
|
|
52
|
+
return {
|
|
53
|
+
".gitignore": "cdk.out\n",
|
|
54
|
+
"cdk.json": cdkJson(),
|
|
55
|
+
"vite.config.ts": applicationConfig(),
|
|
56
|
+
bin: {
|
|
57
|
+
"app.ts": CDK_APP_BIN,
|
|
58
|
+
},
|
|
59
|
+
lib: {
|
|
60
|
+
"cdk-app-stack.ts": CDK_APP_STACK,
|
|
61
|
+
"cdk-app-stack.test.ts": CDK_APP_STACK_TEST,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function accountSetupFiles() {
|
|
67
|
+
return {
|
|
68
|
+
".gitignore": "cdk.out\n",
|
|
69
|
+
"cdk.json": cdkJson(),
|
|
70
|
+
"vite.config.ts": applicationConfig(),
|
|
71
|
+
bin: {
|
|
72
|
+
"app.ts": ACCOUNT_SETUP_BIN,
|
|
73
|
+
},
|
|
74
|
+
lib: {
|
|
75
|
+
"account-setup-stack.ts": ACCOUNT_SETUP_STACK,
|
|
76
|
+
"account-setup-stack.test.ts": ACCOUNT_SETUP_STACK_TEST,
|
|
77
|
+
"github-repository.ts": GITHUB_REPOSITORY,
|
|
78
|
+
"github-repository.test.ts": GITHUB_REPOSITORY_TEST,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function cdkJson() {
|
|
84
|
+
return `${JSON.stringify(
|
|
85
|
+
{
|
|
86
|
+
app: "node bin/app.ts",
|
|
87
|
+
requireApproval: "never",
|
|
88
|
+
context: {
|
|
89
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
null,
|
|
93
|
+
2,
|
|
94
|
+
)}\n`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function applicationConfig() {
|
|
98
|
+
return `import { cdkToolbox } from "@jaykingson/cdk-toolbox/bingo-blocks";
|
|
99
|
+
import { defineApplicationConfig } from "@jaykingson/vite-plus-base";
|
|
100
|
+
|
|
101
|
+
export default defineApplicationConfig({
|
|
102
|
+
bingo: {
|
|
103
|
+
plugins: [cdkToolbox()],
|
|
104
|
+
},
|
|
105
|
+
run: {
|
|
106
|
+
tasks: {
|
|
107
|
+
synth: {
|
|
108
|
+
command: "cdk synth",
|
|
109
|
+
cache: false,
|
|
110
|
+
},
|
|
111
|
+
diff: {
|
|
112
|
+
command: "cdk diff",
|
|
113
|
+
cache: false,
|
|
114
|
+
},
|
|
115
|
+
deploy: {
|
|
116
|
+
command: "cdk deploy --all",
|
|
117
|
+
cache: false,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
test: {
|
|
122
|
+
environment: "node",
|
|
123
|
+
include: ["lib/**/*.test.ts"],
|
|
124
|
+
exclude: ["**/node_modules/**", "**/.git/**", "cdk.out/**"],
|
|
125
|
+
passWithNoTests: true,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const CDK_APP_BIN = `#!/usr/bin/env node
|
|
132
|
+
import { App } from "aws-cdk-lib";
|
|
133
|
+
|
|
134
|
+
import { CdkAppStack } from "../lib/cdk-app-stack.ts";
|
|
135
|
+
|
|
136
|
+
const app = new App();
|
|
137
|
+
new CdkAppStack(app, "CdkAppStack");
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
const CDK_APP_STACK = `import { CfnOutput, Stack, type StackProps } from "aws-cdk-lib";
|
|
141
|
+
import { Construct } from "constructs";
|
|
142
|
+
|
|
143
|
+
export class CdkAppStack extends Stack {
|
|
144
|
+
constructor(scope: Construct, id: string, props?: StackProps) {
|
|
145
|
+
super(scope, id, props);
|
|
146
|
+
|
|
147
|
+
new CfnOutput(this, "StackName", {
|
|
148
|
+
value: this.stackName,
|
|
149
|
+
description: "Name of the scaffolded CDK stack.",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
`;
|
|
154
|
+
|
|
155
|
+
const CDK_APP_STACK_TEST = `import { App } from "aws-cdk-lib";
|
|
156
|
+
import { Template } from "aws-cdk-lib/assertions";
|
|
157
|
+
import { describe, it } from "vite-plus/test";
|
|
158
|
+
|
|
159
|
+
import { CdkAppStack } from "./cdk-app-stack.ts";
|
|
160
|
+
|
|
161
|
+
describe("CdkAppStack", () => {
|
|
162
|
+
it("synthesizes without AWS credentials", () => {
|
|
163
|
+
const app = new App();
|
|
164
|
+
const stack = new CdkAppStack(app, "CdkAppStack");
|
|
165
|
+
const template = Template.fromStack(stack);
|
|
166
|
+
|
|
167
|
+
template.hasOutput("StackName", {});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
`;
|
|
171
|
+
|
|
172
|
+
const ACCOUNT_SETUP_BIN = `#!/usr/bin/env node
|
|
173
|
+
import { readFileSync } from "node:fs";
|
|
174
|
+
import { dirname, join } from "node:path";
|
|
175
|
+
import { fileURLToPath } from "node:url";
|
|
176
|
+
import { App } from "aws-cdk-lib";
|
|
177
|
+
|
|
178
|
+
import { AccountSetupStack } from "../lib/account-setup-stack.ts";
|
|
179
|
+
import { resolveGitHubRepository } from "../lib/github-repository.ts";
|
|
180
|
+
|
|
181
|
+
const app = new App();
|
|
182
|
+
const rootManifest = readRootManifest();
|
|
183
|
+
const repository = resolveGitHubRepository({
|
|
184
|
+
contextOwner: app.node.tryGetContext("githubOwner"),
|
|
185
|
+
contextName: app.node.tryGetContext("githubRepo"),
|
|
186
|
+
env: process.env,
|
|
187
|
+
repositoryUrl: rootManifest.repositoryUrl,
|
|
188
|
+
packageName: rootManifest.name,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
new AccountSetupStack(app, "AccountSetupStack", {
|
|
192
|
+
repositoryOwner: repository.owner,
|
|
193
|
+
repositoryName: repository.name,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
function readRootManifest(): { name?: string; repositoryUrl?: string } {
|
|
197
|
+
try {
|
|
198
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
199
|
+
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as {
|
|
200
|
+
name?: unknown;
|
|
201
|
+
repository?: unknown;
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
name: typeof manifest.name === "string" ? manifest.name : undefined,
|
|
205
|
+
repositoryUrl: repositoryUrl(manifest.repository),
|
|
206
|
+
};
|
|
207
|
+
} catch {
|
|
208
|
+
return {};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function repositoryUrl(repository: unknown): string | undefined {
|
|
213
|
+
if (typeof repository === "string") {
|
|
214
|
+
return repository;
|
|
215
|
+
}
|
|
216
|
+
if (repository && typeof repository === "object" && "url" in repository) {
|
|
217
|
+
const url = (repository as { url?: unknown }).url;
|
|
218
|
+
return typeof url === "string" ? url : undefined;
|
|
219
|
+
}
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
|
|
224
|
+
const ACCOUNT_SETUP_STACK = `import { Aws, CfnOutput, Stack, type StackProps } from "aws-cdk-lib";
|
|
225
|
+
import {
|
|
226
|
+
OidcProviderNative,
|
|
227
|
+
PolicyStatement,
|
|
228
|
+
Role,
|
|
229
|
+
WebIdentityPrincipal,
|
|
230
|
+
} from "aws-cdk-lib/aws-iam";
|
|
231
|
+
import { Construct } from "constructs";
|
|
232
|
+
|
|
233
|
+
const BOOTSTRAP_QUALIFIER = "hnb659fds";
|
|
234
|
+
const BOOTSTRAP_REGION = "us-east-1";
|
|
235
|
+
const BOOTSTRAP_ROLE_NAMES = [
|
|
236
|
+
"deploy-role",
|
|
237
|
+
"file-publishing-role",
|
|
238
|
+
"image-publishing-role",
|
|
239
|
+
"lookup-role",
|
|
240
|
+
"cfn-exec-role",
|
|
241
|
+
] as const;
|
|
242
|
+
|
|
243
|
+
const GITHUB_OIDC_URL = "https://token.actions.githubusercontent.com";
|
|
244
|
+
const GITHUB_OIDC_AUDIENCE = "sts.amazonaws.com";
|
|
245
|
+
|
|
246
|
+
export type AccountSetupStackProps = StackProps & {
|
|
247
|
+
repositoryOwner?: string;
|
|
248
|
+
repositoryName?: string;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export class AccountSetupStack extends Stack {
|
|
252
|
+
constructor(scope: Construct, id: string, props: AccountSetupStackProps = {}) {
|
|
253
|
+
super(scope, id, props);
|
|
254
|
+
|
|
255
|
+
const owner = props.repositoryOwner ?? "owner";
|
|
256
|
+
const name = props.repositoryName ?? "repo";
|
|
257
|
+
const repository = \`\${owner}/\${name}\`;
|
|
258
|
+
|
|
259
|
+
const provider = new OidcProviderNative(this, "GitHubProvider", {
|
|
260
|
+
url: GITHUB_OIDC_URL,
|
|
261
|
+
clientIds: [GITHUB_OIDC_AUDIENCE],
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const deployRole = new Role(this, "DeployRole", {
|
|
265
|
+
roleName: "GitHubActionsCdkDeployRole",
|
|
266
|
+
description: \`Allows GitHub Actions from \${repository} to deploy CDK stacks.\`,
|
|
267
|
+
assumedBy: new WebIdentityPrincipal(provider.openIdConnectProviderArn, {
|
|
268
|
+
StringEquals: {
|
|
269
|
+
"token.actions.githubusercontent.com:aud": GITHUB_OIDC_AUDIENCE,
|
|
270
|
+
},
|
|
271
|
+
StringLike: {
|
|
272
|
+
// owner/name subjects. Immutable numeric subjects are a later polish.
|
|
273
|
+
"token.actions.githubusercontent.com:sub": \`repo:\${repository}:*\`,
|
|
274
|
+
},
|
|
275
|
+
}),
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
deployRole.addToPolicy(
|
|
279
|
+
new PolicyStatement({
|
|
280
|
+
actions: ["sts:AssumeRole"],
|
|
281
|
+
resources: BOOTSTRAP_ROLE_NAMES.map(
|
|
282
|
+
(roleName) =>
|
|
283
|
+
\`arn:\${Aws.PARTITION}:iam::\${Aws.ACCOUNT_ID}:role/cdk-\${BOOTSTRAP_QUALIFIER}-\${roleName}-\${Aws.ACCOUNT_ID}-\${BOOTSTRAP_REGION}\`,
|
|
284
|
+
),
|
|
285
|
+
}),
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
new CfnOutput(this, "GitHubActionsDeployRoleArn", {
|
|
289
|
+
value: deployRole.roleArn,
|
|
290
|
+
description: "Assume this role from GitHub Actions via OIDC.",
|
|
291
|
+
});
|
|
292
|
+
new CfnOutput(this, "GitHubActionsOidcProviderArn", {
|
|
293
|
+
value: provider.openIdConnectProviderArn,
|
|
294
|
+
description: "GitHub Actions OIDC provider ARN.",
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
`;
|
|
299
|
+
|
|
300
|
+
const ACCOUNT_SETUP_STACK_TEST = `import { App } from "aws-cdk-lib";
|
|
301
|
+
import { Template } from "aws-cdk-lib/assertions";
|
|
302
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
303
|
+
|
|
304
|
+
import { AccountSetupStack } from "./account-setup-stack.ts";
|
|
305
|
+
|
|
306
|
+
describe("AccountSetupStack", () => {
|
|
307
|
+
it("synthesizes a GitHub OIDC provider and deploy role without AWS credentials", () => {
|
|
308
|
+
const app = new App();
|
|
309
|
+
const stack = new AccountSetupStack(app, "AccountSetupStack", {
|
|
310
|
+
repositoryOwner: "octo",
|
|
311
|
+
repositoryName: "aws-ops",
|
|
312
|
+
});
|
|
313
|
+
const template = Template.fromStack(stack);
|
|
314
|
+
|
|
315
|
+
template.resourceCountIs("AWS::IAM::OIDCProvider", 1);
|
|
316
|
+
template.hasResourceProperties("AWS::IAM::Role", {
|
|
317
|
+
RoleName: "GitHubActionsCdkDeployRole",
|
|
318
|
+
});
|
|
319
|
+
expect(JSON.stringify(template.toJSON())).toContain("repo:octo/aws-ops:*");
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
`;
|
|
323
|
+
|
|
324
|
+
const GITHUB_REPOSITORY = `const GITHUB_SLUG = /^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/;
|
|
325
|
+
const GITHUB_URL = /github\\.com[:/]([^/]+)\\/([^/#?\\s]+?)(?:\\.git)?$/;
|
|
326
|
+
|
|
327
|
+
export type GitHubRepository = {
|
|
328
|
+
owner: string;
|
|
329
|
+
name: string;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
export function resolveGitHubRepository(input: {
|
|
333
|
+
contextOwner?: unknown;
|
|
334
|
+
contextName?: unknown;
|
|
335
|
+
env?: Record<string, string | undefined>;
|
|
336
|
+
repositoryUrl?: string;
|
|
337
|
+
packageName?: string;
|
|
338
|
+
}): GitHubRepository {
|
|
339
|
+
const context = pair(input.contextOwner, input.contextName);
|
|
340
|
+
if (context) {
|
|
341
|
+
return context;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const fromEnv = parseSlug(input.env?.GITHUB_REPOSITORY);
|
|
345
|
+
if (fromEnv) {
|
|
346
|
+
return fromEnv;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const fromUrl = parseRepositoryUrl(input.repositoryUrl);
|
|
350
|
+
if (fromUrl) {
|
|
351
|
+
return fromUrl;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return { owner: "owner", name: input.packageName || "repo" };
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function pair(owner: unknown, name: unknown): GitHubRepository | undefined {
|
|
358
|
+
if (typeof owner !== "string" || typeof name !== "string") {
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
const trimmedOwner = owner.trim();
|
|
362
|
+
const trimmedName = name.trim();
|
|
363
|
+
if (!trimmedOwner || !trimmedName) {
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
366
|
+
return { owner: trimmedOwner, name: trimmedName };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function parseSlug(value: string | undefined): GitHubRepository | undefined {
|
|
370
|
+
const trimmed = value?.trim();
|
|
371
|
+
if (!trimmed || !GITHUB_SLUG.test(trimmed)) {
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
374
|
+
const [owner, name] = trimmed.split("/");
|
|
375
|
+
if (!owner || !name) {
|
|
376
|
+
return undefined;
|
|
377
|
+
}
|
|
378
|
+
return { owner, name };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function parseRepositoryUrl(value: string | undefined): GitHubRepository | undefined {
|
|
382
|
+
const trimmed = value?.trim();
|
|
383
|
+
if (!trimmed) {
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
const slug = parseSlug(trimmed);
|
|
387
|
+
if (slug) {
|
|
388
|
+
return slug;
|
|
389
|
+
}
|
|
390
|
+
const match = GITHUB_URL.exec(trimmed);
|
|
391
|
+
const owner = match?.[1];
|
|
392
|
+
const name = match?.[2];
|
|
393
|
+
if (!owner || !name) {
|
|
394
|
+
return undefined;
|
|
395
|
+
}
|
|
396
|
+
return { owner, name };
|
|
397
|
+
}
|
|
398
|
+
`;
|
|
399
|
+
|
|
400
|
+
const GITHUB_REPOSITORY_TEST = `import { describe, expect, it } from "vite-plus/test";
|
|
401
|
+
|
|
402
|
+
import { resolveGitHubRepository } from "./github-repository.ts";
|
|
403
|
+
|
|
404
|
+
describe("resolveGitHubRepository", () => {
|
|
405
|
+
it("prefers CDK context, then GitHub env, then the repository URL", () => {
|
|
406
|
+
expect(
|
|
407
|
+
resolveGitHubRepository({
|
|
408
|
+
contextOwner: "from-context",
|
|
409
|
+
contextName: "repo",
|
|
410
|
+
env: { GITHUB_REPOSITORY: "from-env/repo" },
|
|
411
|
+
repositoryUrl: "https://github.com/from-url/repo",
|
|
412
|
+
}),
|
|
413
|
+
).toEqual({ owner: "from-context", name: "repo" });
|
|
414
|
+
|
|
415
|
+
expect(
|
|
416
|
+
resolveGitHubRepository({
|
|
417
|
+
env: { GITHUB_REPOSITORY: "from-env/repo" },
|
|
418
|
+
repositoryUrl: "git+https://github.com/from-url/repo.git",
|
|
419
|
+
}),
|
|
420
|
+
).toEqual({ owner: "from-env", name: "repo" });
|
|
421
|
+
|
|
422
|
+
expect(
|
|
423
|
+
resolveGitHubRepository({
|
|
424
|
+
repositoryUrl: "https://github.com/from-url/repo.git",
|
|
425
|
+
packageName: "aws-ops",
|
|
426
|
+
}),
|
|
427
|
+
).toEqual({ owner: "from-url", name: "repo" });
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it("falls back to the package name so synth still has a subject", () => {
|
|
431
|
+
expect(resolveGitHubRepository({ packageName: "aws-ops" })).toEqual({
|
|
432
|
+
owner: "owner",
|
|
433
|
+
name: "aws-ops",
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
`;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { base, blockPackageJson } from "@jaykingson/vite-plus-base/bingo";
|
|
2
2
|
|
|
3
|
+
import { blockCdkApps } from "./blockCdkApps/blockCdkApps.ts";
|
|
3
4
|
import { blockCdkPreflight } from "./blockCdkPreflight/blockCdkPreflight.ts";
|
|
4
5
|
|
|
5
|
-
export { blockCdkPreflight };
|
|
6
|
+
export { blockCdkApps, blockCdkPreflight };
|
|
6
7
|
|
|
7
8
|
export function cdkToolbox() {
|
|
8
9
|
return base.createPreset({
|
|
@@ -11,6 +12,6 @@ export function cdkToolbox() {
|
|
|
11
12
|
},
|
|
12
13
|
// Package scope does not include the base preset, and extensions only apply
|
|
13
14
|
// to blocks already in the preset. Package JSON has to travel with the block.
|
|
14
|
-
blocks: [blockPackageJson, blockCdkPreflight],
|
|
15
|
+
blocks: [blockPackageJson, blockCdkPreflight, blockCdkApps],
|
|
15
16
|
});
|
|
16
17
|
}
|