@aws-blocks/core 0.3.0 → 0.5.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 +25 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +32 -0
- package/dist/api.test.js +22 -0
- package/dist/bb-utils.d.ts +1 -0
- package/dist/bb-utils.d.ts.map +1 -1
- package/dist/bb-utils.js +3 -0
- package/dist/cdk/apigateway-account.d.ts +33 -0
- package/dist/cdk/apigateway-account.d.ts.map +1 -0
- package/dist/cdk/apigateway-account.js +60 -0
- package/dist/cdk/blocks-backend.d.ts +11 -0
- package/dist/cdk/blocks-backend.d.ts.map +1 -1
- package/dist/cdk/blocks-backend.js +72 -13
- package/dist/cdk/blocks-backend.test.js +88 -1
- package/dist/cdk/blocks-defaults.d.ts +76 -1
- package/dist/cdk/blocks-defaults.d.ts.map +1 -1
- package/dist/cdk/blocks-defaults.js +17 -1
- package/dist/cdk/blocks-defaults.test.js +17 -0
- package/dist/cdk/blocks-stack.test.js +44 -3
- package/dist/cdk/compute/compute-registry.d.ts +19 -0
- package/dist/cdk/compute/compute-registry.d.ts.map +1 -0
- package/dist/cdk/compute/compute-registry.js +38 -0
- package/dist/cdk/compute/compute.d.ts +82 -2
- package/dist/cdk/compute/compute.d.ts.map +1 -1
- package/dist/cdk/compute/compute.js +64 -2
- package/dist/cdk/compute/default-compute-factory.d.ts +1 -0
- package/dist/cdk/compute/default-compute-factory.d.ts.map +1 -1
- package/dist/cdk/config-registry.d.ts +34 -4
- package/dist/cdk/config-registry.d.ts.map +1 -1
- package/dist/cdk/config-registry.js +83 -25
- package/dist/cdk/config-registry.test.d.ts +2 -0
- package/dist/cdk/config-registry.test.d.ts.map +1 -0
- package/dist/cdk/config-registry.test.js +127 -0
- package/dist/cdk/dashboard-registry.d.ts +41 -0
- package/dist/cdk/dashboard-registry.d.ts.map +1 -0
- package/dist/cdk/dashboard-registry.js +61 -0
- package/dist/cdk/index.d.ts +90 -6
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +135 -13
- package/dist/cdk/internal.d.ts +3 -1
- package/dist/cdk/internal.d.ts.map +1 -1
- package/dist/cdk/internal.js +4 -1
- package/dist/cdk/tracer-registry.d.ts +31 -0
- package/dist/cdk/tracer-registry.d.ts.map +1 -0
- package/dist/cdk/tracer-registry.js +49 -0
- package/dist/cdk/vpc-requirements-registry.d.ts +33 -0
- package/dist/cdk/vpc-requirements-registry.d.ts.map +1 -0
- package/dist/cdk/vpc-requirements-registry.js +46 -0
- package/dist/cdk/vpc-types.d.ts +151 -0
- package/dist/cdk/vpc-types.d.ts.map +1 -0
- package/dist/cdk/vpc-types.js +3 -0
- package/dist/cdk/vpc.d.ts +59 -0
- package/dist/cdk/vpc.d.ts.map +1 -0
- package/dist/cdk/vpc.js +298 -0
- package/dist/cdk/vpc.test.d.ts +2 -0
- package/dist/cdk/vpc.test.d.ts.map +1 -0
- package/dist/cdk/vpc.test.js +285 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/common/config.d.ts +34 -0
- package/dist/common/config.d.ts.map +1 -1
- package/dist/common/config.js +45 -3
- package/dist/common/config.test.js +19 -0
- package/dist/common/index.d.ts +8 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +25 -0
- package/dist/hosting.d.ts +9 -0
- package/dist/hosting.d.ts.map +1 -1
- package/dist/hosting.js +12 -1
- package/dist/hosting.test.js +63 -1
- package/dist/index.cdk.d.ts +3 -2
- package/dist/index.cdk.d.ts.map +1 -1
- package/dist/index.cdk.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lambda-handler.d.ts +17 -0
- package/dist/lambda-handler.d.ts.map +1 -1
- package/dist/lambda-handler.js +61 -5
- package/dist/lambda-handler.test.js +191 -2
- package/dist/raw-route.d.ts +15 -1
- package/dist/raw-route.d.ts.map +1 -1
- package/dist/raw-route.js +96 -12
- package/dist/raw-route.test.js +332 -1
- package/dist/scripts/dev-server.d.ts.map +1 -1
- package/dist/scripts/dev-server.js +11 -0
- package/dist/scripts/extract-ts-types.d.ts.map +1 -1
- package/dist/scripts/extract-ts-types.js +107 -23
- package/dist/scripts/extract-ts-types.test.js +225 -26
- package/dist/scripts/generate-spec.d.ts.map +1 -1
- package/dist/scripts/generate-spec.js +14 -5
- package/dist/scripts/generate-spec.test.js +93 -0
- package/dist/scripts/sandbox-empty-buckets.test.d.ts +2 -0
- package/dist/scripts/sandbox-empty-buckets.test.d.ts.map +1 -0
- package/dist/scripts/sandbox-empty-buckets.test.js +171 -0
- package/dist/scripts/sandbox.d.ts +54 -0
- package/dist/scripts/sandbox.d.ts.map +1 -1
- package/dist/scripts/sandbox.js +163 -25
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -1
- package/src/api.test.ts +25 -0
- package/src/api.ts +39 -0
- package/src/bb-utils.ts +3 -0
- package/src/cdk/apigateway-account.ts +66 -0
- package/src/cdk/blocks-backend.test.ts +168 -60
- package/src/cdk/blocks-backend.ts +299 -227
- package/src/cdk/blocks-defaults.test.ts +21 -0
- package/src/cdk/blocks-defaults.ts +79 -1
- package/src/cdk/blocks-stack.test.ts +57 -13
- package/src/cdk/compute/compute-registry.ts +45 -0
- package/src/cdk/compute/compute.ts +114 -2
- package/src/cdk/compute/default-compute-factory.ts +1 -0
- package/src/cdk/config-registry.test.ts +149 -0
- package/src/cdk/config-registry.ts +92 -34
- package/src/cdk/dashboard-registry.ts +68 -0
- package/src/cdk/index.ts +427 -256
- package/src/cdk/internal.ts +6 -2
- package/src/cdk/tracer-registry.ts +54 -0
- package/src/cdk/vpc-requirements-registry.ts +63 -0
- package/src/cdk/vpc-types.ts +158 -0
- package/src/cdk/vpc.test.ts +348 -0
- package/src/cdk/vpc.ts +336 -0
- package/src/client/index.ts +1 -1
- package/src/common/config.test.ts +21 -0
- package/src/common/config.ts +47 -3
- package/src/common/index.ts +8 -0
- package/src/errors.ts +26 -0
- package/src/hosting.test.ts +87 -1
- package/src/hosting.ts +24 -1
- package/src/index.cdk.ts +11 -1
- package/src/index.ts +1 -1
- package/src/lambda-handler.test.ts +220 -2
- package/src/lambda-handler.ts +65 -4
- package/src/raw-route.test.ts +427 -1
- package/src/raw-route.ts +125 -12
- package/src/scripts/dev-server.ts +12 -1
- package/src/scripts/extract-ts-types.test.ts +228 -26
- package/src/scripts/extract-ts-types.ts +104 -20
- package/src/scripts/generate-spec.test.ts +101 -0
- package/src/scripts/generate-spec.ts +15 -5
- package/src/scripts/sandbox-empty-buckets.test.ts +191 -0
- package/src/scripts/sandbox.ts +185 -24
- package/src/version.ts +1 -1
package/dist/cdk/index.js
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import * as cdk from 'aws-cdk-lib';
|
|
4
|
-
import { Construct } from 'constructs';
|
|
5
3
|
import { pathToFileURL } from 'node:url';
|
|
6
4
|
import { __PIPELINE_STAGE_SCOPE__ } from '@aws-blocks/pipeline';
|
|
5
|
+
import * as cdk from 'aws-cdk-lib';
|
|
6
|
+
import { Construct } from 'constructs';
|
|
7
7
|
import { computeScopeFullId, } from '../common/index.js';
|
|
8
|
-
import {
|
|
9
|
-
import { addBlocksStackMetadata } from './stack-metadata.js';
|
|
10
|
-
import { finalizeConfigRegistry } from './config-registry.js';
|
|
8
|
+
import { assertCdkConditionActive, BlocksBackend, setupBlocksInfra } from './blocks-backend.js';
|
|
11
9
|
import { BlocksPresets } from './blocks-defaults.js';
|
|
10
|
+
import { getComputes } from './compute/compute-registry.js';
|
|
11
|
+
import { finalizeConfigRegistry } from './config-registry.js';
|
|
12
|
+
import { finalizeDashboards } from './dashboard-registry.js';
|
|
13
|
+
import { addBlocksStackMetadata } from './stack-metadata.js';
|
|
14
|
+
import { finalizeTracing } from './tracer-registry.js';
|
|
15
|
+
import { anyRequirementNeedsVpc, finalizeVpc, getOrCreateVpc, initializeVpc } from './vpc.js';
|
|
16
|
+
import { registerVpcRequirements } from './vpc-requirements-registry.js';
|
|
17
|
+
export { ApiError, DEFAULT_API_ERROR_NAME, hasAuthError, isBlocksError } from '../errors.js';
|
|
18
|
+
export { ensureApiGatewayAccount } from './apigateway-account.js';
|
|
12
19
|
export { BlocksBackend, SHARED_HANDLER_TIMEOUT_SECONDS, } from './blocks-backend.js';
|
|
13
|
-
export {
|
|
20
|
+
export { BlocksPresets, } from './blocks-defaults.js';
|
|
14
21
|
export { blocksNodejsBundling } from './bundling.js';
|
|
22
|
+
export { finalizeConfigRegistry, getConfigLocation, registerConfig } from './config-registry.js';
|
|
23
|
+
export { finalizeDashboards, registerDashboardFinalizer } from './dashboard-registry.js';
|
|
15
24
|
export { SandboxDisableDeletionProtection } from './mixins.js';
|
|
16
|
-
export {
|
|
17
|
-
export { BlocksPresets, } from './blocks-defaults.js';
|
|
25
|
+
export { DEFAULT_NODE_RUNTIME } from './node-version.js';
|
|
18
26
|
export { synthGuard } from './synth-guard.js';
|
|
19
|
-
export {
|
|
27
|
+
export { finalizeTracing, registerTracer } from './tracer-registry.js';
|
|
28
|
+
export { getVpcContext } from './vpc.js';
|
|
20
29
|
export class BlocksStack extends cdk.Stack {
|
|
21
30
|
id;
|
|
22
31
|
backendHandlerPath;
|
|
32
|
+
/**
|
|
33
|
+
* Path to the app's backend module (`props.backendCDKPath`). Exposed so Building Blocks that
|
|
34
|
+
* co-bundle the backend at synth (e.g. the Agent BB's AgentCore Runtime) can discover it via
|
|
35
|
+
* `globalThis.CURRENT_BLOCKS_STACK.backendModulePath`.
|
|
36
|
+
*/
|
|
37
|
+
backendModulePath;
|
|
23
38
|
/** Shared IAM role assumed by all Blocks compute. Building Blocks grant to this role. */
|
|
24
39
|
executionRole;
|
|
25
40
|
/** Infrastructure defaults for Building Blocks created under this stack. */
|
|
@@ -38,19 +53,35 @@ export class BlocksStack extends cdk.Stack {
|
|
|
38
53
|
get apiUrl() {
|
|
39
54
|
return this.requireDefaultCompute().apiUrl;
|
|
40
55
|
}
|
|
56
|
+
/** The default compute's handler CloudWatch log group. Its retention comes from
|
|
57
|
+
* the compute's `logRetention` (falling back to `defaults.logRetention`); the
|
|
58
|
+
* `bb-logger` CDK construct is a no-op and no longer touches it. */
|
|
59
|
+
get handlerLogGroup() {
|
|
60
|
+
return this.requireDefaultCompute().logGroup;
|
|
61
|
+
}
|
|
41
62
|
requireDefaultCompute() {
|
|
42
63
|
if (!this._defaultCompute) {
|
|
43
64
|
throw new Error('Blocks stack not fully initialized — access .handler/.gateway/.apiUrl after BlocksStack.create() resolves.');
|
|
44
65
|
}
|
|
45
66
|
return this._defaultCompute;
|
|
46
67
|
}
|
|
68
|
+
_vpcOptions;
|
|
47
69
|
constructor(scope, id, props) {
|
|
48
70
|
super(scope, id, props);
|
|
49
71
|
this.id = id;
|
|
50
72
|
this.backendHandlerPath = props.backendHandlerPath;
|
|
73
|
+
this.backendModulePath = props.backendCDKPath;
|
|
51
74
|
this.defaults = props.defaults;
|
|
75
|
+
this._vpcOptions = props.defaults.vpc;
|
|
52
76
|
// Set globalThis so Building Blocks attach directly to this stack
|
|
53
77
|
globalThis.CURRENT_BLOCKS_STACK = this;
|
|
78
|
+
// Initialize VPC context before the default compute is created and before
|
|
79
|
+
// BBs are constructed, so both can discover it: the default compute
|
|
80
|
+
// (LambdaCompute) reads it via getVpcContext(this) to place its function in
|
|
81
|
+
// the VPC, and BBs (e.g. bb-data) read it to co-locate their resources.
|
|
82
|
+
if (this._vpcOptions) {
|
|
83
|
+
initializeVpc(this, this._vpcOptions);
|
|
84
|
+
}
|
|
54
85
|
const infra = setupBlocksInfra(this, props, id);
|
|
55
86
|
this.executionRole = infra.executionRole;
|
|
56
87
|
}
|
|
@@ -81,7 +112,30 @@ export class BlocksStack extends cdk.Stack {
|
|
|
81
112
|
}
|
|
82
113
|
}
|
|
83
114
|
// Finalize BB config → S3 (after all BBs have registered their config)
|
|
84
|
-
finalizeConfigRegistry(stack, stack.
|
|
115
|
+
finalizeConfigRegistry(stack, stack.executionRole, getComputes(stack));
|
|
116
|
+
// Tracing is presence-gated: if the app contains a Tracer, enable X-Ray on
|
|
117
|
+
// every compute. Runs before the dashboard finalize so tracingEnabled is
|
|
118
|
+
// set when the dashboard reads it.
|
|
119
|
+
finalizeTracing(stack, stack.executionRole);
|
|
120
|
+
// Build any deferred Dashboards now that every compute's observability
|
|
121
|
+
// state is settled — so the dashboard is order-independent.
|
|
122
|
+
finalizeDashboards(stack);
|
|
123
|
+
// Finalize VPC. A VPC is a derived resource: use the customer's if they
|
|
124
|
+
// brought one, else lazily create one only if a Building Block genuinely
|
|
125
|
+
// requires it (requiresVpc). Most apps need neither — Lambda reaches AWS
|
|
126
|
+
// services from the managed network without a VPC.
|
|
127
|
+
if (stack._vpcOptions) {
|
|
128
|
+
finalizeVpc(stack, stack._vpcOptions);
|
|
129
|
+
}
|
|
130
|
+
else if (anyRequirementNeedsVpc(stack)) {
|
|
131
|
+
const derived = getOrCreateVpc(stack);
|
|
132
|
+
const options = { network: derived };
|
|
133
|
+
initializeVpc(stack, options);
|
|
134
|
+
finalizeVpc(stack, options);
|
|
135
|
+
cdk.Annotations.of(stack).addInfoV2('blocks:vpc:derived', 'A Building Block required a VPC and none was provided, so Blocks created one ' +
|
|
136
|
+
'(with a NAT gateway, which has an ongoing cost). Pass `defaults.vpc: { network }` to ' +
|
|
137
|
+
'BlocksStack.create to bring your own. See packages/blocks/VPC.md.');
|
|
138
|
+
}
|
|
85
139
|
new cdk.CfnOutput(stack, 'ApiUrl', { value: stack.apiUrl });
|
|
86
140
|
addBlocksStackMetadata(stack);
|
|
87
141
|
return stack;
|
|
@@ -165,6 +219,23 @@ export class Scope extends Construct {
|
|
|
165
219
|
}
|
|
166
220
|
return defaultCompute;
|
|
167
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* The stack's default compute, **ignoring** any per-scope `_compute`
|
|
224
|
+
* assignment (unlike {@link compute}, which resolves the nearest assigned
|
|
225
|
+
* one). Use when a resource is a stack-level singleton that must bind to one
|
|
226
|
+
* deterministic compute regardless of the block's resolved compute — e.g.
|
|
227
|
+
* Realtime's shared WebSocket route integration, where one WebSocket API
|
|
228
|
+
* integrates to a single target and connection bookkeeping is compute-agnostic.
|
|
229
|
+
*
|
|
230
|
+
* @internal Not a customer surface; for framework/BB singleton infra only.
|
|
231
|
+
*/
|
|
232
|
+
get defaultCompute() {
|
|
233
|
+
const defaultCompute = this.root._defaultCompute;
|
|
234
|
+
if (!defaultCompute) {
|
|
235
|
+
throw new Error('Default compute not initialized — BlocksStack/BlocksBackend.create() must run before resolving `defaultCompute`.');
|
|
236
|
+
}
|
|
237
|
+
return defaultCompute;
|
|
238
|
+
}
|
|
168
239
|
/**
|
|
169
240
|
* The backend entry file the owning BlocksStack/BlocksBackend runs — the
|
|
170
241
|
* single handler entry shared across the whole app.
|
|
@@ -187,6 +258,16 @@ export class Scope extends Construct {
|
|
|
187
258
|
}
|
|
188
259
|
return name;
|
|
189
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* The shared handler Lambda's CloudWatch log group (the default compute's).
|
|
263
|
+
* Resolves the same way as {@link handler} — via the owning
|
|
264
|
+
* BlocksStack/BlocksBackend. Its retention comes from the compute's
|
|
265
|
+
* `logRetention` (falling back to `defaults.logRetention`); the `bb-logger`
|
|
266
|
+
* CDK construct is a no-op and no longer reconfigures it.
|
|
267
|
+
*/
|
|
268
|
+
get handlerLogGroup() {
|
|
269
|
+
return this.root.handlerLogGroup;
|
|
270
|
+
}
|
|
190
271
|
get fullId() {
|
|
191
272
|
return computeScopeFullId(this);
|
|
192
273
|
}
|
|
@@ -212,7 +293,8 @@ export class Scope extends Construct {
|
|
|
212
293
|
return current.defaults;
|
|
213
294
|
}
|
|
214
295
|
}
|
|
215
|
-
const ambient = globalThis.CURRENT_BLOCKS_STACK
|
|
296
|
+
const ambient = globalThis.CURRENT_BLOCKS_STACK
|
|
297
|
+
?.defaults;
|
|
216
298
|
if (ambient)
|
|
217
299
|
return ambient;
|
|
218
300
|
// No owning BlocksStack/BlocksBackend in the tree and none ambient — this is
|
|
@@ -230,6 +312,46 @@ export class Scope extends Construct {
|
|
|
230
312
|
registerClientMiddleware(_packageSpecifier) { }
|
|
231
313
|
registerDevAttachment(_packageSpecifier) { }
|
|
232
314
|
registerLambdaEventHandler(_eventSource, _identifier, _handler) { }
|
|
233
|
-
get clientMiddleware() {
|
|
234
|
-
|
|
315
|
+
get clientMiddleware() {
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
get devAttachments() {
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Base class for Building Block CDK constructs.
|
|
324
|
+
*
|
|
325
|
+
* BBs extend this instead of `Scope` directly and **must** declare their VPC
|
|
326
|
+
* requirements as a constructor argument — the base registers them centrally
|
|
327
|
+
* (see `vpc-requirements-registry.ts`) so `finalizeVpc` can pull, deduplicate,
|
|
328
|
+
* and provision endpoints, and so the lazy VPC can answer "does anything here
|
|
329
|
+
* need a VPC?". Passing the requirements is required by the constructor
|
|
330
|
+
* signature, so a BB author cannot silently forget to declare them — the same
|
|
331
|
+
* forcing the previous `abstract getVpcRequirements()` gave, but without a
|
|
332
|
+
* standing method on every subclass.
|
|
333
|
+
*
|
|
334
|
+
* Declare `{}` when the BB needs nothing VPC-specific.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* export class KVStore extends BuildingBlockScope {
|
|
339
|
+
* constructor(scope: ScopeParent, id: string) {
|
|
340
|
+
* super(id, { parent: scope, vpc: { gatewayEndpoints: [ec2.GatewayVpcEndpointAwsService.DYNAMODB] } });
|
|
341
|
+
* // …
|
|
342
|
+
* }
|
|
343
|
+
* }
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export class BuildingBlockScope extends Scope {
|
|
347
|
+
constructor(id, options) {
|
|
348
|
+
const { vpc, ...scopeOptions } = options;
|
|
349
|
+
super(id, scopeOptions);
|
|
350
|
+
// Resolve the provider (callback form is evaluated here, after super(), so
|
|
351
|
+
// values that depend on this.fullId are available) and self-register on the
|
|
352
|
+
// owning stack. Register even when empty so the registry is a faithful
|
|
353
|
+
// census of every BB — the lazy VPC and finalizeVpc both rely on that.
|
|
354
|
+
const requirements = typeof vpc === 'function' ? vpc() : vpc;
|
|
355
|
+
registerVpcRequirements(this, requirements);
|
|
356
|
+
}
|
|
235
357
|
}
|
package/dist/cdk/internal.d.ts
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
+
export { BLOCKS_NAMESPACE } from '../constants.js';
|
|
23
|
+
export type { ComputeDashboardSection } from './compute/compute.js';
|
|
22
24
|
export { Compute } from './compute/compute.js';
|
|
25
|
+
export { getComputes } from './compute/compute-registry.js';
|
|
23
26
|
export type { DefaultComputeFactory } from './compute/default-compute-factory.js';
|
|
24
|
-
export { BLOCKS_NAMESPACE } from '../constants.js';
|
|
25
27
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/cdk/internal.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/cdk/internal.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,YAAY,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC"}
|
package/dist/cdk/internal.js
CHANGED
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @internal
|
|
23
23
|
*/
|
|
24
|
-
export { Compute } from './compute/compute.js';
|
|
25
24
|
// Reserved `/aws-blocks` path segment, needed by concrete computes (e.g.
|
|
26
25
|
// LambdaCompute in @aws-blocks/bb-lambda-compute) to build their API route tree.
|
|
27
26
|
export { BLOCKS_NAMESPACE } from '../constants.js';
|
|
27
|
+
export { Compute } from './compute/compute.js';
|
|
28
|
+
// Enumerate the computes registered on a stack — the Dashboard BB's default
|
|
29
|
+
// compute selection resolves through this at finalize.
|
|
30
|
+
export { getComputes } from './compute/compute-registry.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type IRole } from 'aws-cdk-lib/aws-iam';
|
|
2
|
+
import type { Construct } from 'constructs';
|
|
3
|
+
/**
|
|
4
|
+
* Mark that the app contains a `Tracer`. Tracing is **presence-gated**: a Tracer
|
|
5
|
+
* anywhere in the app means every compute should be traced (X-Ray provisions
|
|
6
|
+
* real, costed infra, so it's off unless the app opts in by creating a Tracer).
|
|
7
|
+
* Multiple Tracers are fine — this just records the boolean. Stored per stack
|
|
8
|
+
* (keyed by a Symbol), like the config/compute registries.
|
|
9
|
+
*
|
|
10
|
+
* @param scope - Any construct in the stack (used to locate the stack).
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerTracer(scope: Construct): void;
|
|
13
|
+
/**
|
|
14
|
+
* If the app contains a `Tracer`, enable tracing on **every** compute in the
|
|
15
|
+
* stack and grant X-Ray publish **once** on the shared execution role. Runs at
|
|
16
|
+
* the end of `create()` (after the backend module has imported, so all computes
|
|
17
|
+
* are registered). `Compute.enableTracing()` is idempotent, so this is safe
|
|
18
|
+
* regardless of how many Tracers exist.
|
|
19
|
+
*
|
|
20
|
+
* The IAM grant lives here — at the framework level, once on the shared role —
|
|
21
|
+
* rather than in each compute's `applyTracing()`: every compute assumes the same
|
|
22
|
+
* execution role, so a per-compute grant would add N identical statements. The
|
|
23
|
+
* compute only flips its own tracing mode (e.g. Lambda `TracingConfig: Active`);
|
|
24
|
+
* the permission to publish segments is a single stack-level concern.
|
|
25
|
+
*
|
|
26
|
+
* @param scope - Any construct in the stack (used to locate the stack + computes).
|
|
27
|
+
* @param executionRole - The shared execution role every compute assumes; granted
|
|
28
|
+
* X-Ray publish once when tracing is enabled.
|
|
29
|
+
*/
|
|
30
|
+
export declare function finalizeTracing(scope: Construct, executionRole: IRole): void;
|
|
31
|
+
//# sourceMappingURL=tracer-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracer-registry.d.ts","sourceRoot":"","sources":["../../src/cdk/tracer-registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,KAAK,EAAmB,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAErD;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,GAAG,IAAI,CAU5E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import * as cdk from 'aws-cdk-lib';
|
|
4
|
+
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
|
|
5
|
+
import { getComputes } from './compute/compute-registry.js';
|
|
6
|
+
const REGISTRY_KEY = Symbol.for('BLOCKS_TRACER_PRESENCE');
|
|
7
|
+
/**
|
|
8
|
+
* Mark that the app contains a `Tracer`. Tracing is **presence-gated**: a Tracer
|
|
9
|
+
* anywhere in the app means every compute should be traced (X-Ray provisions
|
|
10
|
+
* real, costed infra, so it's off unless the app opts in by creating a Tracer).
|
|
11
|
+
* Multiple Tracers are fine — this just records the boolean. Stored per stack
|
|
12
|
+
* (keyed by a Symbol), like the config/compute registries.
|
|
13
|
+
*
|
|
14
|
+
* @param scope - Any construct in the stack (used to locate the stack).
|
|
15
|
+
*/
|
|
16
|
+
export function registerTracer(scope) {
|
|
17
|
+
cdk.Stack.of(scope)[REGISTRY_KEY] = true;
|
|
18
|
+
}
|
|
19
|
+
function hasTracer(stack) {
|
|
20
|
+
return stack[REGISTRY_KEY] === true;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* If the app contains a `Tracer`, enable tracing on **every** compute in the
|
|
24
|
+
* stack and grant X-Ray publish **once** on the shared execution role. Runs at
|
|
25
|
+
* the end of `create()` (after the backend module has imported, so all computes
|
|
26
|
+
* are registered). `Compute.enableTracing()` is idempotent, so this is safe
|
|
27
|
+
* regardless of how many Tracers exist.
|
|
28
|
+
*
|
|
29
|
+
* The IAM grant lives here — at the framework level, once on the shared role —
|
|
30
|
+
* rather than in each compute's `applyTracing()`: every compute assumes the same
|
|
31
|
+
* execution role, so a per-compute grant would add N identical statements. The
|
|
32
|
+
* compute only flips its own tracing mode (e.g. Lambda `TracingConfig: Active`);
|
|
33
|
+
* the permission to publish segments is a single stack-level concern.
|
|
34
|
+
*
|
|
35
|
+
* @param scope - Any construct in the stack (used to locate the stack + computes).
|
|
36
|
+
* @param executionRole - The shared execution role every compute assumes; granted
|
|
37
|
+
* X-Ray publish once when tracing is enabled.
|
|
38
|
+
*/
|
|
39
|
+
export function finalizeTracing(scope, executionRole) {
|
|
40
|
+
if (!hasTracer(cdk.Stack.of(scope)))
|
|
41
|
+
return;
|
|
42
|
+
for (const compute of getComputes(scope))
|
|
43
|
+
compute.enableTracing();
|
|
44
|
+
// One grant on the shared role rather than one per traced compute.
|
|
45
|
+
executionRole.addToPrincipalPolicy(new PolicyStatement({
|
|
46
|
+
actions: ['xray:PutTraceSegments', 'xray:PutTelemetryRecords'],
|
|
47
|
+
resources: ['*'],
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
|
+
import type { Construct } from 'constructs';
|
|
3
|
+
import type { VpcRequirements } from './vpc-types.js';
|
|
4
|
+
/** A registered requirement plus the fullId of the BB that declared it (for errors). */
|
|
5
|
+
export interface RegisteredVpcRequirement {
|
|
6
|
+
readonly fullId: string;
|
|
7
|
+
readonly requirements: VpcRequirements;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Register a Building Block's VPC requirements on its owning stack. Called from
|
|
11
|
+
* the {@link BuildingBlockScope} base constructor, so every BB self-registers the
|
|
12
|
+
* moment it is constructed — `finalizeVpc` then enumerates them without a separate
|
|
13
|
+
* discovery pass (mirrors how `registerCompute`/`registerConfig` accumulate during
|
|
14
|
+
* the backend import). Because it's driven by the base constructor, a BB **cannot**
|
|
15
|
+
* silently skip declaring its requirements: the constructor won't compile without
|
|
16
|
+
* supplying them (see `BuildingBlockScope`).
|
|
17
|
+
*
|
|
18
|
+
* @param bb - The construct declaring the requirement (used to locate its stack and name it).
|
|
19
|
+
* @param requirements - What the BB needs from the VPC.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerVpcRequirements(bb: Construct & {
|
|
22
|
+
readonly fullId: string;
|
|
23
|
+
}, requirements: VpcRequirements): void;
|
|
24
|
+
/**
|
|
25
|
+
* The VPC requirements registered on the stack that owns `scope`, in construction
|
|
26
|
+
* order. Returns an empty array before any BB is constructed.
|
|
27
|
+
*
|
|
28
|
+
* @param scope - Any construct in the stack (used to locate the stack).
|
|
29
|
+
*/
|
|
30
|
+
export declare function getVpcRequirements(scope: Construct): readonly RegisteredVpcRequirement[];
|
|
31
|
+
/** Clear the registry. **For test cleanup only.** */
|
|
32
|
+
export declare function _resetVpcRequirementsRegistry(stack: cdk.Stack): void;
|
|
33
|
+
//# sourceMappingURL=vpc-requirements-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vpc-requirements-registry.d.ts","sourceRoot":"","sources":["../../src/cdk/vpc-requirements-registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,wFAAwF;AACxF,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;CACvC;AAiBD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACtC,EAAE,EAAE,SAAS,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC3C,YAAY,EAAE,eAAe,GAC3B,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,wBAAwB,EAAE,CAExF;AAED,qDAAqD;AACrD,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,IAAI,CAEpE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import * as cdk from 'aws-cdk-lib';
|
|
4
|
+
const REGISTRY_KEY = Symbol.for('BLOCKS_VPC_REQUIREMENTS_REGISTRY');
|
|
5
|
+
/**
|
|
6
|
+
* Get or create the VPC-requirements list for a given stack. Stored on the stack
|
|
7
|
+
* object (keyed by a Symbol), so each stack in a multi-stack synth gets its own —
|
|
8
|
+
* a requirement never leaks into another stack's list. Mirrors the compute and
|
|
9
|
+
* config registries, which scope their state the same way.
|
|
10
|
+
*/
|
|
11
|
+
function getRegistry(stack) {
|
|
12
|
+
let list = stack[REGISTRY_KEY];
|
|
13
|
+
if (!list) {
|
|
14
|
+
list = [];
|
|
15
|
+
stack[REGISTRY_KEY] = list;
|
|
16
|
+
}
|
|
17
|
+
return list;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a Building Block's VPC requirements on its owning stack. Called from
|
|
21
|
+
* the {@link BuildingBlockScope} base constructor, so every BB self-registers the
|
|
22
|
+
* moment it is constructed — `finalizeVpc` then enumerates them without a separate
|
|
23
|
+
* discovery pass (mirrors how `registerCompute`/`registerConfig` accumulate during
|
|
24
|
+
* the backend import). Because it's driven by the base constructor, a BB **cannot**
|
|
25
|
+
* silently skip declaring its requirements: the constructor won't compile without
|
|
26
|
+
* supplying them (see `BuildingBlockScope`).
|
|
27
|
+
*
|
|
28
|
+
* @param bb - The construct declaring the requirement (used to locate its stack and name it).
|
|
29
|
+
* @param requirements - What the BB needs from the VPC.
|
|
30
|
+
*/
|
|
31
|
+
export function registerVpcRequirements(bb, requirements) {
|
|
32
|
+
getRegistry(cdk.Stack.of(bb)).push({ fullId: bb.fullId, requirements });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The VPC requirements registered on the stack that owns `scope`, in construction
|
|
36
|
+
* order. Returns an empty array before any BB is constructed.
|
|
37
|
+
*
|
|
38
|
+
* @param scope - Any construct in the stack (used to locate the stack).
|
|
39
|
+
*/
|
|
40
|
+
export function getVpcRequirements(scope) {
|
|
41
|
+
return getRegistry(cdk.Stack.of(scope));
|
|
42
|
+
}
|
|
43
|
+
/** Clear the registry. **For test cleanup only.** */
|
|
44
|
+
export function _resetVpcRequirementsRegistry(stack) {
|
|
45
|
+
stack[REGISTRY_KEY] = [];
|
|
46
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
/**
|
|
3
|
+
* A subnet role — the kind of subnet a Building Block needs, expressed as an
|
|
4
|
+
* intent the VPC resolves to a concrete {@link ec2.SubnetSelection}:
|
|
5
|
+
*
|
|
6
|
+
* - `'private-with-egress'` — private subnets with outbound internet access via
|
|
7
|
+
* a NAT gateway. Required by anything that must reach a public AWS endpoint at
|
|
8
|
+
* runtime (e.g. a service with no interface endpoint).
|
|
9
|
+
* - `'isolated'` — private subnets with no internet route at all. Best for
|
|
10
|
+
* resources reached entirely over VPC endpoints or in-VPC (e.g. a database).
|
|
11
|
+
* - `'public'` — subnets with a direct internet gateway route.
|
|
12
|
+
*/
|
|
13
|
+
export type SubnetRole = 'private-with-egress' | 'isolated' | 'public';
|
|
14
|
+
/**
|
|
15
|
+
* Options for VPC integration on BlocksStack / BlocksBackend.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const vpc = new ec2.Vpc(app, 'AppVpc', { maxAzs: 2, natGateways: 1 });
|
|
20
|
+
* await BlocksStack.create(app, stackName, {
|
|
21
|
+
* backendHandlerPath: join(__dirname, 'index.handler.ts'),
|
|
22
|
+
* backendCDKPath: join(__dirname, 'index.ts'),
|
|
23
|
+
* defaults: { ...BlocksPresets.production, vpc: { network: vpc } },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export interface BlocksVpcOptions {
|
|
28
|
+
/**
|
|
29
|
+
* The VPC to place Lambdas and VPC-resident resources into.
|
|
30
|
+
* Create this however you like — standard CDK:
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const vpc = new ec2.Vpc(stack, 'AppVpc', { maxAzs: 2, natGateways: 1 });
|
|
34
|
+
* // or
|
|
35
|
+
* const vpc = ec2.Vpc.fromLookup(stack, 'SharedVpc', { vpcId: 'vpc-abc123' });
|
|
36
|
+
*/
|
|
37
|
+
network: ec2.IVpc;
|
|
38
|
+
/**
|
|
39
|
+
* Subnet selection for Lambda and Blocks-managed compute placement.
|
|
40
|
+
*
|
|
41
|
+
* Any subnets you select must belong to {@link network}. This is not
|
|
42
|
+
* validated at synth — CDK can't check it for an imported subnet (which
|
|
43
|
+
* carries no `vpcId`) — so a mismatch surfaces as a CloudFormation error at
|
|
44
|
+
* deploy, not a synth-time failure.
|
|
45
|
+
*
|
|
46
|
+
* @default { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }
|
|
47
|
+
*/
|
|
48
|
+
subnets?: ec2.SubnetSelection;
|
|
49
|
+
/**
|
|
50
|
+
* Whether to auto-provision VPC endpoints based on BB registrations.
|
|
51
|
+
* Set to `false` to disable (e.g., when using a shared VPC that already has endpoints).
|
|
52
|
+
*
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
provisionEndpoints?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* VPC requirements declared by a Building Block.
|
|
59
|
+
* Supplied to the `BuildingBlockScope` constructor and collected in the central
|
|
60
|
+
* requirements registry; `finalizeVpc` pulls them to provision endpoints, and the
|
|
61
|
+
* lazy VPC uses `requiresVpc` to decide whether to derive a VPC when none was
|
|
62
|
+
* provided.
|
|
63
|
+
*/
|
|
64
|
+
export interface VpcRequirements {
|
|
65
|
+
/** Gateway VPC endpoints this BB needs (e.g., S3, DynamoDB). */
|
|
66
|
+
gatewayEndpoints?: ec2.GatewayVpcEndpointAwsService[];
|
|
67
|
+
/** Interface VPC endpoints this BB needs (e.g., SQS, SSM, Secrets Manager). */
|
|
68
|
+
interfaceEndpoints?: ec2.InterfaceVpcEndpointAwsService[];
|
|
69
|
+
/**
|
|
70
|
+
* Whether this BB **cannot function without a VPC** — i.e. it must run in (or
|
|
71
|
+
* provision resources into) a VPC regardless of whether the customer asked
|
|
72
|
+
* for one. When any registered requirement sets this and no `vpc` was
|
|
73
|
+
* provided, the framework **lazily derives** a default VPC (see
|
|
74
|
+
* `getOrCreateVpc`) rather than erroring — mirroring how bb-data creates its
|
|
75
|
+
* own VPC when no shared one exists.
|
|
76
|
+
*
|
|
77
|
+
* Most BBs leave this unset: they reach AWS services from the AWS-managed
|
|
78
|
+
* Lambda network and only *benefit* from a VPC (endpoints) when one is present.
|
|
79
|
+
* Set it only for a BB whose resources are intrinsically VPC-resident.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
requiresVpc?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the BB's **parent runtime** — the shared Blocks handler Lambda (or,
|
|
86
|
+
* in future, a container) that executes this BB's operations — must be able to
|
|
87
|
+
* reach the internet (outbound egress) for the BB to work at runtime.
|
|
88
|
+
*
|
|
89
|
+
* Set this when your BB's runtime code calls a service it can only reach over
|
|
90
|
+
* the public internet. The canonical case: a service with no VPC endpoint
|
|
91
|
+
* (e.g. Aurora DSQL) is reached over a public HTTPS endpoint, so the runtime
|
|
92
|
+
* must sit in a subnet with an egress route; if it's placed in isolated
|
|
93
|
+
* subnets the deploy still succeeds but every call times out at runtime.
|
|
94
|
+
*
|
|
95
|
+
* The framework **validates** this at synth against the runtime's resolved
|
|
96
|
+
* placement (egress is satisfied by a `private-with-egress` or `public`
|
|
97
|
+
* selection) and fails the build with an actionable message on a mismatch. It
|
|
98
|
+
* never moves the runtime — reassigning a customer's explicit placement is not
|
|
99
|
+
* a BB's responsibility, so an unsatisfiable requirement is an error, not a
|
|
100
|
+
* silent relocation.
|
|
101
|
+
*
|
|
102
|
+
* This constrains the BB's **host**. To place compute the BB provisions
|
|
103
|
+
* **itself** (e.g. an Aurora cluster), resolve a subnet inline in your
|
|
104
|
+
* constructor via {@link VpcContext.selectSubnets} instead.
|
|
105
|
+
*
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
requiresEgress?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The minimal shape {@link VpcContext.selectSubnets} needs from a Building
|
|
112
|
+
* Block to produce an instructive, BB-named error — just its `fullId`. Typed
|
|
113
|
+
* structurally so `vpc-types.ts` stays type-only and free of a dependency on
|
|
114
|
+
* the `Scope` class.
|
|
115
|
+
*/
|
|
116
|
+
export interface SubnetScope {
|
|
117
|
+
readonly fullId: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Internal VPC context propagated through the construct tree.
|
|
121
|
+
* Set by the CDK-level VPC option. BBs read this to determine their VPC placement.
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
export interface VpcContext {
|
|
125
|
+
readonly vpc: ec2.IVpc;
|
|
126
|
+
readonly computeSecurityGroup: ec2.ISecurityGroup;
|
|
127
|
+
readonly computeSubnets: ec2.SubnetSelection;
|
|
128
|
+
/**
|
|
129
|
+
* Resolve a {@link SubnetRole} to a concrete {@link ec2.SubnetSelection} for a
|
|
130
|
+
* resource this Building Block provisions itself, verifying the VPC actually
|
|
131
|
+
* has subnets of that role.
|
|
132
|
+
*
|
|
133
|
+
* Prefer this over building an `ec2.SubnetSelection` by hand: if the VPC has
|
|
134
|
+
* no matching subnet, it throws an actionable, BB-named error at synth
|
|
135
|
+
* ("`KVStore 'app/cache'` needs an 'isolated' subnet, but VPC 'vpc-…' has
|
|
136
|
+
* none …") instead of the opaque CDK "no subnet groups" error thrown later.
|
|
137
|
+
*
|
|
138
|
+
* @param scope the BB requesting the subnet (its `fullId` names the error)
|
|
139
|
+
* @param role the subnet role the BB's own resource needs
|
|
140
|
+
* @param opts.fallback an alternate role to use when `role` is absent from
|
|
141
|
+
* the VPC. Provide it to **explicitly** allow graceful degradation (e.g.
|
|
142
|
+
* Aurora over the Data API works from `'private-with-egress'` when there is
|
|
143
|
+
* no isolated tier); omit it to require `role` strictly and fail otherwise.
|
|
144
|
+
* The downgrade is never silent — it only happens when you opt in here.
|
|
145
|
+
* @throws if the VPC has neither `role` nor (when given) `opts.fallback`
|
|
146
|
+
*/
|
|
147
|
+
selectSubnets(scope: SubnetScope, role: SubnetRole, opts?: {
|
|
148
|
+
fallback?: SubnetRole;
|
|
149
|
+
}): ec2.SubnetSelection;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=vpc-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vpc-types.d.ts","sourceRoot":"","sources":["../../src/cdk/vpc-types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAAG,qBAAqB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;OAQG;IACH,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC;IAElB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC;IAE9B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC/B,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,GAAG,CAAC,4BAA4B,EAAE,CAAC;IACtD,+EAA+E;IAC/E,kBAAkB,CAAC,EAAE,GAAG,CAAC,8BAA8B,EAAE,CAAC;IAC1D;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;IACvB,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,cAAc,CAAC;IAClD,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,eAAe,CAAC;IAC7C;;;;;;;;;;;;;;;;;;OAkBG;IACH,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,GAAG,CAAC,eAAe,CAAC;CAC3G"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
import type { Construct } from 'constructs';
|
|
3
|
+
import type { BlocksVpcOptions, VpcContext } from './vpc-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Set the VPC context on a scope (BlocksStack or BlocksBackend).
|
|
6
|
+
* Called during stack creation when `vpc` prop is provided.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function setVpcContext(scope: Construct, context: VpcContext): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get the VPC context from a scope by walking up the construct tree.
|
|
12
|
+
* Used by BBs (e.g., bb-data) to discover the shared VPC.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function getVpcContext(scope: Construct): VpcContext | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Does any registered Building Block *require* a VPC (i.e. cannot function
|
|
18
|
+
* without one)? Used to decide whether to lazily derive a VPC when the customer
|
|
19
|
+
* didn't provide one. A BB that merely benefits from endpoints does NOT count —
|
|
20
|
+
* only `requiresVpc: true`.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function anyRequirementNeedsVpc(scope: Construct): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get the framework-owned VPC for a stack, creating one on first use.
|
|
26
|
+
*
|
|
27
|
+
* VPC is a **derived** resource: when a Building Block (or, later, a container
|
|
28
|
+
* compute) requires one and the customer didn't bring their own, Blocks
|
|
29
|
+
* materializes a sensible default here — the same create-if-absent pattern
|
|
30
|
+
* `bb-data` uses for Aurora, lifted to the framework so the whole app shares a
|
|
31
|
+
* single VPC. Keyed by a Symbol on the stack so it's a true singleton: the first
|
|
32
|
+
* caller creates, everyone else reuses. Passing a customer VPC (`vpc:` prop)
|
|
33
|
+
* pre-seeds this via {@link initializeVpc}, so this default is only built when
|
|
34
|
+
* nothing was provided.
|
|
35
|
+
*
|
|
36
|
+
* The default has both a `private-with-egress` tier (for a runtime that needs
|
|
37
|
+
* outbound access — the derivation trigger) and public subnets for the NAT
|
|
38
|
+
* gateway. NAT has a real cost, so this is only created on genuine need, and
|
|
39
|
+
* `create()` emits a notice when it does.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare function getOrCreateVpc(scope: Construct): ec2.IVpc;
|
|
43
|
+
/**
|
|
44
|
+
* Initialize VPC support on a Blocks scope (BlocksStack or BlocksBackend).
|
|
45
|
+
* Creates the security group, sets VPC context, and returns the VpcContext
|
|
46
|
+
* that is used for Lambda placement configuration.
|
|
47
|
+
*
|
|
48
|
+
* Called during setupBlocksInfra when `vpc` prop is present.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function initializeVpc(scope: Construct, options: BlocksVpcOptions): VpcContext;
|
|
52
|
+
/**
|
|
53
|
+
* Finalize VPC: query all BuildingBlockScope children for their VPC requirements,
|
|
54
|
+
* deduplicate, and provision endpoints.
|
|
55
|
+
* Called after all BBs are constructed (alongside finalizeConfigRegistry).
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export declare function finalizeVpc(scope: Construct, options: BlocksVpcOptions): void;
|
|
59
|
+
//# sourceMappingURL=vpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vpc.d.ts","sourceRoot":"","sources":["../../src/cdk/vpc.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAA2B,UAAU,EAAmB,MAAM,gBAAgB,CAAC;AA4B7G;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAQtE;AAID;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEhE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,CAOzD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAG,UAAU,CAkDrF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAyH7E"}
|