cdk-local 0.9.0 → 0.10.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 +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{local-start-service-Rit5YxNR.js → local-start-service-BbOWJ2dK.js} +146 -12
- package/dist/local-start-service-BbOWJ2dK.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, u as createLocalInvokeCommand } from "./local-start-service-
|
|
2
|
+
import { i as createLocalStartApiCommand, r as createLocalRunTaskCommand, t as createLocalStartServiceCommand, u as createLocalInvokeCommand } from "./local-start-service-BbOWJ2dK.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.10.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
|
|
@@ -114,10 +115,13 @@ declare class CfnLocalStateProvider implements LocalStateProvider {
|
|
|
114
115
|
private readonly cfnStackName;
|
|
115
116
|
private readonly region;
|
|
116
117
|
private client;
|
|
118
|
+
private lambdaClient;
|
|
117
119
|
private readonly clientOptions;
|
|
118
120
|
private disposed;
|
|
119
121
|
constructor(opts: CfnLocalStateProviderOptions);
|
|
120
122
|
private getClient;
|
|
123
|
+
private getLambdaClient;
|
|
124
|
+
resolveDeployedFunctionEnv(functionPhysicalId: string): Promise<Record<string, string> | undefined>;
|
|
121
125
|
load(_stackName: string, _synthRegion: string | undefined): Promise<LocalStateRecord | undefined>;
|
|
122
126
|
buildCrossStackResolver(_consumerRegion: string): Promise<CrossStackResolver | undefined>;
|
|
123
127
|
dispose(): void;
|
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/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;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,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,WACC,OAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as CfnLocalStateProvider, a as resolveSelectionExpression, c as pickRefLogicalId, d as LocalStateSourceError, f as createLocalStateProvider, g as resolveCfnStackName, h as resolveCfnRegion, i as createLocalStartApiCommand, l as resolveLambdaArnIntrinsic, m as rejectExplicitCfnStackWithMultipleStacks, n as getContainerNetworkIp, o as resolveServiceIntegrationParameters, p as isCfnFlagPresent, r as createLocalRunTaskCommand, s as translateLambdaResponse, t as createLocalStartServiceCommand, u as createLocalInvokeCommand } from "./local-start-service-
|
|
1
|
+
import { _ as CfnLocalStateProvider, a as resolveSelectionExpression, c as pickRefLogicalId, d as LocalStateSourceError, f as createLocalStateProvider, g as resolveCfnStackName, h as resolveCfnRegion, i as createLocalStartApiCommand, l as resolveLambdaArnIntrinsic, m as rejectExplicitCfnStackWithMultipleStacks, n as getContainerNetworkIp, o as resolveServiceIntegrationParameters, p as isCfnFlagPresent, r as createLocalRunTaskCommand, s as translateLambdaResponse, t as createLocalStartServiceCommand, u as createLocalInvokeCommand } from "./local-start-service-BbOWJ2dK.js";
|
|
2
2
|
|
|
3
3
|
export { CfnLocalStateProvider, LocalStateSourceError, createLocalInvokeCommand, createLocalRunTaskCommand, createLocalStartApiCommand, createLocalStartServiceCommand, createLocalStateProvider, getContainerNetworkIp, isCfnFlagPresent, 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();
|
|
@@ -14878,9 +14984,24 @@ async function buildContainerSpec(args) {
|
|
|
14878
14984
|
if (stateBundle.pseudoParameters) context.pseudoParameters = stateBundle.pseudoParameters;
|
|
14879
14985
|
const { env, audit } = substituteEnvVarsFromState(templateEnv, context);
|
|
14880
14986
|
templateEnv = env;
|
|
14881
|
-
stateAudit = audit;
|
|
14882
14987
|
for (const key of audit.resolvedKeys) getLogger().debug(`Lambda ${logicalId}: state source substituted env var ${key}`);
|
|
14883
|
-
|
|
14988
|
+
let unresolved = audit.unresolved;
|
|
14989
|
+
const resolvedKeys = [...audit.resolvedKeys];
|
|
14990
|
+
const deployedEnv = stateBundle.deployedEnvByLambda?.get(logicalId);
|
|
14991
|
+
if (unresolved.length > 0 && deployedEnv) {
|
|
14992
|
+
const fb = applyDeployedEnvFallback(templateEnv, unresolved, deployedEnv);
|
|
14993
|
+
templateEnv = fb.env;
|
|
14994
|
+
unresolved = fb.stillUnresolved;
|
|
14995
|
+
for (const key of fb.filled) {
|
|
14996
|
+
resolvedKeys.push(key);
|
|
14997
|
+
getLogger().debug(`Lambda ${logicalId}: filled env var ${key} from deployed function config`);
|
|
14998
|
+
}
|
|
14999
|
+
}
|
|
15000
|
+
stateAudit = {
|
|
15001
|
+
resolvedKeys,
|
|
15002
|
+
unresolved
|
|
15003
|
+
};
|
|
15004
|
+
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
15005
|
}
|
|
14885
15006
|
const lambdaCdkPath = readCdkPathOrUndefined(lambda.resource);
|
|
14886
15007
|
const envResult = resolveEnvVars(logicalId, lambdaCdkPath, templateEnv, overrides);
|
|
@@ -15656,6 +15777,19 @@ async function loadStateForRoutedStacks(stacks, routes, routesWithAuth, options,
|
|
|
15656
15777
|
const pseudo = await resolvePseudoParametersForStartApi(loaded.region, options);
|
|
15657
15778
|
if (pseudo) bundle.pseudoParameters = pseudo;
|
|
15658
15779
|
}
|
|
15780
|
+
if (provider.resolveDeployedFunctionEnv) {
|
|
15781
|
+
const deployedEnvByLambda = /* @__PURE__ */ new Map();
|
|
15782
|
+
for (const logicalId of lambdaIds) {
|
|
15783
|
+
const resource = stack.template.Resources?.[logicalId];
|
|
15784
|
+
if (!resource || resource.Type !== "AWS::Lambda::Function") continue;
|
|
15785
|
+
if (!envHasIntrinsicValue(getTemplateEnv(resource))) continue;
|
|
15786
|
+
const physicalId = loaded.resources[logicalId]?.physicalId;
|
|
15787
|
+
if (!physicalId) continue;
|
|
15788
|
+
const deployedEnv = await provider.resolveDeployedFunctionEnv(physicalId);
|
|
15789
|
+
if (deployedEnv) deployedEnvByLambda.set(logicalId, deployedEnv);
|
|
15790
|
+
}
|
|
15791
|
+
if (deployedEnvByLambda.size > 0) bundle.deployedEnvByLambda = deployedEnvByLambda;
|
|
15792
|
+
}
|
|
15659
15793
|
out.set(stackName, bundle);
|
|
15660
15794
|
logger.debug(`${provider.label}: loaded state for ${stackName} (${loaded.region})`);
|
|
15661
15795
|
} finally {
|
|
@@ -18305,4 +18439,4 @@ function createLocalStartServiceCommand(opts = {}) {
|
|
|
18305
18439
|
|
|
18306
18440
|
//#endregion
|
|
18307
18441
|
export { CfnLocalStateProvider as _, resolveSelectionExpression as a, pickRefLogicalId as c, LocalStateSourceError as d, createLocalStateProvider as f, resolveCfnStackName as g, resolveCfnRegion as h, createLocalStartApiCommand as i, resolveLambdaArnIntrinsic as l, rejectExplicitCfnStackWithMultipleStacks as m, getContainerNetworkIp as n, resolveServiceIntegrationParameters as o, isCfnFlagPresent as p, createLocalRunTaskCommand as r, translateLambdaResponse as s, createLocalStartServiceCommand as t, createLocalInvokeCommand as u };
|
|
18308
|
-
//# sourceMappingURL=local-start-service-
|
|
18442
|
+
//# sourceMappingURL=local-start-service-BbOWJ2dK.js.map
|