@aws-blocks/core 0.1.18 → 0.3.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/dist/cdk/__fixtures__/import-meta-handler.d.ts +6 -0
- package/dist/cdk/__fixtures__/import-meta-handler.d.ts.map +1 -0
- package/dist/cdk/__fixtures__/import-meta-handler.js +13 -0
- package/dist/cdk/blocks-backend.d.ts +46 -9
- package/dist/cdk/blocks-backend.d.ts.map +1 -1
- package/dist/cdk/blocks-backend.js +66 -67
- package/dist/cdk/blocks-backend.test.js +114 -56
- package/dist/cdk/blocks-defaults.d.ts +70 -0
- package/dist/cdk/blocks-defaults.d.ts.map +1 -0
- package/dist/cdk/blocks-defaults.js +27 -0
- package/dist/cdk/blocks-defaults.test.d.ts +2 -0
- package/dist/cdk/blocks-defaults.test.d.ts.map +1 -0
- package/dist/cdk/blocks-defaults.test.js +24 -0
- package/dist/cdk/blocks-stack.test.js +74 -31
- package/dist/cdk/bundling.d.ts +42 -0
- package/dist/cdk/bundling.d.ts.map +1 -0
- package/dist/cdk/bundling.js +72 -0
- package/dist/cdk/bundling.test.d.ts +2 -0
- package/dist/cdk/bundling.test.d.ts.map +1 -0
- package/dist/cdk/bundling.test.js +80 -0
- package/dist/cdk/compute/compute.d.ts +33 -0
- package/dist/cdk/compute/compute.d.ts.map +1 -0
- package/dist/cdk/compute/compute.js +28 -0
- package/dist/cdk/compute/default-compute-factory.d.ts +33 -0
- package/dist/cdk/compute/default-compute-factory.d.ts.map +1 -0
- package/dist/cdk/compute/default-compute-factory.js +3 -0
- package/dist/cdk/index.d.ts +92 -12
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +141 -25
- package/dist/cdk/internal.d.ts +25 -0
- package/dist/cdk/internal.d.ts.map +1 -0
- package/dist/cdk/internal.js +27 -0
- package/dist/cdk/mixins.d.ts +18 -4
- package/dist/cdk/mixins.d.ts.map +1 -1
- package/dist/cdk/mixins.js +31 -7
- package/dist/cdk/mixins.test.js +45 -0
- package/dist/common/index.d.ts +9 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/hosting-secrets.d.ts +48 -0
- package/dist/hosting-secrets.d.ts.map +1 -0
- package/dist/hosting-secrets.js +57 -0
- package/dist/hosting-secrets.test.d.ts +2 -0
- package/dist/hosting-secrets.test.d.ts.map +1 -0
- package/dist/hosting-secrets.test.js +81 -0
- package/dist/hosting.d.ts +88 -6
- package/dist/hosting.d.ts.map +1 -1
- package/dist/hosting.js +83 -24
- package/dist/hosting.test.js +158 -10
- package/dist/index.cdk.d.ts +13 -11
- package/dist/index.cdk.d.ts.map +1 -1
- package/dist/index.cdk.js +13 -8
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/lambda-handler.test.js +66 -0
- package/dist/pipeline/index.d.ts +24 -2
- package/dist/pipeline/index.d.ts.map +1 -1
- package/dist/pipeline/index.js +41 -1
- package/dist/pipeline.test.d.ts +2 -0
- package/dist/pipeline.test.d.ts.map +1 -0
- package/dist/pipeline.test.js +47 -0
- package/dist/rpc.d.ts +21 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +46 -3
- package/dist/rpc.test.js +58 -1
- package/dist/scripts/config.d.ts +15 -0
- package/dist/scripts/config.d.ts.map +1 -0
- package/dist/scripts/config.js +29 -0
- package/dist/scripts/deploy.d.ts.map +1 -1
- package/dist/scripts/deploy.js +4 -0
- package/dist/scripts/dev-server.d.ts +8 -0
- package/dist/scripts/dev-server.d.ts.map +1 -1
- package/dist/scripts/dev-server.js +31 -0
- package/dist/scripts/generate-client.d.ts.map +1 -1
- package/dist/scripts/generate-client.js +9 -4
- package/dist/scripts/generate-client.test.js +19 -4
- package/dist/scripts/index.d.ts +13 -10
- package/dist/scripts/index.d.ts.map +1 -1
- package/dist/scripts/index.js +11 -8
- package/dist/scripts/preflight-credentials.d.ts +30 -0
- package/dist/scripts/preflight-credentials.d.ts.map +1 -0
- package/dist/scripts/preflight-credentials.js +108 -0
- package/dist/scripts/preflight-credentials.test.d.ts +2 -0
- package/dist/scripts/preflight-credentials.test.d.ts.map +1 -0
- package/dist/scripts/preflight-credentials.test.js +77 -0
- package/dist/scripts/sandbox-args.test.d.ts +2 -0
- package/dist/scripts/sandbox-args.test.d.ts.map +1 -0
- package/dist/scripts/sandbox-args.test.js +77 -0
- package/dist/scripts/sandbox.d.ts +52 -0
- package/dist/scripts/sandbox.d.ts.map +1 -1
- package/dist/scripts/sandbox.js +92 -15
- package/dist/scripts/secret.d.ts +15 -0
- package/dist/scripts/secret.d.ts.map +1 -0
- package/dist/scripts/secret.js +29 -0
- package/dist/scripts/secret.test.d.ts +2 -0
- package/dist/scripts/secret.test.d.ts.map +1 -0
- package/dist/scripts/secret.test.js +28 -0
- package/dist/scripts/telemetry.test.js +2 -0
- package/dist/scripts/typegen.d.ts +15 -0
- package/dist/scripts/typegen.d.ts.map +1 -0
- package/dist/scripts/typegen.js +16 -0
- package/dist/secret-naming.d.ts +58 -0
- package/dist/secret-naming.d.ts.map +1 -0
- package/dist/secret-naming.js +67 -0
- package/dist/secret-naming.test.d.ts +2 -0
- package/dist/secret-naming.test.d.ts.map +1 -0
- package/dist/secret-naming.test.js +40 -0
- package/dist/telemetry/environment.d.ts.map +1 -1
- package/dist/telemetry/environment.js +3 -1
- package/dist/telemetry/telemetry.test.js +10 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -1
- package/src/cdk/__fixtures__/import-meta-handler.ts +16 -0
- package/src/cdk/blocks-backend.test.ts +308 -237
- package/src/cdk/blocks-backend.ts +98 -77
- package/src/cdk/blocks-defaults.test.ts +27 -0
- package/src/cdk/blocks-defaults.ts +75 -0
- package/src/cdk/blocks-stack.test.ts +160 -110
- package/src/cdk/bundling.test.ts +90 -0
- package/src/cdk/bundling.ts +76 -0
- package/src/cdk/compute/compute.ts +37 -0
- package/src/cdk/compute/default-compute-factory.ts +37 -0
- package/src/cdk/index.ts +178 -27
- package/src/cdk/internal.ts +30 -0
- package/src/cdk/mixins.test.ts +56 -1
- package/src/cdk/mixins.ts +32 -7
- package/src/common/index.ts +9 -0
- package/src/hosting-secrets.test.ts +106 -0
- package/src/hosting-secrets.ts +106 -0
- package/src/hosting.test.ts +244 -63
- package/src/hosting.ts +180 -68
- package/src/index.cdk.ts +79 -36
- package/src/index.ts +35 -16
- package/src/lambda-handler.test.ts +74 -0
- package/src/pipeline/index.ts +64 -11
- package/src/pipeline.test.ts +55 -0
- package/src/rpc.test.ts +66 -1
- package/src/rpc.ts +60 -3
- package/src/scripts/config.ts +35 -0
- package/src/scripts/deploy.ts +5 -0
- package/src/scripts/dev-server.ts +40 -0
- package/src/scripts/generate-client.test.ts +43 -8
- package/src/scripts/generate-client.ts +70 -65
- package/src/scripts/index.ts +20 -17
- package/src/scripts/preflight-credentials.test.ts +110 -0
- package/src/scripts/preflight-credentials.ts +131 -0
- package/src/scripts/sandbox-args.test.ts +92 -0
- package/src/scripts/sandbox.ts +102 -15
- package/src/scripts/secret.test.ts +35 -0
- package/src/scripts/secret.ts +35 -0
- package/src/scripts/telemetry.test.ts +2 -0
- package/src/scripts/typegen.ts +18 -0
- package/src/secret-naming.test.ts +59 -0
- package/src/secret-naming.ts +99 -0
- package/src/telemetry/environment.ts +3 -1
- package/src/telemetry/telemetry.test.ts +12 -0
- package/src/version.ts +1 -1
package/src/cdk/mixins.ts
CHANGED
|
@@ -6,13 +6,36 @@ import type { IConstruct } from 'constructs';
|
|
|
6
6
|
import type { IMixin } from 'constructs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Property names used across CloudFormation resources to express deletion
|
|
10
|
+
* protection. L2 constructs and most L1s use `deletionProtection` (e.g. RDS
|
|
11
|
+
* clusters and instances, ELBv2 load balancers), while others spell it
|
|
12
|
+
* `deletionProtectionEnabled` (e.g. the DynamoDB `CfnTable` behind an L2
|
|
13
|
+
* `Table`, Aurora DSQL clusters).
|
|
14
|
+
*/
|
|
15
|
+
const DELETION_PROTECTION_PROPERTIES = ['deletionProtection', 'deletionProtectionEnabled'] as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Disables deletion protection on any construct that exposes a deletion
|
|
19
|
+
* protection property (e.g. RDS clusters, RDS instances, DynamoDB tables).
|
|
20
|
+
* Uses duck-typing so it automatically covers current and future resource
|
|
21
|
+
* types, matching both the `deletionProtection` and
|
|
22
|
+
* `deletionProtectionEnabled` spellings.
|
|
23
|
+
*
|
|
24
|
+
* Note that a DynamoDB L2 `Table` only accepts `deletionProtection` as a prop
|
|
25
|
+
* and does not re-expose it, so tables are matched through their underlying
|
|
26
|
+
* L1 `CfnTable.deletionProtectionEnabled`.
|
|
12
27
|
*
|
|
13
28
|
* Intended for sandbox teardown — use in the CDK layer alongside
|
|
14
29
|
* `RemovalPolicies.of(stack).destroy()` to ensure `sandbox:destroy` can
|
|
15
|
-
* delete the entire stack without manual cleanup.
|
|
30
|
+
* delete the entire stack without manual cleanup. DynamoDB refuses
|
|
31
|
+
* `DeleteTable` while deletion protection is enabled, regardless of the
|
|
32
|
+
* CloudFormation `DeletionPolicy`.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated Prefer the stack-wide `defaults` prop on `BlocksStack`/`BlocksBackend`
|
|
35
|
+
* (`defaults: BlocksPresets.sandbox` / `.production`, or `sandboxMode ? … : …`).
|
|
36
|
+
* Amazon-authored Building Blocks now read removal policy + deletion protection
|
|
37
|
+
* from `defaults`, so this mixin is no longer needed; it is retained only for
|
|
38
|
+
* backward compatibility.
|
|
16
39
|
*
|
|
17
40
|
* @example
|
|
18
41
|
* ```ts
|
|
@@ -27,15 +50,17 @@ import type { IMixin } from 'constructs';
|
|
|
27
50
|
*/
|
|
28
51
|
export class SandboxDisableDeletionProtection extends Mixin implements IMixin {
|
|
29
52
|
supports(construct: any): boolean {
|
|
30
|
-
return
|
|
53
|
+
return DELETION_PROTECTION_PROPERTIES.some((property) => property in construct);
|
|
31
54
|
}
|
|
32
55
|
applyTo(node: IConstruct): void {
|
|
33
56
|
// Only flip explicitly-enabled protection. When undefined (the default),
|
|
34
57
|
// deletion protection is already off — setting it to false would emit the
|
|
35
58
|
// property in the CloudFormation template, which breaks Aurora DB instances
|
|
36
59
|
// (RDS rejects DeletionProtection on cluster members).
|
|
37
|
-
|
|
38
|
-
(node as any)
|
|
60
|
+
for (const property of DELETION_PROTECTION_PROPERTIES) {
|
|
61
|
+
if ((node as any)[property] === true) {
|
|
62
|
+
(node as any)[property] = false;
|
|
63
|
+
}
|
|
39
64
|
}
|
|
40
65
|
}
|
|
41
66
|
}
|
package/src/common/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { StackProps } from 'aws-cdk-lib';
|
|
5
5
|
import type { Construct } from 'constructs';
|
|
6
|
+
import type { BlocksDefaults } from '../cdk/blocks-defaults.js';
|
|
6
7
|
import { CORE_VERSION } from '../version.js';
|
|
7
8
|
import { OFFICIAL_BB_NAMES } from './official-bb-names.generated.js';
|
|
8
9
|
export { OFFICIAL_BB_NAMES } from './official-bb-names.generated.js';
|
|
@@ -325,6 +326,14 @@ export function computeScopeFullId(scope: { id: string; parent?: any }) {
|
|
|
325
326
|
export interface BlocksStackProps extends StackProps {
|
|
326
327
|
backendHandlerPath: string;
|
|
327
328
|
backendCDKPath: string;
|
|
329
|
+
/**
|
|
330
|
+
* Stack-wide infrastructure defaults applied to every Building Block (removal
|
|
331
|
+
* policy, deletion protection, …). Start from `BlocksPresets.sandbox` or
|
|
332
|
+
* `BlocksPresets.production` and override individual fields as needed. Any
|
|
333
|
+
* field a block also exposes as a per-block option is overridden by that
|
|
334
|
+
* option. See `BlocksDefaults` in `@aws-blocks/core/cdk`.
|
|
335
|
+
*/
|
|
336
|
+
defaults: BlocksDefaults;
|
|
328
337
|
}
|
|
329
338
|
|
|
330
339
|
export class BlocksStack {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import assert from 'node:assert';
|
|
5
|
+
import { describe, it } from 'node:test';
|
|
6
|
+
import { config, secret } from '@aws-blocks/hosting';
|
|
7
|
+
import {
|
|
8
|
+
collectSynthMarkers,
|
|
9
|
+
partitionEnvironment,
|
|
10
|
+
resolveDomainNames,
|
|
11
|
+
resolveSecretsAtSynth,
|
|
12
|
+
} from './hosting-secrets.js';
|
|
13
|
+
|
|
14
|
+
void describe('partitionEnvironment()', () => {
|
|
15
|
+
void it('splits plain / managed (secret+config)', () => {
|
|
16
|
+
const { plain, managed } = partitionEnvironment({
|
|
17
|
+
FLAG: 'on',
|
|
18
|
+
STRIPE_KEY: secret('STRIPE_KEY'),
|
|
19
|
+
FEATURE_FLAGS: config('FEATURE_FLAGS'),
|
|
20
|
+
});
|
|
21
|
+
assert.deepStrictEqual(plain, { FLAG: 'on' });
|
|
22
|
+
assert.deepStrictEqual(managed.map((m) => `${m.key}:${m.kind}`).sort(), [
|
|
23
|
+
'FEATURE_FLAGS:config',
|
|
24
|
+
'STRIPE_KEY:secret',
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
void it('rejects env key / marker key mismatch', () => {
|
|
29
|
+
assert.throws(
|
|
30
|
+
() => partitionEnvironment({ STRIPE_KEY: secret('OTHER') }),
|
|
31
|
+
/must match the environment variable name/,
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
void it('handles undefined', () => {
|
|
36
|
+
const { plain, managed, byo } = partitionEnvironment(undefined);
|
|
37
|
+
assert.deepStrictEqual(plain, {});
|
|
38
|
+
assert.strictEqual(managed.length, 0);
|
|
39
|
+
assert.strictEqual(byo.length, 0);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
void describe('collectSynthMarkers()', () => {
|
|
44
|
+
void it('gathers domain markers, deduped by key', () => {
|
|
45
|
+
const markers = collectSynthMarkers(['example.com', config('DOMAIN_PROD'), config('DOMAIN_PROD')]);
|
|
46
|
+
assert.deepStrictEqual(
|
|
47
|
+
markers.map((m) => m.key),
|
|
48
|
+
['DOMAIN_PROD'],
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
void it('returns nothing when no markers', () => {
|
|
52
|
+
assert.deepStrictEqual(collectSynthMarkers('example.com'), []);
|
|
53
|
+
assert.deepStrictEqual(collectSynthMarkers(undefined), []);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
void describe('resolveSecretsAtSynth() — Blocks namespaces', () => {
|
|
58
|
+
void it('config marker resolves under /blocks/config (SSM leading-slash)', async () => {
|
|
59
|
+
const seen: string[] = [];
|
|
60
|
+
const resolved = await resolveSecretsAtSynth([config('DOMAIN_PROD')], async (name) => {
|
|
61
|
+
seen.push(name);
|
|
62
|
+
return 'prod.example.com';
|
|
63
|
+
});
|
|
64
|
+
assert.deepStrictEqual(seen, ['/blocks/config/DOMAIN_PROD']);
|
|
65
|
+
assert.strictEqual(resolved.get('DOMAIN_PROD'), 'prod.example.com');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
void it('secret marker resolves under /blocks/secrets (Secrets Manager slash-free)', async () => {
|
|
69
|
+
const seen: string[] = [];
|
|
70
|
+
await resolveSecretsAtSynth([secret('API_KEY')], async (name) => {
|
|
71
|
+
seen.push(name);
|
|
72
|
+
return 'k';
|
|
73
|
+
});
|
|
74
|
+
assert.deepStrictEqual(seen, ['blocks/secrets/API_KEY']);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
void it('throws an actionable error when a value is not set', async () => {
|
|
78
|
+
await assert.rejects(
|
|
79
|
+
resolveSecretsAtSynth([config('DOMAIN_PROD')], async () => {
|
|
80
|
+
const e = new Error('not found');
|
|
81
|
+
e.name = 'ParameterNotFound';
|
|
82
|
+
throw e;
|
|
83
|
+
}),
|
|
84
|
+
/config 'DOMAIN_PROD' is referenced/,
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
void describe('resolveDomainNames()', () => {
|
|
90
|
+
void it('replaces markers with resolved literals, preserving shape', () => {
|
|
91
|
+
const resolved = new Map([['DOMAIN_PROD', 'prod.example.com']]);
|
|
92
|
+
assert.strictEqual(resolveDomainNames(config('DOMAIN_PROD'), resolved), 'prod.example.com');
|
|
93
|
+
assert.deepStrictEqual(resolveDomainNames(['www.example.com', config('DOMAIN_PROD')], resolved), [
|
|
94
|
+
'www.example.com',
|
|
95
|
+
'prod.example.com',
|
|
96
|
+
]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
void it('throws if a marker reached the sync path unresolved', () => {
|
|
100
|
+
assert.throws(() => resolveDomainNames(config('DOMAIN_PROD'), new Map()), /requires async resolution/);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
void it('passes literal domains through untouched', () => {
|
|
104
|
+
assert.strictEqual(resolveDomainNames('example.com', new Map()), 'example.com');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolution glue between the dependency-free `secret()` / `config()` markers
|
|
6
|
+
* (defined in `@aws-blocks/hosting`) and the `Hosting` CDK block.
|
|
7
|
+
*
|
|
8
|
+
* Delegates to the shared `@aws-blocks/hosting` engine, pinning only the Blocks
|
|
9
|
+
* namespaces (`/blocks/secrets`, `/blocks/config`). The store is derived from the
|
|
10
|
+
* marker's kind (`secret` → Secrets Manager, `config` → SSM), and BYO
|
|
11
|
+
* `ISecret`/`IParameter` handles are wired identically.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { ManagedValue } from '@aws-blocks/hosting';
|
|
17
|
+
import {
|
|
18
|
+
type ByoBinding,
|
|
19
|
+
type DomainNameInput as LeafDomainNameInput,
|
|
20
|
+
type EnvValue as LeafEnvValue,
|
|
21
|
+
assertMarkersExistAtSynth as leafAssertMarkersExistAtSynth,
|
|
22
|
+
collectSynthMarkers as leafCollectSynthMarkers,
|
|
23
|
+
partitionEnvironment as leafPartitionEnvironment,
|
|
24
|
+
resolveDomainNames as leafResolveDomainNames,
|
|
25
|
+
resolveSecretsAtSynth as leafResolveSecretsAtSynth,
|
|
26
|
+
type SecretFetcher,
|
|
27
|
+
type StoreConfig,
|
|
28
|
+
wireByo as leafWireByo,
|
|
29
|
+
wireManagedValue as leafWireManagedValue,
|
|
30
|
+
} from '@aws-blocks/hosting/constructs';
|
|
31
|
+
import type * as cdk from 'aws-cdk-lib';
|
|
32
|
+
import { blocksStoreConfig } from './secret-naming.js';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Layer a caller's per-kind store config over the pinned Blocks defaults. Shallow
|
|
36
|
+
* and per-kind: the Blocks `/blocks/*` prefix stays the default, but any field the
|
|
37
|
+
* app sets (`prefix`, `stage`, `cacheTtlSeconds`) wins.
|
|
38
|
+
*/
|
|
39
|
+
function mergeBlocksStoreConfig(override?: StoreConfig): StoreConfig {
|
|
40
|
+
const base = blocksStoreConfig();
|
|
41
|
+
if (!override) return base;
|
|
42
|
+
return {
|
|
43
|
+
secretStore: { ...base.secretStore, ...override.secretStore },
|
|
44
|
+
configStore: { ...base.configStore, ...override.configStore },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A `compute.environment` value: a literal, a managed marker, or a BYO CDK handle. */
|
|
49
|
+
export type EnvValue = LeafEnvValue;
|
|
50
|
+
|
|
51
|
+
/** A custom-domain name: a literal, a managed marker, or a mix in an array. */
|
|
52
|
+
export type DomainNameInput = LeafDomainNameInput;
|
|
53
|
+
|
|
54
|
+
/** Split an environment map into plain literals, managed markers, and BYO handles. */
|
|
55
|
+
export function partitionEnvironment(environment: Record<string, EnvValue> | undefined): {
|
|
56
|
+
plain: Record<string, string>;
|
|
57
|
+
managed: ManagedValue[];
|
|
58
|
+
byo: ByoBinding[];
|
|
59
|
+
} {
|
|
60
|
+
return leafPartitionEnvironment(environment);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Every managed marker requiring a synth-time fetch (domain markers only). */
|
|
64
|
+
export function collectSynthMarkers(domainName: DomainNameInput | undefined): ManagedValue[] {
|
|
65
|
+
return leafCollectSynthMarkers(domainName);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Resolve managed markers to plaintext at synth time under the Blocks namespaces.
|
|
70
|
+
* Throws a clear, actionable error if a referenced value was never set. An optional
|
|
71
|
+
* `storeConfig` overrides the pinned Blocks prefix/stage per kind.
|
|
72
|
+
*/
|
|
73
|
+
export async function resolveSecretsAtSynth(
|
|
74
|
+
markers: ManagedValue[],
|
|
75
|
+
fetcher?: SecretFetcher,
|
|
76
|
+
storeConfig?: StoreConfig,
|
|
77
|
+
): Promise<Map<string, string>> {
|
|
78
|
+
return leafResolveSecretsAtSynth(markers, { ...mergeBlocksStoreConfig(storeConfig), fetcher });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Resolve domain markers to literals using the synth-resolved value map. */
|
|
82
|
+
export function resolveDomainNames(domainName: DomainNameInput, resolved: Map<string, string>): string | string[] {
|
|
83
|
+
return leafResolveDomainNames(domainName, resolved);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Fail synth (deploy) when a referenced `environment` marker has no value set —
|
|
88
|
+
* existence only, never fetching the value. Uses the Blocks namespaces (with an
|
|
89
|
+
* optional per-kind `storeConfig` override), matching how the values are wired.
|
|
90
|
+
*/
|
|
91
|
+
export async function assertMarkersExistAtSynth(markers: ManagedValue[], storeConfig?: StoreConfig): Promise<void> {
|
|
92
|
+
return leafAssertMarkersExistAtSynth(markers, mergeBlocksStoreConfig(storeConfig));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Wire a runtime managed marker under the Blocks namespace (store from kind). An
|
|
97
|
+
* optional `storeConfig` overrides the pinned prefix/stage/cacheTtlSeconds per kind.
|
|
98
|
+
*/
|
|
99
|
+
export function wireManagedValue(fn: cdk.aws_lambda.Function, marker: ManagedValue, storeConfig?: StoreConfig): void {
|
|
100
|
+
leafWireManagedValue(fn, marker, mergeBlocksStoreConfig(storeConfig));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Wire a runtime BYO handle (grant + inject locator). Honors an optional `storeConfig`. */
|
|
104
|
+
export function wireByo(fn: cdk.aws_lambda.Function, binding: ByoBinding, storeConfig?: StoreConfig): void {
|
|
105
|
+
leafWireByo(fn, binding, mergeBlocksStoreConfig(storeConfig));
|
|
106
|
+
}
|