cdk-local 0.9.0 → 0.11.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 +2 -0
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +200 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{local-start-service-Rit5YxNR.js → local-start-service-BwAE8kN7.js} +157 -13
- package/dist/local-start-service-BwAE8kN7.js.map +1 -0
- package/package.json +1 -1
- package/dist/local-start-service-Rit5YxNR.js.map +0 -1
package/README.md
CHANGED
|
@@ -108,6 +108,8 @@ Use this for fast iteration on Lambda code, API routing checks, and container ta
|
|
|
108
108
|
|
|
109
109
|
Once your stack is deployed to AWS (via the AWS CDK CLI or any other tool), pass `--from-cfn-stack <StackName>` and cdk-local reads the deployed CloudFormation stack to inject real ARNs, Secrets values, and IAM credentials (resolved from your current AWS profile) into the local execution.
|
|
110
110
|
|
|
111
|
+
For Lambda (`invoke`, `start-api`), this also recovers env-var values that CloudFormation resolved at deploy time but `ListStackResources` does not expose — e.g. `SIBLING_ARN: Fn::GetAtt <OtherFunction>.Arn`. cdk-local reads the deployed function's own resolved `Environment.Variables` (via `lambda:GetFunctionConfiguration`) and fills those keys, so a Lambda that calls a sibling Lambda by ARN runs locally without a manual `--env-vars` entry. (These values enter the local container env in plaintext; Lambda env vars are a non-secret property, so this exposes nothing the deployed function doesn't already surface to any caller with `lambda:GetFunctionConfiguration`.)
|
|
112
|
+
|
|
111
113
|
#### HTTP APIs & Function URLs — `start-api` (the headline use case)
|
|
112
114
|
|
|
113
115
|
A local API talking to real AWS — point a frontend at it for end-to-end debugging, including real Cognito JWT verification.
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as createLocalStartApiCommand, r as createLocalRunTaskCommand, t as createLocalStartServiceCommand,
|
|
2
|
+
import { i as createLocalStartApiCommand, r as createLocalRunTaskCommand, t as createLocalStartServiceCommand, v as createLocalInvokeCommand } from "./local-start-service-BwAE8kN7.js";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/index.ts
|
|
6
6
|
const program = new Command();
|
|
7
|
-
program.name("cdkl").description("Run AWS CDK stacks locally with Docker.").version("0.
|
|
7
|
+
program.name("cdkl").description("Run AWS CDK stacks locally with Docker.").version("0.11.0");
|
|
8
8
|
program.addCommand(createLocalInvokeCommand());
|
|
9
9
|
program.addCommand(createLocalStartApiCommand());
|
|
10
10
|
program.addCommand(createLocalRunTaskCommand());
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { createLocalInvokeCommand } from './commands/local-invoke.js';\nimport { createLocalStartApiCommand } from './commands/local-start-api.js';\nimport { createLocalRunTaskCommand } from './commands/local-run-task.js';\nimport { createLocalStartServiceCommand } from './commands/local-start-service.js';\n\ndeclare const __CDK_LOCAL_VERSION__: string;\n\nconst program = new Command();\nprogram\n .name('cdkl')\n .description('Run AWS CDK stacks locally with Docker.')\n .version(__CDK_LOCAL_VERSION__);\n\nprogram.addCommand(createLocalInvokeCommand());\nprogram.addCommand(createLocalStartApiCommand());\nprogram.addCommand(createLocalRunTaskCommand());\nprogram.addCommand(createLocalStartServiceCommand());\n\nvoid program.parseAsync(process.argv);\n"],"mappings":";;;;;AAUA,MAAM,UAAU,IAAI,SAAS;AAC7B,QACG,KAAK,OAAO,CACZ,YAAY,0CAA0C,CACtD,
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { createLocalInvokeCommand } from './commands/local-invoke.js';\nimport { createLocalStartApiCommand } from './commands/local-start-api.js';\nimport { createLocalRunTaskCommand } from './commands/local-run-task.js';\nimport { createLocalStartServiceCommand } from './commands/local-start-service.js';\n\ndeclare const __CDK_LOCAL_VERSION__: string;\n\nconst program = new Command();\nprogram\n .name('cdkl')\n .description('Run AWS CDK stacks locally with Docker.')\n .version(__CDK_LOCAL_VERSION__);\n\nprogram.addCommand(createLocalInvokeCommand());\nprogram.addCommand(createLocalStartApiCommand());\nprogram.addCommand(createLocalRunTaskCommand());\nprogram.addCommand(createLocalStartServiceCommand());\n\nvoid program.parseAsync(process.argv);\n"],"mappings":";;;;;AAUA,MAAM,UAAU,IAAI,SAAS;AAC7B,QACG,KAAK,OAAO,CACZ,YAAY,0CAA0C,CACtD,iBAA8B;AAEjC,QAAQ,WAAW,0BAA0B,CAAC;AAC9C,QAAQ,WAAW,4BAA4B,CAAC;AAChD,QAAQ,WAAW,2BAA2B,CAAC;AAC/C,QAAQ,WAAW,gCAAgC,CAAC;AAE/C,QAAQ,WAAW,QAAQ,KAAK"}
|
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ interface LocalStateProvider {
|
|
|
43
43
|
readonly label: string;
|
|
44
44
|
load(stackName: string, synthRegion: string | undefined): Promise<LocalStateRecord | undefined>;
|
|
45
45
|
buildCrossStackResolver(consumerRegion: string): Promise<CrossStackResolver | undefined>;
|
|
46
|
+
resolveDeployedFunctionEnv?(functionPhysicalId: string): Promise<Record<string, string> | undefined>;
|
|
46
47
|
dispose(): void;
|
|
47
48
|
}
|
|
48
49
|
//#endregion
|
|
@@ -75,6 +76,59 @@ interface CdkLocalEmbedConfig {
|
|
|
75
76
|
envPrefix?: string;
|
|
76
77
|
}
|
|
77
78
|
//#endregion
|
|
79
|
+
//#region src/types/resource.d.ts
|
|
80
|
+
interface CloudFormationTemplate {
|
|
81
|
+
AWSTemplateFormatVersion?: string;
|
|
82
|
+
Description?: string;
|
|
83
|
+
Parameters?: Record<string, TemplateParameter>;
|
|
84
|
+
Resources: Record<string, TemplateResource>;
|
|
85
|
+
Outputs?: Record<string, TemplateOutput>;
|
|
86
|
+
Conditions?: Record<string, unknown>;
|
|
87
|
+
Mappings?: Record<string, unknown>;
|
|
88
|
+
Transform?: unknown;
|
|
89
|
+
Rules?: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
interface TemplateParameter {
|
|
92
|
+
Type: string;
|
|
93
|
+
Default?: unknown;
|
|
94
|
+
Description?: string;
|
|
95
|
+
AllowedValues?: unknown[];
|
|
96
|
+
AllowedPattern?: string;
|
|
97
|
+
ConstraintDescription?: string;
|
|
98
|
+
}
|
|
99
|
+
interface TemplateResource {
|
|
100
|
+
Type: string;
|
|
101
|
+
Properties?: Record<string, unknown>;
|
|
102
|
+
DependsOn?: string | readonly string[];
|
|
103
|
+
Condition?: string;
|
|
104
|
+
Metadata?: Record<string, unknown>;
|
|
105
|
+
CreationPolicy?: Record<string, unknown>;
|
|
106
|
+
UpdatePolicy?: Record<string, unknown>;
|
|
107
|
+
DeletionPolicy?: 'Delete' | 'Retain' | 'Snapshot';
|
|
108
|
+
UpdateReplacePolicy?: 'Delete' | 'Retain' | 'Snapshot';
|
|
109
|
+
}
|
|
110
|
+
interface TemplateOutput {
|
|
111
|
+
Value: unknown;
|
|
112
|
+
Description?: string;
|
|
113
|
+
Export?: {
|
|
114
|
+
Name: string;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/synthesis/assembly-reader.d.ts
|
|
119
|
+
interface StackInfo {
|
|
120
|
+
stackName: string;
|
|
121
|
+
displayName: string;
|
|
122
|
+
artifactId: string;
|
|
123
|
+
template: CloudFormationTemplate;
|
|
124
|
+
assetManifestPath?: string | undefined;
|
|
125
|
+
dependencyNames: string[];
|
|
126
|
+
region?: string | undefined;
|
|
127
|
+
account?: string | undefined;
|
|
128
|
+
terminationProtection?: boolean | undefined;
|
|
129
|
+
nestedTemplates?: Record<string, string> | undefined;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
78
132
|
//#region src/cli/commands/local-invoke.d.ts
|
|
79
133
|
interface CreateLocalInvokeCommandOptions {
|
|
80
134
|
extraStateProviders?: ExtraStateProviders;
|
|
@@ -82,6 +136,77 @@ interface CreateLocalInvokeCommandOptions {
|
|
|
82
136
|
}
|
|
83
137
|
declare function createLocalInvokeCommand(opts?: CreateLocalInvokeCommandOptions): Command;
|
|
84
138
|
//#endregion
|
|
139
|
+
//#region src/local/httpv2-service-integration.d.ts
|
|
140
|
+
type SupportedSubtype = 'EventBridge-PutEvents' | 'SQS-SendMessage' | 'SQS-ReceiveMessage' | 'SQS-DeleteMessage' | 'SQS-PurgeQueue' | 'Kinesis-PutRecord' | 'StepFunctions-StartExecution' | 'StepFunctions-StartSyncExecution' | 'StepFunctions-StopExecution' | 'AppConfig-GetConfiguration';
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/local/integration-response-selector.d.ts
|
|
143
|
+
interface IntegrationResponseEntry {
|
|
144
|
+
StatusCode: string;
|
|
145
|
+
SelectionPattern?: string;
|
|
146
|
+
ResponseParameters?: Record<string, string>;
|
|
147
|
+
ResponseTemplates?: Record<string, string>;
|
|
148
|
+
ContentHandling?: string;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/local/rest-v1-integrations.d.ts
|
|
152
|
+
interface MockIntegrationConfig {
|
|
153
|
+
kind: 'mock';
|
|
154
|
+
requestTemplate: string | undefined;
|
|
155
|
+
responses: IntegrationResponseEntry[];
|
|
156
|
+
}
|
|
157
|
+
interface HttpProxyIntegrationConfig {
|
|
158
|
+
kind: 'http-proxy';
|
|
159
|
+
uri: string;
|
|
160
|
+
integrationHttpMethod?: string;
|
|
161
|
+
requestParameters?: Record<string, string>;
|
|
162
|
+
responses: IntegrationResponseEntry[];
|
|
163
|
+
}
|
|
164
|
+
interface HttpIntegrationConfig {
|
|
165
|
+
kind: 'http';
|
|
166
|
+
uri: string;
|
|
167
|
+
integrationHttpMethod?: string;
|
|
168
|
+
requestParameters?: Record<string, string>;
|
|
169
|
+
requestTemplates?: Record<string, string>;
|
|
170
|
+
responses: IntegrationResponseEntry[];
|
|
171
|
+
}
|
|
172
|
+
interface AwsLambdaIntegrationConfig {
|
|
173
|
+
kind: 'aws-lambda';
|
|
174
|
+
lambdaLogicalId: string;
|
|
175
|
+
requestTemplates?: Record<string, string>;
|
|
176
|
+
responses: IntegrationResponseEntry[];
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/local/route-discovery.d.ts
|
|
180
|
+
type RestV1IntegrationConfig = MockIntegrationConfig | HttpProxyIntegrationConfig | HttpIntegrationConfig | AwsLambdaIntegrationConfig;
|
|
181
|
+
interface DiscoveredRoute {
|
|
182
|
+
method: string;
|
|
183
|
+
pathPattern: string;
|
|
184
|
+
lambdaLogicalId: string;
|
|
185
|
+
source: 'http-api' | 'rest-v1' | 'function-url';
|
|
186
|
+
apiVersion: 'v1' | 'v2';
|
|
187
|
+
stage: string;
|
|
188
|
+
apiLogicalId?: string;
|
|
189
|
+
apiStackName?: string;
|
|
190
|
+
apiCdkPath?: string;
|
|
191
|
+
stageVariables?: Record<string, string> | null;
|
|
192
|
+
invokeMode?: 'BUFFERED' | 'RESPONSE_STREAM';
|
|
193
|
+
unsupported?: {
|
|
194
|
+
reason: string;
|
|
195
|
+
};
|
|
196
|
+
mockCors?: {
|
|
197
|
+
statusCode: number;
|
|
198
|
+
headers: Record<string, string>;
|
|
199
|
+
};
|
|
200
|
+
serviceIntegration?: {
|
|
201
|
+
subtype: SupportedSubtype;
|
|
202
|
+
requestParameters: Readonly<Record<string, unknown>>;
|
|
203
|
+
responseParameters?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
204
|
+
};
|
|
205
|
+
restV1Integration?: RestV1IntegrationConfig;
|
|
206
|
+
declaredAt: string;
|
|
207
|
+
}
|
|
208
|
+
declare function discoverRoutes(stacks: readonly StackInfo[]): DiscoveredRoute[];
|
|
209
|
+
//#endregion
|
|
85
210
|
//#region src/cli/commands/local-start-api.d.ts
|
|
86
211
|
interface CreateLocalStartApiCommandOptions {
|
|
87
212
|
extraStateProviders?: ExtraStateProviders;
|
|
@@ -114,10 +239,13 @@ declare class CfnLocalStateProvider implements LocalStateProvider {
|
|
|
114
239
|
private readonly cfnStackName;
|
|
115
240
|
private readonly region;
|
|
116
241
|
private client;
|
|
242
|
+
private lambdaClient;
|
|
117
243
|
private readonly clientOptions;
|
|
118
244
|
private disposed;
|
|
119
245
|
constructor(opts: CfnLocalStateProviderOptions);
|
|
120
246
|
private getClient;
|
|
247
|
+
private getLambdaClient;
|
|
248
|
+
resolveDeployedFunctionEnv(functionPhysicalId: string): Promise<Record<string, string> | undefined>;
|
|
121
249
|
load(_stackName: string, _synthRegion: string | undefined): Promise<LocalStateRecord | undefined>;
|
|
122
250
|
buildCrossStackResolver(_consumerRegion: string): Promise<CrossStackResolver | undefined>;
|
|
123
251
|
dispose(): void;
|
|
@@ -169,5 +297,76 @@ declare function translateLambdaResponse(payload: unknown, version: 'v1' | 'v2')
|
|
|
169
297
|
//#region src/local/docker-inspect.d.ts
|
|
170
298
|
declare function getContainerNetworkIp(containerId: string, networkName: string): Promise<string | undefined>;
|
|
171
299
|
//#endregion
|
|
172
|
-
|
|
300
|
+
//#region src/local/route-matcher.d.ts
|
|
301
|
+
interface RouteMatchResult {
|
|
302
|
+
route: DiscoveredRoute;
|
|
303
|
+
pathParameters: Record<string, string>;
|
|
304
|
+
}
|
|
305
|
+
declare function matchRoute(method: string, requestPath: string, routes: readonly DiscoveredRoute[]): RouteMatchResult | null;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/local/api-gateway-event.d.ts
|
|
308
|
+
interface HttpRequestSnapshot {
|
|
309
|
+
method: string;
|
|
310
|
+
rawUrl: string;
|
|
311
|
+
headers: Record<string, string[]>;
|
|
312
|
+
body: Buffer;
|
|
313
|
+
sourceIp?: string;
|
|
314
|
+
clientCert?: Record<string, unknown>;
|
|
315
|
+
}
|
|
316
|
+
interface MatchedRouteContext {
|
|
317
|
+
route: DiscoveredRoute;
|
|
318
|
+
pathParameters: Record<string, string>;
|
|
319
|
+
matchedPath: string;
|
|
320
|
+
}
|
|
321
|
+
declare function buildHttpApiV2Event(req: HttpRequestSnapshot, ctx: MatchedRouteContext, opts?: {
|
|
322
|
+
now?: () => Date;
|
|
323
|
+
}): Record<string, unknown>;
|
|
324
|
+
declare function buildRestV1Event(req: HttpRequestSnapshot, ctx: MatchedRouteContext, opts?: {
|
|
325
|
+
now?: () => Date;
|
|
326
|
+
}): Record<string, unknown>;
|
|
327
|
+
type AuthorizerEventOverlay = {
|
|
328
|
+
kind: 'lambda-rest-v1';
|
|
329
|
+
principalId?: string;
|
|
330
|
+
context?: Record<string, unknown>;
|
|
331
|
+
} | {
|
|
332
|
+
kind: 'lambda-http-v2';
|
|
333
|
+
principalId?: string;
|
|
334
|
+
context?: Record<string, unknown>;
|
|
335
|
+
} | {
|
|
336
|
+
kind: 'cognito-rest-v1';
|
|
337
|
+
claims: Record<string, unknown>;
|
|
338
|
+
} | {
|
|
339
|
+
kind: 'jwt-http-v2';
|
|
340
|
+
claims: Record<string, unknown>;
|
|
341
|
+
scopes?: string[];
|
|
342
|
+
};
|
|
343
|
+
declare function applyAuthorizerOverlay(event: Record<string, unknown>, overlay: AuthorizerEventOverlay): Record<string, unknown>;
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/local/websocket-route-discovery.d.ts
|
|
346
|
+
interface DiscoveredWebSocketApi {
|
|
347
|
+
apiLogicalId: string;
|
|
348
|
+
apiStackName: string;
|
|
349
|
+
declaredAt: string;
|
|
350
|
+
apiCdkPath?: string;
|
|
351
|
+
routeSelectionExpression: string;
|
|
352
|
+
stage: string;
|
|
353
|
+
routes: WebSocketRouteEntry[];
|
|
354
|
+
unsupported?: {
|
|
355
|
+
reason: string;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
interface WebSocketRouteEntry {
|
|
359
|
+
routeKey: string;
|
|
360
|
+
targetLambdaLogicalId: string;
|
|
361
|
+
lambdaStackName: string;
|
|
362
|
+
declaredAt: string;
|
|
363
|
+
}
|
|
364
|
+
declare function discoverWebSocketApis(stacks: readonly StackInfo[]): {
|
|
365
|
+
apis: DiscoveredWebSocketApi[];
|
|
366
|
+
errors: string[];
|
|
367
|
+
};
|
|
368
|
+
declare function discoverWebSocketApisOrThrow(stacks: readonly StackInfo[]): DiscoveredWebSocketApi[];
|
|
369
|
+
declare function parseSelectionExpressionPath(expr: string): string[];
|
|
370
|
+
//#endregion
|
|
371
|
+
export { type AuthorizerEventOverlay, type CdkLocalEmbedConfig, CfnLocalStateProvider, type CfnLocalStateProviderOptions, type CreateLocalInvokeCommandOptions, type CreateLocalRunTaskCommandOptions, type CreateLocalStartApiCommandOptions, type CreateLocalStartServiceCommandOptions, type CrossStackResolver, type DiscoveredRoute, type DiscoveredWebSocketApi, type ExtraStateProviders, type HttpRequestSnapshot, type LambdaArnResolveOutcome, type LocalStateProvider, type LocalStateProviderFactory, type LocalStateRecord, LocalStateSourceError, type LocalStateSourceOptions, type MatchedRouteContext, type RequestParameterContext, type ResolveParametersOutcome, type RestV1IntegrationConfig, type RouteMatchResult, type SubstitutionContext, type TranslatedHttpResponse, type WebSocketRouteEntry, applyAuthorizerOverlay, buildHttpApiV2Event, buildRestV1Event, createLocalInvokeCommand, createLocalRunTaskCommand, createLocalStartApiCommand, createLocalStartServiceCommand, createLocalStateProvider, discoverRoutes, discoverWebSocketApis, discoverWebSocketApisOrThrow, getContainerNetworkIp, isCfnFlagPresent, matchRoute, parseSelectionExpressionPath, pickRefLogicalId, rejectExplicitCfnStackWithMultipleStacks, resolveCfnRegion, resolveCfnStackName, resolveLambdaArnIntrinsic, resolveSelectionExpression, resolveServiceIntegrationParameters, translateLambdaResponse };
|
|
173
372
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types/state.ts","../src/local/state-resolver.ts","../src/local/local-state-provider.ts","../src/cli/commands/local-state-source.ts","../src/local/embed-config.ts","../src/cli/commands/local-invoke.ts","../src/cli/commands/local-start-api.ts","../src/cli/commands/local-run-task.ts","../src/cli/commands/local-start-service.ts","../src/local/cfn-local-state-provider.ts","../src/local/intrinsic-utils.ts","../src/local/intrinsic-lambda-arn.ts","../src/local/parameter-mapping.ts","../src/local/api-gateway-response.ts","../src/local/docker-inspect.ts"],"mappings":";;;;UAuLiB,aAAA;EAEf,UAAA;EAGA,YAAA;EAGA,UAAA,EAAY,MAAA;EAcZ,kBAAA,GAAqB,MAAA;EAGrB,UAAA,GAAa,MAAA;EAGb,YAAA;EAGA,QAAA,GAAW,MAAA;EAmBX,cAAA;EAMA,mBAAA;EAyBA,aAAA;AAAA;;;UCxIe,gBAAA;EACf,SAAA;EACA,MAAA;EACA,SAAA;EACA,SAAA;AAAA;AAAA,UAqBe,kBAAA;EAOf,aAAA,CAAc,UAAA,WAAqB,OAAA;EAQnC,qBAAA,CACE,aAAA,UACA,cAAA,UACA,UAAA,WACC,OAAA;AAAA;AAAA,UAGY,mBAAA;EAEf,SAAA,EAAW,MAAA,SAAe,aAAA;EAE1B,gBAAA,GAAmB,gBAAA;EAOnB,kBAAA,GAAqB,kBAAA;EAOrB,cAAA;AAAA;;;UCrJe,gBAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types/state.ts","../src/local/state-resolver.ts","../src/local/local-state-provider.ts","../src/cli/commands/local-state-source.ts","../src/local/embed-config.ts","../src/types/resource.ts","../src/synthesis/assembly-reader.ts","../src/cli/commands/local-invoke.ts","../src/local/httpv2-service-integration.ts","../src/local/integration-response-selector.ts","../src/local/rest-v1-integrations.ts","../src/local/route-discovery.ts","../src/cli/commands/local-start-api.ts","../src/cli/commands/local-run-task.ts","../src/cli/commands/local-start-service.ts","../src/local/cfn-local-state-provider.ts","../src/local/intrinsic-utils.ts","../src/local/intrinsic-lambda-arn.ts","../src/local/parameter-mapping.ts","../src/local/api-gateway-response.ts","../src/local/docker-inspect.ts","../src/local/route-matcher.ts","../src/local/api-gateway-event.ts","../src/local/websocket-route-discovery.ts"],"mappings":";;;;UAuLiB,aAAA;EAEf,UAAA;EAGA,YAAA;EAGA,UAAA,EAAY,MAAA;EAcZ,kBAAA,GAAqB,MAAA;EAGrB,UAAA,GAAa,MAAA;EAGb,YAAA;EAGA,QAAA,GAAW,MAAA;EAmBX,cAAA;EAMA,mBAAA;EAyBA,aAAA;AAAA;;;UCxIe,gBAAA;EACf,SAAA;EACA,MAAA;EACA,SAAA;EACA,SAAA;AAAA;AAAA,UAqBe,kBAAA;EAOf,aAAA,CAAc,UAAA,WAAqB,OAAA;EAQnC,qBAAA,CACE,aAAA,UACA,cAAA,UACA,UAAA,WACC,OAAA;AAAA;AAAA,UAGY,mBAAA;EAEf,SAAA,EAAW,MAAA,SAAe,aAAA;EAE1B,gBAAA,GAAmB,gBAAA;EAOnB,kBAAA,GAAqB,kBAAA;EAOrB,cAAA;AAAA;;;UCrJe,gBAAA;EAWf,SAAA,EAAW,MAAA,SAAe,aAAA;EAO1B,OAAA,EAAS,MAAA;EAOT,MAAA;AAAA;AAAA,UAsBe,kBAAA;EAAA,SAMN,KAAA;EAQT,IAAA,CAAK,SAAA,UAAmB,WAAA,uBAAkC,OAAA,CAAQ,gBAAA;EAalE,uBAAA,CAAwB,cAAA,WAAyB,OAAA,CAAQ,kBAAA;EA4BzD,0BAAA,EACE,kBAAA,WACC,OAAA,CAAQ,MAAA;EAKX,OAAA;AAAA;;;UC/Ge,uBAAA;EAOf,YAAA;EAEA,MAAA;EAEA,OAAA;EAMA,WAAA;EAAA,CAEC,GAAA;AAAA;AAAA,KAQS,yBAAA,IAA6B,OAAA,EAAS,uBAAA,KAA4B,kBAAA;AAAA,KAUlE,mBAAA,GAAsB,MAAA,SAAe,yBAAA;AAAA,iBAUjC,mBAAA,CAAoB,YAAA,oBAAgC,SAAA;AAAA,iBAapD,gBAAA,CAAiB,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wB,WAAA;EAAsB,OAAA,GAAU,MAAA;AAAA;EACxD,IAAA;EAAyB,MAAA,EAAQ,MAAA;AAAA;EACjC,IAAA;EAAqB,MAAA,EAAQ,MAAA;EAAyB,MAAA;AAAA;AAAA,iBAY5C,sBAAA,CACd,KAAA,EAAO,MAAA,mBACP,OAAA,EAAS,sBAAA,GACR,MAAA;;;UC3Pc,sBAAA;EAEf,YAAA;EAEA,YAAA;EAEA,UAAA;EAMA,UAAA;EAQA,wBAAA;EAOA,KAAA;EAaA,MAAA,EAAQ,mBAAA;EAiBR,WAAA;IAAgB,MAAA;EAAA;AAAA;AAAA,UAID,mBAAA;EAEf,QAAA;EAEA,qBAAA;EAEA,eAAA;EAEA,UAAA;AAAA;AAAA,iBAuBc,qBAAA,CAAsB,MAAA,WAAiB,SAAA;EACrD,IAAA,EAAM,sBAAA;EACN,MAAA;AAAA;AAAA,iBA8Bc,4BAAA,CACd,MAAA,WAAiB,SAAA,KAChB,sBAAA;AAAA,iBAgJa,4BAAA,CAA6B,IAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as resolveCfnRegion, S as rejectExplicitCfnStackWithMultipleStacks, T as CfnLocalStateProvider, _ as resolveLambdaArnIntrinsic, a as resolveSelectionExpression, b as createLocalStateProvider, c as translateLambdaResponse, d as buildRestV1Event, f as discoverWebSocketApis, g as pickRefLogicalId, h as discoverRoutes, i as createLocalStartApiCommand, l as applyAuthorizerOverlay, m as parseSelectionExpressionPath, n as getContainerNetworkIp, o as resolveServiceIntegrationParameters, p as discoverWebSocketApisOrThrow, r as createLocalRunTaskCommand, s as matchRoute, t as createLocalStartServiceCommand, u as buildHttpApiV2Event, v as createLocalInvokeCommand, w as resolveCfnStackName, x as isCfnFlagPresent, y as LocalStateSourceError } from "./local-start-service-BwAE8kN7.js";
|
|
2
2
|
|
|
3
|
-
export { CfnLocalStateProvider, LocalStateSourceError, createLocalInvokeCommand, createLocalRunTaskCommand, createLocalStartApiCommand, createLocalStartServiceCommand, createLocalStateProvider, getContainerNetworkIp, isCfnFlagPresent, pickRefLogicalId, rejectExplicitCfnStackWithMultipleStacks, resolveCfnRegion, resolveCfnStackName, resolveLambdaArnIntrinsic, resolveSelectionExpression, resolveServiceIntegrationParameters, translateLambdaResponse };
|
|
3
|
+
export { CfnLocalStateProvider, LocalStateSourceError, applyAuthorizerOverlay, buildHttpApiV2Event, buildRestV1Event, createLocalInvokeCommand, createLocalRunTaskCommand, createLocalStartApiCommand, createLocalStartServiceCommand, createLocalStateProvider, discoverRoutes, discoverWebSocketApis, discoverWebSocketApisOrThrow, getContainerNetworkIp, isCfnFlagPresent, matchRoute, parseSelectionExpressionPath, pickRefLogicalId, rejectExplicitCfnStackWithMultipleStacks, resolveCfnRegion, resolveCfnStackName, resolveLambdaArnIntrinsic, resolveSelectionExpression, resolveServiceIntegrationParameters, translateLambdaResponse };
|
|
@@ -8,6 +8,7 @@ import { AssumeRoleCommand, GetCallerIdentityCommand, STSClient } from "@aws-sdk
|
|
|
8
8
|
import { AssetManifestArtifact } from "@aws-cdk/cloud-assembly-api";
|
|
9
9
|
import { CdkAppMultiContext, NonInteractiveIoHost, Toolkit } from "@aws-cdk/toolkit-lib";
|
|
10
10
|
import { CloudFormationClient, DescribeStacksCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
|
|
11
|
+
import { GetFunctionConfigurationCommand, LambdaClient } from "@aws-sdk/client-lambda";
|
|
11
12
|
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
12
13
|
import { Readable } from "node:stream";
|
|
13
14
|
import { pipeline } from "node:stream/promises";
|
|
@@ -531,13 +532,18 @@ function resolveCdkPathToLogicalIds(input, index) {
|
|
|
531
532
|
* map built from `ListStackResources.StackResourceSummaries[]` (one
|
|
532
533
|
* entry per `(LogicalResourceId, PhysicalResourceId, ResourceType)`
|
|
533
534
|
* tuple).
|
|
534
|
-
* - `Fn::GetAtt: [<LogicalId>, <Attr>]` →
|
|
535
|
-
* `ListStackResources`
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
535
|
+
* - `Fn::GetAtt: [<LogicalId>, <Attr>]` → not resolvable from
|
|
536
|
+
* `ListStackResources` (which returns physical IDs only, no
|
|
537
|
+
* per-attribute values). For a Lambda function's OWN env vars this
|
|
538
|
+
* gap is closed by {@link CfnLocalStateProvider.resolveDeployedFunctionEnv}:
|
|
539
|
+
* because `--from-cfn-stack` means the consumer function is itself
|
|
540
|
+
* deployed, CloudFormation already resolved every intrinsic (incl.
|
|
541
|
+
* `Fn::GetAtt <Sibling>.Arn`) into the function's
|
|
542
|
+
* `Environment.Variables` at deploy time, so the env-substitution
|
|
543
|
+
* layer reads the concrete value back via
|
|
544
|
+
* `lambda:GetFunctionConfiguration`. Intrinsic values that are NOT a
|
|
545
|
+
* consumer-Lambda env var (e.g. an ECS container env entry) still
|
|
546
|
+
* warn-and-drop and can be overridden via `--env-vars`.
|
|
541
547
|
* - `Fn::ImportValue: <exportName>` → resolved via `ListExports`
|
|
542
548
|
* (paginated). Same-region only — CFn exports are region-scoped.
|
|
543
549
|
* - `Fn::GetStackOutput` → rejected with a clear pointer that the
|
|
@@ -574,6 +580,7 @@ var CfnLocalStateProvider = class {
|
|
|
574
580
|
cfnStackName;
|
|
575
581
|
region;
|
|
576
582
|
client;
|
|
583
|
+
lambdaClient;
|
|
577
584
|
clientOptions;
|
|
578
585
|
disposed = false;
|
|
579
586
|
constructor(opts) {
|
|
@@ -590,6 +597,37 @@ var CfnLocalStateProvider = class {
|
|
|
590
597
|
});
|
|
591
598
|
return this.client;
|
|
592
599
|
}
|
|
600
|
+
getLambdaClient() {
|
|
601
|
+
if (this.disposed) throw new Error("CfnLocalStateProvider used after dispose()");
|
|
602
|
+
if (!this.lambdaClient) this.lambdaClient = new LambdaClient({
|
|
603
|
+
region: this.region,
|
|
604
|
+
...this.clientOptions.profile !== void 0 && { profile: this.clientOptions.profile }
|
|
605
|
+
});
|
|
606
|
+
return this.lambdaClient;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Read a deployed Lambda function's already-resolved
|
|
610
|
+
* `Environment.Variables` via `lambda:GetFunctionConfiguration`. See
|
|
611
|
+
* {@link LocalStateProvider.resolveDeployedFunctionEnv} for why this
|
|
612
|
+
* closes the `Fn::GetAtt`/`Fn::Sub`/cross-stack gap for a consumer
|
|
613
|
+
* function's own env vars.
|
|
614
|
+
*
|
|
615
|
+
* Best-effort: on any expected miss (function not found, access
|
|
616
|
+
* denied, throttling) logs a warn and returns `undefined` so the
|
|
617
|
+
* caller falls back to warn-and-drop on the affected keys. Never
|
|
618
|
+
* throws out of the substitution pass.
|
|
619
|
+
*/
|
|
620
|
+
async resolveDeployedFunctionEnv(functionPhysicalId) {
|
|
621
|
+
if (this.disposed) throw new Error("CfnLocalStateProvider used after dispose()");
|
|
622
|
+
const logger = getLogger();
|
|
623
|
+
const client = this.getLambdaClient();
|
|
624
|
+
try {
|
|
625
|
+
return (await client.send(new GetFunctionConfigurationCommand({ FunctionName: functionPhysicalId }))).Environment?.Variables ?? {};
|
|
626
|
+
} catch (err) {
|
|
627
|
+
logger.warn(`${this.label}: GetFunctionConfiguration(${functionPhysicalId}) failed: ${formatAwsErrorForWarn(err)}. Intrinsic-valued env vars that need the deployed value will warn-and-drop (grant lambda:GetFunctionConfiguration or override via --env-vars).`);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
593
631
|
/**
|
|
594
632
|
* Load the deployed CFn stack's resources + outputs and return them
|
|
595
633
|
* as a synthetic `LocalStateRecord` (matching the shape the existing
|
|
@@ -675,6 +713,10 @@ var CfnLocalStateProvider = class {
|
|
|
675
713
|
this.client.destroy();
|
|
676
714
|
this.client = void 0;
|
|
677
715
|
}
|
|
716
|
+
if (this.lambdaClient) {
|
|
717
|
+
this.lambdaClient.destroy();
|
|
718
|
+
this.lambdaClient = void 0;
|
|
719
|
+
}
|
|
678
720
|
}
|
|
679
721
|
};
|
|
680
722
|
/**
|
|
@@ -2597,6 +2639,52 @@ async function substituteEnvVarsFromStateAsync(templateEnv, contextOrResources)
|
|
|
2597
2639
|
audit
|
|
2598
2640
|
};
|
|
2599
2641
|
}
|
|
2642
|
+
/**
|
|
2643
|
+
* Last-resort fill for env keys that static substitution could not
|
|
2644
|
+
* resolve, using the consumer resource's already-deployed environment.
|
|
2645
|
+
*
|
|
2646
|
+
* When a Lambda / container is bound to a deployed CloudFormation stack
|
|
2647
|
+
* (`--from-cfn-stack`), the consumer itself is deployed, so CloudFormation
|
|
2648
|
+
* already resolved every intrinsic (`Fn::GetAtt`, `Fn::Sub`,
|
|
2649
|
+
* `Fn::ImportValue`, cross-stack `Ref`) into its concrete deployed env
|
|
2650
|
+
* value. `ListStackResources` does not return per-attribute values, so
|
|
2651
|
+
* the static substituter drops those keys — but the deployed env carries
|
|
2652
|
+
* the answer. The provider fetches the deployed env (e.g.
|
|
2653
|
+
* `lambda:GetFunctionConfiguration`) and this helper splices it in for
|
|
2654
|
+
* the keys that remained unresolved.
|
|
2655
|
+
*
|
|
2656
|
+
* Precedence: only keys in `unresolved` are touched — statically resolved
|
|
2657
|
+
* keys and literal keys are left exactly as the substituter produced
|
|
2658
|
+
* them, and a `--env-vars` override still wins downstream. Keys absent
|
|
2659
|
+
* from `deployedEnv` stay unresolved so the caller's warn-and-drop fires.
|
|
2660
|
+
*
|
|
2661
|
+
* Pure: returns new arrays / a new env map, never mutates the inputs.
|
|
2662
|
+
*/
|
|
2663
|
+
function applyDeployedEnvFallback(resolvedEnv, unresolved, deployedEnv) {
|
|
2664
|
+
if (!deployedEnv) return {
|
|
2665
|
+
env: resolvedEnv,
|
|
2666
|
+
filled: [],
|
|
2667
|
+
stillUnresolved: [...unresolved]
|
|
2668
|
+
};
|
|
2669
|
+
const env = { ...resolvedEnv };
|
|
2670
|
+
const filled = [];
|
|
2671
|
+
const stillUnresolved = [];
|
|
2672
|
+
for (const item of unresolved) {
|
|
2673
|
+
const deployedValue = deployedEnv[item.key];
|
|
2674
|
+
if (deployedValue !== void 0) {
|
|
2675
|
+
env[item.key] = deployedValue;
|
|
2676
|
+
filled.push(item.key);
|
|
2677
|
+
} else stillUnresolved.push({
|
|
2678
|
+
key: item.key,
|
|
2679
|
+
reason: item.reason
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
return {
|
|
2683
|
+
env,
|
|
2684
|
+
filled,
|
|
2685
|
+
stillUnresolved
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2600
2688
|
|
|
2601
2689
|
//#endregion
|
|
2602
2690
|
//#region src/local/ecs-task-resolver.ts
|
|
@@ -5152,10 +5240,28 @@ async function localInvokeCommand(target, options, extraStateProviders) {
|
|
|
5152
5240
|
}
|
|
5153
5241
|
const { env, audit } = await substituteEnvVarsFromStateAsync(templateEnv, subContext);
|
|
5154
5242
|
templateEnv = env;
|
|
5155
|
-
stateAudit = audit;
|
|
5156
5243
|
const label = stateProvider.label;
|
|
5157
5244
|
for (const key of audit.resolvedKeys) logger.debug(`${label}: substituted env var ${key}`);
|
|
5158
|
-
|
|
5245
|
+
let unresolved = audit.unresolved;
|
|
5246
|
+
const resolvedKeys = [...audit.resolvedKeys];
|
|
5247
|
+
if (unresolved.length > 0 && stateProvider.resolveDeployedFunctionEnv) {
|
|
5248
|
+
const physicalId = loaded.resources[lambda.logicalId]?.physicalId;
|
|
5249
|
+
if (physicalId) {
|
|
5250
|
+
const deployedEnv = await stateProvider.resolveDeployedFunctionEnv(physicalId);
|
|
5251
|
+
const fb = applyDeployedEnvFallback(templateEnv, unresolved, deployedEnv);
|
|
5252
|
+
templateEnv = fb.env;
|
|
5253
|
+
unresolved = fb.stillUnresolved;
|
|
5254
|
+
for (const key of fb.filled) {
|
|
5255
|
+
resolvedKeys.push(key);
|
|
5256
|
+
logger.debug(`${label}: filled env var ${key} from deployed function config`);
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
stateAudit = {
|
|
5261
|
+
resolvedKeys,
|
|
5262
|
+
unresolved
|
|
5263
|
+
};
|
|
5264
|
+
for (const { key, reason } of unresolved) logger.warn(`${label}: could not substitute env var ${key} (${reason}). Override it via --env-vars or it will be dropped.`);
|
|
5159
5265
|
}
|
|
5160
5266
|
} finally {
|
|
5161
5267
|
stateProvider.dispose();
|
|
@@ -6944,6 +7050,16 @@ function discoverWebSocketApis(stacks) {
|
|
|
6944
7050
|
errors
|
|
6945
7051
|
};
|
|
6946
7052
|
}
|
|
7053
|
+
/**
|
|
7054
|
+
* Convenience wrapper around {@link discoverWebSocketApis} that
|
|
7055
|
+
* throws on any error (mirrors `discoverRoutes` for HTTP — useful in
|
|
7056
|
+
* test fixtures where errors should fail fast).
|
|
7057
|
+
*/
|
|
7058
|
+
function discoverWebSocketApisOrThrow(stacks) {
|
|
7059
|
+
const { apis, errors } = discoverWebSocketApis(stacks);
|
|
7060
|
+
if (errors.length > 0) throw new RouteDiscoveryError(`${getEmbedConfig().cliName} start-api: ${errors.length} malformed WebSocket API(s) in the synthesized template:\n` + errors.map((e) => ` - ${e}`).join("\n"));
|
|
7061
|
+
return apis;
|
|
7062
|
+
}
|
|
6947
7063
|
function discoverOneApi(logicalId, resource, template, stackName) {
|
|
6948
7064
|
const props = resource.Properties ?? {};
|
|
6949
7065
|
const declaredAt = `${stackName}/${logicalId}`;
|
|
@@ -14878,9 +14994,24 @@ async function buildContainerSpec(args) {
|
|
|
14878
14994
|
if (stateBundle.pseudoParameters) context.pseudoParameters = stateBundle.pseudoParameters;
|
|
14879
14995
|
const { env, audit } = substituteEnvVarsFromState(templateEnv, context);
|
|
14880
14996
|
templateEnv = env;
|
|
14881
|
-
stateAudit = audit;
|
|
14882
14997
|
for (const key of audit.resolvedKeys) getLogger().debug(`Lambda ${logicalId}: state source substituted env var ${key}`);
|
|
14883
|
-
|
|
14998
|
+
let unresolved = audit.unresolved;
|
|
14999
|
+
const resolvedKeys = [...audit.resolvedKeys];
|
|
15000
|
+
const deployedEnv = stateBundle.deployedEnvByLambda?.get(logicalId);
|
|
15001
|
+
if (unresolved.length > 0 && deployedEnv) {
|
|
15002
|
+
const fb = applyDeployedEnvFallback(templateEnv, unresolved, deployedEnv);
|
|
15003
|
+
templateEnv = fb.env;
|
|
15004
|
+
unresolved = fb.stillUnresolved;
|
|
15005
|
+
for (const key of fb.filled) {
|
|
15006
|
+
resolvedKeys.push(key);
|
|
15007
|
+
getLogger().debug(`Lambda ${logicalId}: filled env var ${key} from deployed function config`);
|
|
15008
|
+
}
|
|
15009
|
+
}
|
|
15010
|
+
stateAudit = {
|
|
15011
|
+
resolvedKeys,
|
|
15012
|
+
unresolved
|
|
15013
|
+
};
|
|
15014
|
+
for (const { key, reason } of unresolved) getLogger().warn(`Lambda ${logicalId}: state source could not substitute env var ${key} (${reason}). Override it via --env-vars or it will be dropped.`);
|
|
14884
15015
|
}
|
|
14885
15016
|
const lambdaCdkPath = readCdkPathOrUndefined(lambda.resource);
|
|
14886
15017
|
const envResult = resolveEnvVars(logicalId, lambdaCdkPath, templateEnv, overrides);
|
|
@@ -15656,6 +15787,19 @@ async function loadStateForRoutedStacks(stacks, routes, routesWithAuth, options,
|
|
|
15656
15787
|
const pseudo = await resolvePseudoParametersForStartApi(loaded.region, options);
|
|
15657
15788
|
if (pseudo) bundle.pseudoParameters = pseudo;
|
|
15658
15789
|
}
|
|
15790
|
+
if (provider.resolveDeployedFunctionEnv) {
|
|
15791
|
+
const deployedEnvByLambda = /* @__PURE__ */ new Map();
|
|
15792
|
+
for (const logicalId of lambdaIds) {
|
|
15793
|
+
const resource = stack.template.Resources?.[logicalId];
|
|
15794
|
+
if (!resource || resource.Type !== "AWS::Lambda::Function") continue;
|
|
15795
|
+
if (!envHasIntrinsicValue(getTemplateEnv(resource))) continue;
|
|
15796
|
+
const physicalId = loaded.resources[logicalId]?.physicalId;
|
|
15797
|
+
if (!physicalId) continue;
|
|
15798
|
+
const deployedEnv = await provider.resolveDeployedFunctionEnv(physicalId);
|
|
15799
|
+
if (deployedEnv) deployedEnvByLambda.set(logicalId, deployedEnv);
|
|
15800
|
+
}
|
|
15801
|
+
if (deployedEnvByLambda.size > 0) bundle.deployedEnvByLambda = deployedEnvByLambda;
|
|
15802
|
+
}
|
|
15659
15803
|
out.set(stackName, bundle);
|
|
15660
15804
|
logger.debug(`${provider.label}: loaded state for ${stackName} (${loaded.region})`);
|
|
15661
15805
|
} finally {
|
|
@@ -18304,5 +18448,5 @@ function createLocalStartServiceCommand(opts = {}) {
|
|
|
18304
18448
|
}
|
|
18305
18449
|
|
|
18306
18450
|
//#endregion
|
|
18307
|
-
export { CfnLocalStateProvider as _, resolveSelectionExpression as a,
|
|
18308
|
-
//# sourceMappingURL=local-start-service-
|
|
18451
|
+
export { resolveCfnRegion as C, rejectExplicitCfnStackWithMultipleStacks as S, CfnLocalStateProvider as T, resolveLambdaArnIntrinsic as _, resolveSelectionExpression as a, createLocalStateProvider as b, translateLambdaResponse as c, buildRestV1Event as d, discoverWebSocketApis as f, pickRefLogicalId as g, discoverRoutes as h, createLocalStartApiCommand as i, applyAuthorizerOverlay as l, parseSelectionExpressionPath as m, getContainerNetworkIp as n, resolveServiceIntegrationParameters as o, discoverWebSocketApisOrThrow as p, createLocalRunTaskCommand as r, matchRoute as s, createLocalStartServiceCommand as t, buildHttpApiV2Event as u, createLocalInvokeCommand as v, resolveCfnStackName as w, isCfnFlagPresent as x, LocalStateSourceError as y };
|
|
18452
|
+
//# sourceMappingURL=local-start-service-BwAE8kN7.js.map
|