@empire-builder-kit/nx 1.0.0-rc.46 → 1.0.0-rc.47
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/generators.json +11 -1
- package/package.json +3 -3
- package/src/aws-authority/stage-authority.d.ts +30 -2
- package/src/aws-authority/stage-authority.js +220 -25
- package/src/developer-agent/generator-planning.js +99 -6
- package/src/developer-agent/model.d.ts +7 -3
- package/src/developer-agent/model.js +1 -0
- package/src/developer-agent/operation-registry.d.ts +1 -0
- package/src/developer-agent/operation-registry.js +43 -2
- package/src/developer-agent/planning.js +5 -2
- package/src/developer-agent/preview-changes.js +10 -0
- package/src/developer-agent/validation.js +7 -3
- package/src/developer-agent/workspace-inspection.js +51 -4
- package/src/executors/deployment-plan/deployment-plan.js +3 -0
- package/src/executors/dev-doctor/dev-doctor.d.ts +25 -3
- package/src/executors/dev-doctor/dev-doctor.js +136 -49
- package/src/executors/dev-setup/dev-setup.d.ts +18 -1
- package/src/executors/dev-setup/dev-setup.js +320 -196
- package/src/executors/foundation-preflight/foundation-preflight.js +9 -1
- package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +2 -2
- package/src/executors/infrastructure-plan/infrastructure-plan.js +10 -3
- package/src/executors/local-deploy/local-deploy.d.ts +15 -0
- package/src/executors/local-deploy/local-deploy.js +96 -14
- package/src/executors/sst-lifecycle/logging-preflight.js +12 -1
- package/src/executors/sst-lifecycle/run-sst-command.js +51 -5
- package/src/foundation/cost-estimate.js +1 -1
- package/src/foundation/identity-domain-parent-ready.d.ts +91 -0
- package/src/foundation/identity-domain-parent-ready.js +333 -0
- package/src/foundation/identity-domain.d.ts +94 -0
- package/src/foundation/identity-domain.js +115 -0
- package/src/foundation/index.d.ts +2 -0
- package/src/foundation/index.js +7 -0
- package/src/foundation/preflight.js +17 -1
- package/src/foundation/root-site-readiness.d.ts +27 -0
- package/src/foundation/root-site-readiness.js +78 -0
- package/src/foundation/root-site.d.ts +81 -0
- package/src/foundation/root-site.js +268 -0
- package/src/generators/framework-prerequisites.d.ts +2 -0
- package/src/generators/framework-prerequisites.js +34 -0
- package/src/generators/function/function-registration.d.ts +24 -0
- package/src/generators/function/function-registration.js +66 -0
- package/src/generators/function/function.d.ts +16 -1
- package/src/generators/function/function.js +101 -18
- package/src/generators/function/schema.d.ts +1 -0
- package/src/generators/function/schema.json +6 -0
- package/src/generators/function-access/function-access.d.ts +14 -0
- package/src/generators/function-access/function-access.js +141 -0
- package/src/generators/function-access/schema.d.ts +6 -0
- package/src/generators/function-access/schema.json +25 -0
- package/src/generators/post-generation-install.d.ts +1 -1
- package/src/generators/post-generation-install.js +1 -1
- package/src/generators/preset/dependency-overrides.d.ts +1 -1
- package/src/generators/preset/dependency-overrides.js +1 -1
- package/src/generators/preset/workspace-files-adopter-skills.js +14 -0
- package/src/generators/preset/workspace-files-developer-agent.js +17 -11
- package/src/generators/preset/workspace-files-stage-authority.js +58 -1
- package/src/generators/preset/workspace-files-thin-deploy.d.ts +11 -0
- package/src/generators/preset/workspace-files-thin-deploy.js +47 -4
- package/src/generators/preset/workspace-files-thin-docs.js +33 -5
- package/src/generators/preset/workspace-files.js +207 -13
- package/src/generators/repository-policy/repository-policy.js +2 -1
- package/src/generators/repository-policy/schema.d.ts +2 -0
- package/src/generators/repository-policy/schema.json +7 -2
- package/src/generators/site/built-in-site-documentation-files.d.ts +2 -0
- package/src/generators/site/built-in-site-documentation-files.js +92 -0
- package/src/generators/site/built-in-site-files.d.ts +8 -0
- package/src/generators/site/built-in-site-files.js +40 -0
- package/src/generators/site/built-in-site-infrastructure-files.d.ts +2 -0
- package/src/generators/site/built-in-site-infrastructure-files.js +275 -0
- package/src/generators/site/built-in-site-plan.d.ts +19 -0
- package/src/generators/site/built-in-site-plan.js +65 -0
- package/src/generators/site/built-in-site-project-files.d.ts +3 -0
- package/src/generators/site/built-in-site-project-files.js +258 -0
- package/src/generators/site/built-in-site-script-files.d.ts +2 -0
- package/src/generators/site/built-in-site-script-files.js +306 -0
- package/src/generators/site/built-in-site-shared.d.ts +9 -0
- package/src/generators/site/built-in-site-shared.js +21 -0
- package/src/generators/site/built-in-site-smoke-files.d.ts +2 -0
- package/src/generators/site/built-in-site-smoke-files.js +37 -0
- package/src/generators/site/built-in-site-sst-config-files.d.ts +2 -0
- package/src/generators/site/built-in-site-sst-config-files.js +39 -0
- package/src/generators/site/built-in-site-web-files.d.ts +2 -0
- package/src/generators/site/built-in-site-web-files.js +284 -0
- package/src/generators/site/schema.d.ts +4 -0
- package/src/generators/site/schema.json +20 -0
- package/src/generators/site/site.d.ts +13 -0
- package/src/generators/site/site.js +221 -0
- package/src/generators/slice/built-in-plan-alarm-identity.d.ts +9 -0
- package/src/generators/slice/built-in-plan-alarm-identity.js +8 -1
- package/src/generators/slice/built-in-plan-api-contract-files.js +18 -0
- package/src/generators/slice/built-in-plan-async-work-files.js +18 -0
- package/src/generators/slice/built-in-plan-data-files.js +116 -11
- package/src/generators/slice/built-in-plan-foundation-files.d.ts +12 -0
- package/src/generators/slice/built-in-plan-foundation-files.js +114 -5
- package/src/generators/slice/built-in-plan-frontend-files.js +2 -271
- package/src/generators/slice/built-in-plan-frontend-header-proof.d.ts +6 -0
- package/src/generators/slice/built-in-plan-frontend-header-proof.js +282 -0
- package/src/generators/slice/built-in-plan-infrastructure-files.js +151 -237
- package/src/generators/slice/built-in-plan-key-value-cleanup.js +4 -3
- package/src/generators/slice/built-in-plan-log-group-helpers.d.ts +29 -0
- package/src/generators/slice/built-in-plan-log-group-helpers.js +130 -0
- package/src/generators/slice/built-in-plan-metadata-files.js +21 -4
- package/src/generators/slice/built-in-plan-next-build-authority.d.ts +5 -0
- package/src/generators/slice/built-in-plan-next-build-authority.js +124 -0
- package/src/generators/slice/built-in-plan-operations-files.d.ts +6 -0
- package/src/generators/slice/built-in-plan-operations-files.js +107 -219
- package/src/generators/slice/built-in-plan-performance-files.js +6 -1
- package/src/generators/slice/built-in-plan-reliability-files.js +12 -8
- package/src/generators/slice/built-in-plan-shared.d.ts +1 -1
- package/src/generators/slice/built-in-plan-shared.js +1 -1
- package/src/generators/slice/built-in-plan-sst-config.d.ts +49 -0
- package/src/generators/slice/built-in-plan-sst-config.js +160 -0
- package/src/generators/slice/built-in-plan-testing-files.js +92 -49
- package/src/generators/slice/built-in-plan-verification-files.js +15 -4
- package/src/generators/slice/built-in-plan-web-files.js +65 -0
- package/src/generators/slice/deployed-smoke-diagnostics.d.ts +35 -0
- package/src/generators/slice/deployed-smoke-diagnostics.js +189 -0
- package/src/generators/slice/deployed-smoke-readiness.d.ts +7 -0
- package/src/generators/slice/deployed-smoke-readiness.js +118 -23
- package/src/generators/slice/persistence-contract.js +2 -2
- package/src/generators/slice/pnpm-launch-script.d.ts +13 -0
- package/src/generators/slice/pnpm-launch-script.js +28 -0
- package/src/generators/slice/slice.js +27 -0
- package/src/generators/upgrade/custom-domain-notice.d.ts +19 -0
- package/src/generators/upgrade/custom-domain-notice.js +38 -0
- package/src/generators/upgrade/external-blueprint-compositions.d.ts +84 -0
- package/src/generators/upgrade/external-blueprint-compositions.js +478 -0
- package/src/generators/upgrade/framework-package-upgrade.d.ts +58 -0
- package/src/generators/upgrade/framework-package-upgrade.js +78 -0
- package/src/generators/upgrade/function-authentication-notice.d.ts +29 -0
- package/src/generators/upgrade/function-authentication-notice.js +74 -0
- package/src/generators/upgrade/schema.json +2 -2
- package/src/generators/upgrade/upgrade-plan.d.ts +52 -0
- package/src/generators/upgrade/upgrade-plan.js +406 -0
- package/src/generators/upgrade/upgrade.d.ts +1 -35
- package/src/generators/upgrade/upgrade.js +259 -593
- package/src/generators/workload/workload.js +60 -4
- package/src/git-policy/github-bootstrap.d.ts +6 -5
- package/src/git-policy/github-bootstrap.js +6 -4
- package/src/local-dev/fleet-process.d.ts +9 -2
- package/src/local-dev/fleet-process.js +27 -7
- package/src/local-dev/gateway-daemon.d.ts +1 -1
- package/src/local-dev/gateway-daemon.js +6 -4
- package/src/local-dev/portless.d.ts +5 -0
- package/src/local-dev/portless.js +5 -0
- package/src/local-dev/process-group.d.ts +10 -0
- package/src/local-dev/process-group.js +33 -0
- package/src/local-dev/tls.js +31 -2
- package/src/local-dev/trust-store.d.ts +42 -0
- package/src/local-dev/trust-store.js +87 -0
- package/src/ownership/composition.d.ts +7 -0
- package/src/ownership/composition.js +64 -56
- package/src/ownership/index.d.ts +1 -0
- package/src/ownership/index.js +1 -0
- package/src/ownership/record.d.ts +19 -0
- package/src/ownership/record.js +26 -2
- package/src/ownership/site-record.d.ts +18 -0
- package/src/ownership/site-record.js +105 -0
- package/src/repository-policy/deployment-plan.d.ts +3 -0
- package/src/repository-policy/deployment-plan.js +33 -4
- package/src/repository-policy/index.d.ts +1 -0
- package/src/repository-policy/index.js +1 -0
- package/src/repository-policy/policy.d.ts +13 -1
- package/src/repository-policy/policy.js +55 -1
- package/src/repository-policy/public-dns.d.ts +65 -0
- package/src/repository-policy/public-dns.js +168 -0
- package/src/schemas/generated-ownership-v2.json +6 -0
- package/src/schemas/repository-policy-v1.json +67 -1
- package/src/supply-chain/blueprint-trust-git.js +24 -0
- package/src/supply-chain/blueprint-verification-authority.js +21 -3
- package/src/supply-chain/generated-blueprint-trust-command.js +15 -0
- package/src/work-markers/work-markers.js +4 -1
- package/src/workspace-deployment/ownership.d.ts +15 -0
- package/src/workspace-deployment/ownership.js +19 -3
|
@@ -4,10 +4,17 @@ exports.renderProductInfrastructureFiles = renderProductInfrastructureFiles;
|
|
|
4
4
|
const built_in_plan_alarm_identity_js_1 = require("./built-in-plan-alarm-identity.js");
|
|
5
5
|
const built_in_plan_shared_js_1 = require("./built-in-plan-shared.js");
|
|
6
6
|
const built_in_plan_key_value_retention_infrastructure_js_1 = require("./built-in-plan-key-value-retention-infrastructure.js");
|
|
7
|
+
const built_in_plan_log_group_helpers_js_1 = require("./built-in-plan-log-group-helpers.js");
|
|
8
|
+
const built_in_plan_next_build_authority_js_1 = require("./built-in-plan-next-build-authority.js");
|
|
7
9
|
/** @internal */
|
|
8
10
|
function renderProductInfrastructureFiles(name, pascalName, workspace, protectedRuntimeStages = ['staging', 'production'], sql = false, network = sql) {
|
|
9
11
|
const identifierPrefix = (0, built_in_plan_shared_js_1.lowerCamelIdentifier)(pascalName);
|
|
10
12
|
const recordExportWorkflowName = (0, built_in_plan_shared_js_1.stableGeneratedName)(40, name);
|
|
13
|
+
const logHelpers = (0, built_in_plan_log_group_helpers_js_1.renderManagedLogHelpers)({
|
|
14
|
+
dataProtectionAlarm: (0, built_in_plan_alarm_identity_js_1.sliceAlarmIdentity)(name, 'data-protection-findings'),
|
|
15
|
+
name,
|
|
16
|
+
workspace,
|
|
17
|
+
});
|
|
11
18
|
const files = {
|
|
12
19
|
'infra/event-subscriptions.ts': `/**
|
|
13
20
|
* Same-Slice routing reads only the Slice's own seeded EventContractSchema and
|
|
@@ -310,120 +317,7 @@ export function createVpcRouteFunctionMaterializer(input: {
|
|
|
310
317
|
return Object.freeze({ route, transform });
|
|
311
318
|
}
|
|
312
319
|
`,
|
|
313
|
-
'infra/next-build-authority.ts':
|
|
314
|
-
chmodSync,
|
|
315
|
-
existsSync,
|
|
316
|
-
lstatSync,
|
|
317
|
-
readdirSync,
|
|
318
|
-
realpathSync,
|
|
319
|
-
unlinkSync,
|
|
320
|
-
} from 'node:fs';
|
|
321
|
-
import { join, relative, resolve } from 'node:path';
|
|
322
|
-
|
|
323
|
-
const maximumEntries = 65_536;
|
|
324
|
-
const maximumDepth = 64;
|
|
325
|
-
const maximumFinderMetadataFiles = 256;
|
|
326
|
-
const maximumFinderMetadataBytes = 1_048_576n;
|
|
327
|
-
|
|
328
|
-
// SST 4.17.1 awaits FunctionArgs.hook.postbuild after Runtime.Build has
|
|
329
|
-
// materialized the exact directory that its Lambda zipper consumes. Finder
|
|
330
|
-
// metadata removed only from OpenNext's earlier output can be recreated or
|
|
331
|
-
// copied through package-local node_modules before that boundary. Sanitize the
|
|
332
|
-
// final derived bundle here so the bytes reviewed by the infrastructure plan
|
|
333
|
-
// are the bytes SST packages.
|
|
334
|
-
export function removeFinderMetadataFromBuiltFunction(rootPath: string): number {
|
|
335
|
-
const root = resolve(rootPath);
|
|
336
|
-
const rootIdentity = lstatSync(root, { bigint: true });
|
|
337
|
-
if (
|
|
338
|
-
!rootIdentity.isDirectory() ||
|
|
339
|
-
rootIdentity.isSymbolicLink() ||
|
|
340
|
-
realpathSync(root) !== root
|
|
341
|
-
) {
|
|
342
|
-
throw new Error('The built Function root has an invalid identity.');
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const pendingDirectories = [{ depth: 0, path: root }];
|
|
346
|
-
let observedEntries = 0;
|
|
347
|
-
let removedFinderMetadata = 0;
|
|
348
|
-
while (pendingDirectories.length > 0) {
|
|
349
|
-
const current = pendingDirectories.pop();
|
|
350
|
-
if (!current) break;
|
|
351
|
-
if (current.depth > maximumDepth) {
|
|
352
|
-
throw new Error('The built Function tree exceeds its depth bound.');
|
|
353
|
-
}
|
|
354
|
-
for (const entry of readdirSync(current.path, { withFileTypes: true }).sort(
|
|
355
|
-
(left, right) =>
|
|
356
|
-
left.name < right.name ? -1 : left.name > right.name ? 1 : 0,
|
|
357
|
-
)) {
|
|
358
|
-
observedEntries += 1;
|
|
359
|
-
if (observedEntries > maximumEntries) {
|
|
360
|
-
throw new Error('The built Function tree exceeds its entry bound.');
|
|
361
|
-
}
|
|
362
|
-
const entryPath = join(current.path, entry.name);
|
|
363
|
-
const identity = lstatSync(entryPath, { bigint: true });
|
|
364
|
-
if (entry.name === '.DS_Store') {
|
|
365
|
-
removedFinderMetadata += 1;
|
|
366
|
-
if (
|
|
367
|
-
removedFinderMetadata > maximumFinderMetadataFiles ||
|
|
368
|
-
!identity.isFile() ||
|
|
369
|
-
identity.isSymbolicLink() ||
|
|
370
|
-
identity.nlink !== 1n ||
|
|
371
|
-
identity.size > maximumFinderMetadataBytes
|
|
372
|
-
) {
|
|
373
|
-
throw new Error(
|
|
374
|
-
'The built Function Finder metadata has an invalid identity.',
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
unlinkSync(entryPath);
|
|
378
|
-
if (existsSync(entryPath)) {
|
|
379
|
-
throw new Error(
|
|
380
|
-
'The built Function Finder metadata was not removed.',
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
if (identity.isDirectory() && !identity.isSymbolicLink()) {
|
|
386
|
-
const confined = relative(root, entryPath);
|
|
387
|
-
if (
|
|
388
|
-
confined === '..' ||
|
|
389
|
-
confined.startsWith('../') ||
|
|
390
|
-
resolve(root, confined) !== entryPath
|
|
391
|
-
) {
|
|
392
|
-
throw new Error('The built Function entry escapes its root.');
|
|
393
|
-
}
|
|
394
|
-
pendingDirectories.push({ depth: current.depth + 1, path: entryPath });
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
// Finder can recreate its metadata in the interval between this hook and
|
|
398
|
-
// SST's asynchronous glob/archive pass. On macOS, close that exact race by
|
|
399
|
-
// removing only the owner's write bit from each completed derived
|
|
400
|
-
// directory. The generated build wrapper restores it before the next
|
|
401
|
-
// OpenNext build. Group/other permission bits remain unchanged.
|
|
402
|
-
if (process.platform === 'darwin') {
|
|
403
|
-
const currentIdentity = lstatSync(current.path, { bigint: true });
|
|
404
|
-
if (
|
|
405
|
-
!currentIdentity.isDirectory() ||
|
|
406
|
-
currentIdentity.isSymbolicLink()
|
|
407
|
-
) {
|
|
408
|
-
throw new Error('The built Function directory changed identity.');
|
|
409
|
-
}
|
|
410
|
-
chmodSync(
|
|
411
|
-
current.path,
|
|
412
|
-
Number((currentIdentity.mode & 0o7_777n) & ~0o200n),
|
|
413
|
-
);
|
|
414
|
-
if ((lstatSync(current.path, { bigint: true }).mode & 0o200n) !== 0n) {
|
|
415
|
-
throw new Error('The built Function directory was not sealed.');
|
|
416
|
-
}
|
|
417
|
-
if (existsSync(join(current.path, '.DS_Store'))) {
|
|
418
|
-
throw new Error(
|
|
419
|
-
'The built Function Finder metadata raced its final seal.',
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return removedFinderMetadata;
|
|
425
|
-
}
|
|
426
|
-
`,
|
|
320
|
+
'infra/next-build-authority.ts': (0, built_in_plan_next_build_authority_js_1.renderNextBuildAuthority)(),
|
|
427
321
|
'infra/deployment-receipt.ts': `export interface SuccessfulDeploymentReceiptExpectation {
|
|
428
322
|
account: string;
|
|
429
323
|
project: string;
|
|
@@ -493,6 +387,7 @@ export function validateSuccessfulDeploymentReceipt(
|
|
|
493
387
|
createRouterOriginProofInjection,
|
|
494
388
|
resolveObservabilityPolicy,
|
|
495
389
|
${sql ? ' provisionDatabaseBindings,\n' : ''}\
|
|
390
|
+
${sql ? ' validateDatabaseBindings,\n' : ''}\
|
|
496
391
|
} from '@empire-builder-kit/nx/foundation';
|
|
497
392
|
import * as random from '@pulumi/random';
|
|
498
393
|
import { createHash } from 'node:crypto';
|
|
@@ -542,9 +437,11 @@ import { backgroundWorkSchedules } from './background-work.js';
|
|
|
542
437
|
import { ConfigurationDeclarations } from '../configuration/declarations.js';
|
|
543
438
|
import { assertAsyncAdapterDeploymentReady } from '../async/recovery-adapters.js';
|
|
544
439
|
import {
|
|
440
|
+
foundationSliceWebUrl,
|
|
545
441
|
getFoundationInfrastructure,
|
|
546
442
|
${sql ? ' registerProductMigration,\n' : ''}\
|
|
547
443
|
registerProductRetention,
|
|
444
|
+
type SlicePublicDomain,
|
|
548
445
|
} from './foundation.js';
|
|
549
446
|
import { createVpcRouteFunctionMaterializer } from './route-function-materialization.js';
|
|
550
447
|
import { removeFinderMetadataFromBuiltFunction } from './next-build-authority.js';
|
|
@@ -669,56 +566,36 @@ function protectedPerformanceDeploymentAuthority(input: {
|
|
|
669
566
|
});
|
|
670
567
|
}
|
|
671
568
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function managedLogContract(component: string, resource?: string) {
|
|
696
|
-
return createManagedLogGroupContract({
|
|
697
|
-
component,
|
|
698
|
-
retentionInDays: observability.protectedRetentionDays,
|
|
699
|
-
...(resource ? { resource } : {}),
|
|
700
|
-
slice: '${name}',
|
|
701
|
-
stage: $app.stage,
|
|
702
|
-
workspace: '${workspace}',
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
function operationalAlarmDescription(input: {
|
|
707
|
-
businessSymptom: string;
|
|
708
|
-
id: string;
|
|
709
|
-
runbook: string;
|
|
710
|
-
}) {
|
|
711
|
-
return JSON.stringify({
|
|
712
|
-
businessSymptom: input.businessSymptom,
|
|
713
|
-
id: input.id,
|
|
714
|
-
owner: '${(0, built_in_plan_alarm_identity_js_1.sliceAlarmOwnership)(name).owner}',
|
|
715
|
-
route: '${(0, built_in_plan_alarm_identity_js_1.sliceAlarmOwnership)(name).route}',
|
|
716
|
-
runbook: input.runbook,
|
|
717
|
-
schemaVersion: 1,
|
|
718
|
-
slice: '${name}',
|
|
719
|
-
});
|
|
569
|
+
${sql
|
|
570
|
+
? `/**
|
|
571
|
+
* The optional EBK_DATABASE_CREDENTIAL_GENERATION names the generated database
|
|
572
|
+
* credential generation for every provisioned identifier of this Slice. Each
|
|
573
|
+
* identifier's next bootstrap rotates both runtime roles once when it differs
|
|
574
|
+
* from the stored generation. Unset or empty keeps the framework default.
|
|
575
|
+
*/
|
|
576
|
+
function databaseCredentialRotationTokens():
|
|
577
|
+
| Readonly<Record<string, string>>
|
|
578
|
+
| undefined {
|
|
579
|
+
const generation =
|
|
580
|
+
process.env.EBK_DATABASE_CREDENTIAL_GENERATION?.trim() ?? '';
|
|
581
|
+
if (generation === '') return undefined;
|
|
582
|
+
if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(generation)) {
|
|
583
|
+
throw new Error(
|
|
584
|
+
'EBK_DATABASE_CREDENTIAL_GENERATION must be 1 to 63 lowercase letters, digits, or hyphens that start with a letter or digit, or unset.',
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
return Object.fromEntries(
|
|
588
|
+
validateDatabaseBindings(databaseBindings, {
|
|
589
|
+
slice: '${name}',
|
|
590
|
+
}).provisioned.map((database) => [database, generation]),
|
|
591
|
+
);
|
|
720
592
|
}
|
|
721
593
|
|
|
594
|
+
`
|
|
595
|
+
: ''}\
|
|
596
|
+
${logHelpers.managedLogGroup}
|
|
597
|
+
${logHelpers.managedLogContract}
|
|
598
|
+
${logHelpers.operationalAlarmDescription}
|
|
722
599
|
// sst.aws.Queue has no name member: QueueName dimensions read the physical
|
|
723
600
|
// aws.sqs.Queue name through nodes (nodes.queue.id is the queue URL).
|
|
724
601
|
function physicalQueueName<Q extends { nodes: { queue: { name: unknown } } }>(
|
|
@@ -727,71 +604,15 @@ function physicalQueueName<Q extends { nodes: { queue: { name: unknown } } }>(
|
|
|
727
604
|
return queue.nodes.queue.name;
|
|
728
605
|
}
|
|
729
606
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
)
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
{
|
|
740
|
-
logGroupName,
|
|
741
|
-
policyDocument: JSON.stringify(contract.dataProtectionPolicy),
|
|
742
|
-
},
|
|
743
|
-
{ dependsOn },
|
|
744
|
-
);
|
|
745
|
-
const alarm = new aws.cloudwatch.MetricAlarm(
|
|
746
|
-
logicalName + 'DataProtectionFindings',
|
|
747
|
-
{
|
|
748
|
-
alarmActions: [alertTopicArn],
|
|
749
|
-
alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'data-protection-findings', ' ')}),
|
|
750
|
-
comparisonOperator: 'GreaterThanOrEqualToThreshold',
|
|
751
|
-
dimensions: { LogGroupName: logGroupName },
|
|
752
|
-
evaluationPeriods: 1,
|
|
753
|
-
metricName: 'LogEventsWithFindings',
|
|
754
|
-
namespace: 'AWS/Logs',
|
|
755
|
-
period: 300,
|
|
756
|
-
statistic: 'Sum',
|
|
757
|
-
threshold: 1,
|
|
758
|
-
treatMissingData: 'notBreaching',
|
|
759
|
-
},
|
|
760
|
-
{ dependsOn: [policy] },
|
|
761
|
-
);
|
|
762
|
-
return { alarm, policy };
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
function lambdaLogging(logGroupName: any, functionName?: any) {
|
|
766
|
-
return {
|
|
767
|
-
logging: { format: 'json' as const, logGroup: logGroupName },
|
|
768
|
-
transform: {
|
|
769
|
-
function(args: Record<string, any>): undefined {
|
|
770
|
-
if (functionName) args.name = functionName;
|
|
771
|
-
args.environment = $output(args.environment ?? {}).apply(
|
|
772
|
-
(environment: Record<string, any>) => ({
|
|
773
|
-
...environment,
|
|
774
|
-
variables: $output(environment.variables ?? {}).apply(
|
|
775
|
-
(variables: Record<string, any>) => ({
|
|
776
|
-
...variables,
|
|
777
|
-
EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
|
|
778
|
-
String(observability.routineSuccessSampleRate),
|
|
779
|
-
}),
|
|
780
|
-
),
|
|
781
|
-
}),
|
|
782
|
-
);
|
|
783
|
-
args.loggingConfig = {
|
|
784
|
-
applicationLogLevel: 'TRACE',
|
|
785
|
-
logFormat: 'JSON',
|
|
786
|
-
logGroup: logGroupName,
|
|
787
|
-
systemLogLevel: observability.systemLogLevel,
|
|
788
|
-
};
|
|
789
|
-
},
|
|
790
|
-
},
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
export function product() {
|
|
607
|
+
${logHelpers.managedLogDataProtection}
|
|
608
|
+
${logHelpers.lambdaLogging}
|
|
609
|
+
export function product(publicDomain?: SlicePublicDomain) {
|
|
610
|
+
${sql
|
|
611
|
+
? ` // Refuse a malformed credential generation before any product resource
|
|
612
|
+
// registers.
|
|
613
|
+
const databaseRotationTokens = databaseCredentialRotationTokens();
|
|
614
|
+
`
|
|
615
|
+
: ''}\
|
|
795
616
|
const backgroundSchedules = backgroundWorkSchedules(
|
|
796
617
|
backgroundWorkPolicy,
|
|
797
618
|
$dev ? 'development' : $app.stage,
|
|
@@ -1051,6 +872,9 @@ ${sql
|
|
|
1051
872
|
${sql
|
|
1052
873
|
? ` const databaseProvisions = provisionDatabaseBindings(foundation, {
|
|
1053
874
|
bindings: databaseBindings,
|
|
875
|
+
...(databaseRotationTokens === undefined
|
|
876
|
+
? {}
|
|
877
|
+
: { rotationTokens: databaseRotationTokens }),
|
|
1054
878
|
slice: '${name}',
|
|
1055
879
|
});
|
|
1056
880
|
const databaseProvision = databaseProvisions.bindings.primary;
|
|
@@ -1060,6 +884,15 @@ ${sql
|
|
|
1060
884
|
const authClient = foundation.userPool.addClient('${pascalName}WebAuthClient', {
|
|
1061
885
|
transform: {
|
|
1062
886
|
client: {
|
|
887
|
+
// Sign-in is server-side password and refresh-token auth only. SST
|
|
888
|
+
// merges this object over its client defaults, which enable the
|
|
889
|
+
// implicit and code flows with a placeholder callback, so all four
|
|
890
|
+
// OAuth fields are set explicitly: the provider leaves an omitted
|
|
891
|
+
// field at its current value on an existing client.
|
|
892
|
+
allowedOauthFlows: [],
|
|
893
|
+
allowedOauthFlowsUserPoolClient: false,
|
|
894
|
+
allowedOauthScopes: [],
|
|
895
|
+
callbackUrls: [],
|
|
1063
896
|
explicitAuthFlows: [
|
|
1064
897
|
'ALLOW_USER_PASSWORD_AUTH',
|
|
1065
898
|
'ALLOW_REFRESH_TOKEN_AUTH',
|
|
@@ -1230,12 +1063,32 @@ ${''}\
|
|
|
1230
1063
|
});
|
|
1231
1064
|
const api = new sst.aws.ApiGatewayV2('${pascalName}Api', {
|
|
1232
1065
|
${network ? ' ...(performanceDeploymentAuthority ? { vpc: foundation.vpc } : {}),\n' : ''}\
|
|
1066
|
+
// A bound stage maps this API under /${name} on the
|
|
1067
|
+
// Foundation's api.<root> domain, read by name. A later per-Slice API
|
|
1068
|
+
// host is an additive swap of nameId for name on this same input, with
|
|
1069
|
+
// the Slice owning its certificate and records; no consumer reads the
|
|
1070
|
+
// path shape of apiUrl.
|
|
1071
|
+
...(publicDomain
|
|
1072
|
+
? { domain: { nameId: publicDomain.apiDomainName, path: '${name}' } }
|
|
1073
|
+
: {}),
|
|
1233
1074
|
transform: {
|
|
1075
|
+
...(publicDomain
|
|
1076
|
+
? {
|
|
1077
|
+
// A custom-domain stage serves its API only on api.<root>.
|
|
1078
|
+
api(args: Record<string, unknown>) {
|
|
1079
|
+
args.disableExecuteApiEndpoint = true;
|
|
1080
|
+
},
|
|
1081
|
+
}
|
|
1082
|
+
: {}),
|
|
1234
1083
|
route: {
|
|
1235
1084
|
handler: vpcRouteFunctionMaterializer.transform,
|
|
1236
1085
|
},
|
|
1237
1086
|
},
|
|
1238
1087
|
});
|
|
1088
|
+
// SST's mapped URL ends in '/'. Generated consumers join operation paths
|
|
1089
|
+
// onto a base without one; unbound, this is the unchanged execute-api
|
|
1090
|
+
// origin.
|
|
1091
|
+
const apiUrl = api.url.apply((url: string) => url.replace(/\\/$/, ''));
|
|
1239
1092
|
const routeInVpc = (
|
|
1240
1093
|
rawRoute: string,
|
|
1241
1094
|
handler: { handler: string } & Record<string, any>,
|
|
@@ -1271,7 +1124,14 @@ ${network ? ' ...(performanceDeploymentAuthority ? { vpc: foundation.vpc } :
|
|
|
1271
1124
|
},
|
|
1272
1125
|
},
|
|
1273
1126
|
});
|
|
1274
|
-
return {
|
|
1127
|
+
return {
|
|
1128
|
+
api,
|
|
1129
|
+
// The service routes keep the API's mapping path, which API
|
|
1130
|
+
// Gateway strips before matching a route.
|
|
1131
|
+
apiPathPrefix: publicDomain ? '/${name}' : '',
|
|
1132
|
+
originProof: originProof.result,
|
|
1133
|
+
router,
|
|
1134
|
+
};
|
|
1275
1135
|
})()
|
|
1276
1136
|
: undefined;
|
|
1277
1137
|
const performanceDeploymentBinding =
|
|
@@ -1589,7 +1449,7 @@ ${' ...keyValue.environment,\n'}\
|
|
|
1589
1449
|
String(observability.routineSuccessSampleRate),
|
|
1590
1450
|
...machineAuthorization.proof.environment,
|
|
1591
1451
|
AUTH_MACHINE_PROBE_URL:
|
|
1592
|
-
$interpolate\`\${
|
|
1452
|
+
$interpolate\`\${apiUrl}\${${identifierPrefix}MachineAuthorizationProof.path}\`,
|
|
1593
1453
|
EBK_STAGE: $app.stage,
|
|
1594
1454
|
},
|
|
1595
1455
|
handler: 'authorization/machine-authorization-proof.handler',
|
|
@@ -1665,6 +1525,49 @@ ${''}\
|
|
|
1665
1525
|
maximumRetryAttempts: 2,
|
|
1666
1526
|
},
|
|
1667
1527
|
);
|
|
1528
|
+
// Generated Functions require a signed-in caller unless their composition
|
|
1529
|
+
// records them as anonymous. One JWT authorizer serves every signed-in
|
|
1530
|
+
// Function on this API and exists only once one registers. API Gateway
|
|
1531
|
+
// checks the Cognito issuer, the web or machine client id and the token
|
|
1532
|
+
// lifetime; the Function runtime then requires an access token. Each route
|
|
1533
|
+
// takes it through its Route transform, so a preview keeps the route while
|
|
1534
|
+
// the authorizer id is still unknown.
|
|
1535
|
+
let functionAuthorizer: any;
|
|
1536
|
+
const functionAccess = () => {
|
|
1537
|
+
functionAuthorizer ??= api.addAuthorizer({
|
|
1538
|
+
name: 'FunctionAccess',
|
|
1539
|
+
jwt: {
|
|
1540
|
+
issuer: $interpolate\`https://cognito-idp.\${aws.getRegionOutput({}).name}.amazonaws.com/\${foundation.userPool.id}\`,
|
|
1541
|
+
audiences: $output([
|
|
1542
|
+
authClient.id,
|
|
1543
|
+
machineAuthorization.acceptedClientIdsJson,
|
|
1544
|
+
]).apply((ids: unknown[]): string[] => {
|
|
1545
|
+
const [webClientId, machineClientIds] = ids;
|
|
1546
|
+
const parsed: unknown =
|
|
1547
|
+
typeof machineClientIds === 'string'
|
|
1548
|
+
? JSON.parse(machineClientIds)
|
|
1549
|
+
: undefined;
|
|
1550
|
+
if (
|
|
1551
|
+
ids.length !== 2 ||
|
|
1552
|
+
typeof webClientId !== 'string' ||
|
|
1553
|
+
webClientId.length === 0 ||
|
|
1554
|
+
!Array.isArray(parsed) ||
|
|
1555
|
+
parsed.length < 1 ||
|
|
1556
|
+
parsed.length > 2 ||
|
|
1557
|
+
new Set(parsed).size !== parsed.length ||
|
|
1558
|
+
parsed.some((id) => typeof id !== 'string' || id.length === 0)
|
|
1559
|
+
) {
|
|
1560
|
+
throw new Error(
|
|
1561
|
+
'Function access requires the generated web and machine client ids.',
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
return [webClientId, ...(parsed as string[])];
|
|
1565
|
+
}),
|
|
1566
|
+
},
|
|
1567
|
+
});
|
|
1568
|
+
return { authorizationType: 'JWT', authorizerId: functionAuthorizer.id };
|
|
1569
|
+
};
|
|
1570
|
+
void functionAccess; // Read by signed-in Function registrations below.
|
|
1668
1571
|
// <ebk:function-registrations:start>
|
|
1669
1572
|
// <ebk:function-registrations:end>
|
|
1670
1573
|
|
|
@@ -2579,7 +2482,7 @@ ${' ...keyValue.environment,\n'}\
|
|
|
2579
2482
|
EBK_SECURE_COOKIES: process.env.EBK_SECURE_COOKIES ?? '',
|
|
2580
2483
|
EVENT_BUS_NAME: foundation.discovery.eventBusName,
|
|
2581
2484
|
...runtimeConfigurationEnvironment,
|
|
2582
|
-
NEXT_PUBLIC_API_URL:
|
|
2485
|
+
NEXT_PUBLIC_API_URL: apiUrl,
|
|
2583
2486
|
},
|
|
2584
2487
|
link: [keyValue.link, ${sql ? 'database, foundation.eventBus, ' : ''}foundation.userPool],
|
|
2585
2488
|
path: 'web',
|
|
@@ -2647,6 +2550,9 @@ ${sql ? ' vpc: foundation.vpc,\n' : ''}\
|
|
|
2647
2550
|
}, configurationDeployment
|
|
2648
2551
|
? { dependsOn: [configurationDeployment] }
|
|
2649
2552
|
: {});
|
|
2553
|
+
// Under a custom domain SST's web.url names the wildcard alias host (see
|
|
2554
|
+
// foundationSliceWebUrl). sst dev keeps its local development URL.
|
|
2555
|
+
const webUrl = $dev ? web.url : foundationSliceWebUrl(foundation.discovery);
|
|
2650
2556
|
if (performanceIngress) {
|
|
2651
2557
|
for (const path of [
|
|
2652
2558
|
'/${name}/__ebk/performance/api-lambda',
|
|
@@ -2655,7 +2561,7 @@ ${sql ? ' vpc: foundation.vpc,\n' : ''}\
|
|
|
2655
2561
|
'/${name}/__ebk/performance/database',
|
|
2656
2562
|
'/${name}/__ebk/performance/database/cleanup',
|
|
2657
2563
|
]) {
|
|
2658
|
-
performanceIngress.router.route(path,
|
|
2564
|
+
performanceIngress.router.route(path, webUrl, {
|
|
2659
2565
|
connectionAttempts: 1,
|
|
2660
2566
|
connectionTimeout: '3 seconds',
|
|
2661
2567
|
readTimeout: '30 seconds',
|
|
@@ -3170,6 +3076,10 @@ ${''}\
|
|
|
3170
3076
|
treatMissingData: 'breaching',
|
|
3171
3077
|
},
|
|
3172
3078
|
);
|
|
3079
|
+
// Every cleanup run reports 1 when it could not complete a full inventory.
|
|
3080
|
+
// Minimum alarms only when no run in an hour converged; three hours absorb
|
|
3081
|
+
// the rescan that follows one interrupted run (a resumed scan must still
|
|
3082
|
+
// read the whole collection from the start before it can converge).
|
|
3173
3083
|
const inboxCleanupBacklogAlarm = new aws.cloudwatch.MetricAlarm(
|
|
3174
3084
|
'${pascalName}InboxCleanupBacklog',
|
|
3175
3085
|
{
|
|
@@ -3183,12 +3093,12 @@ ${''}\
|
|
|
3183
3093
|
Slice: '${name}',
|
|
3184
3094
|
Stage: $app.stage,
|
|
3185
3095
|
},
|
|
3186
|
-
evaluationPeriods:
|
|
3187
|
-
metricName: '
|
|
3096
|
+
evaluationPeriods: 3,
|
|
3097
|
+
metricName: 'InboxCleanupContinuationRequired',
|
|
3188
3098
|
name: '${name}-' + $app.stage + '-inbox-cleanup-backlog',
|
|
3189
3099
|
namespace: 'EBK/Async',
|
|
3190
3100
|
period: 3600,
|
|
3191
|
-
statistic: '
|
|
3101
|
+
statistic: 'Minimum',
|
|
3192
3102
|
threshold: 1,
|
|
3193
3103
|
treatMissingData: 'notBreaching',
|
|
3194
3104
|
},
|
|
@@ -3220,6 +3130,8 @@ ${''}\
|
|
|
3220
3130
|
treatMissingData: 'notBreaching',
|
|
3221
3131
|
},
|
|
3222
3132
|
);
|
|
3133
|
+
// Same per-run continuation signal and three-hour Minimum as the inbox
|
|
3134
|
+
// cleanup alarm; expiry shares that run's four-minute budget.
|
|
3223
3135
|
const performanceLoadCleanupBacklogAlarm =
|
|
3224
3136
|
new aws.cloudwatch.MetricAlarm(
|
|
3225
3137
|
'${pascalName}PerformanceLoadCleanupBacklog',
|
|
@@ -3234,15 +3146,15 @@ ${''}\
|
|
|
3234
3146
|
Slice: '${name}',
|
|
3235
3147
|
Stage: $app.stage,
|
|
3236
3148
|
},
|
|
3237
|
-
evaluationPeriods:
|
|
3238
|
-
metricName: '
|
|
3149
|
+
evaluationPeriods: 3,
|
|
3150
|
+
metricName: 'PerformanceLoadCleanupContinuationRequired',
|
|
3239
3151
|
name:
|
|
3240
3152
|
'${name}-' +
|
|
3241
3153
|
$app.stage +
|
|
3242
3154
|
'-performance-load-cleanup-backlog',
|
|
3243
3155
|
namespace: 'EBK/Performance',
|
|
3244
3156
|
period: 3600,
|
|
3245
|
-
statistic: '
|
|
3157
|
+
statistic: 'Minimum',
|
|
3246
3158
|
threshold: 1,
|
|
3247
3159
|
treatMissingData: 'notBreaching',
|
|
3248
3160
|
},
|
|
@@ -3330,6 +3242,7 @@ ${''}\
|
|
|
3330
3242
|
}) : undefined;
|
|
3331
3243
|
return {
|
|
3332
3244
|
api,
|
|
3245
|
+
apiUrl,
|
|
3333
3246
|
asyncInboxCleanup,
|
|
3334
3247
|
dataExportCleanupDeadlineAlarm,
|
|
3335
3248
|
dataExportCleanupErrorAlarm,
|
|
@@ -3389,6 +3302,7 @@ ${' keyValue,\n'}\
|
|
|
3389
3302
|
machineAuthorization,
|
|
3390
3303
|
machineAuthorizationProof,
|
|
3391
3304
|
web,
|
|
3305
|
+
webUrl,
|
|
3392
3306
|
// <ebk:composition-outputs:start>
|
|
3393
3307
|
// <ebk:composition-outputs:end>
|
|
3394
3308
|
};
|
|
@@ -45,11 +45,12 @@ export function createInboxCleanupHandler(dependencies: Dependencies) {
|
|
|
45
45
|
const inbox = await cleanupProviderInbox(store, new Date(dependencies.now()).toISOString(), dependencies.now, deadline);
|
|
46
46
|
const expired = await performance.expire({ deadline });
|
|
47
47
|
await report();
|
|
48
|
+
// The cleanup backlog alarms read these per-run continuation signals.
|
|
48
49
|
emit('InboxCleanupContinuationRequired', 'EBK/Async', inbox.continuationRequired ? 1 : 0);
|
|
49
50
|
emit('PerformanceLoadCleanupContinuationRequired', 'EBK/Performance', expired.continuationRequired ? 1 : 0);
|
|
50
|
-
// A page is not a global count
|
|
51
|
-
//
|
|
52
|
-
|
|
51
|
+
// A page is not a global count, so no backlog count is emitted. This
|
|
52
|
+
// zero marks a complete expiry inventory only; no alarm reads it, but
|
|
53
|
+
// the seeded testing/async-handlers.spec.ts asserts it.
|
|
53
54
|
if (expired.completeScan) emit('PerformanceLoadCleanupBacklog', 'EBK/Performance', 0);
|
|
54
55
|
if (reportFailure !== undefined) throw reportFailure;
|
|
55
56
|
if (reported > 0 || pendingReports) throw new Error('performance-load-cleanup-deadline-breached');
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generated managed log-group helpers. A Product Slice's infra/product.ts
|
|
3
|
+
* and the root site's infra/site.ts carry the same functions, so every managed
|
|
4
|
+
* log group gets the same contract, data protection policy and findings alarm.
|
|
5
|
+
*/
|
|
6
|
+
export interface ManagedLogHelperInput {
|
|
7
|
+
/** The Slice name, or the root site's reserved name. */
|
|
8
|
+
name: string;
|
|
9
|
+
workspace: string;
|
|
10
|
+
/** The identity of each group's data-protection findings alarm. */
|
|
11
|
+
dataProtectionAlarm: {
|
|
12
|
+
businessSymptom: string;
|
|
13
|
+
id: string;
|
|
14
|
+
runbook: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Each helper's generated TypeScript source, ending with a newline. The caller
|
|
19
|
+
* places them: `managedLogGroup` calls `managedLogContract` and
|
|
20
|
+
* `managedLogDataProtection`, whose alarm description calls
|
|
21
|
+
* `operationalAlarmDescription`; `lambdaLogging` stands alone.
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderManagedLogHelpers(input: ManagedLogHelperInput): {
|
|
24
|
+
lambdaLogging: string;
|
|
25
|
+
managedLogContract: string;
|
|
26
|
+
managedLogDataProtection: string;
|
|
27
|
+
managedLogGroup: string;
|
|
28
|
+
operationalAlarmDescription: string;
|
|
29
|
+
};
|