@go-to-k/cdkd 0.164.0 → 0.164.1

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/cli.js CHANGED
@@ -58752,6 +58752,7 @@ async function localInvokeCommand(target, options) {
58752
58752
  region: options.region
58753
58753
  });
58754
58754
  await ensureDockerAvailable();
58755
+ const profileCredentials = options.profile ? await resolveProfileCredentials(options.profile) : void 0;
58755
58756
  const appCmd = resolveApp(options.app);
58756
58757
  if (!appCmd) throw new Error("No CDK app specified. Pass --app, set CDKD_APP, or add \"app\" to cdk.json.");
58757
58758
  logger.info("Synthesizing CDK app...");
@@ -58849,7 +58850,10 @@ async function localInvokeCommand(target, options) {
58849
58850
  logger.warn(`--assume-role: STS AssumeRole(${resolvedAssumeRoleArn}) failed: ${reason}. Falling back to the developer's shell credentials.`);
58850
58851
  }
58851
58852
  }
58852
- if (!assumeSucceeded) forwardAwsEnv(dockerEnv);
58853
+ if (!assumeSucceeded) {
58854
+ forwardAwsEnv(dockerEnv);
58855
+ applyProfileCredentialsOverlay(dockerEnv, profileCredentials, false);
58856
+ }
58853
58857
  let debugPort;
58854
58858
  if (options.debugPort) {
58855
58859
  debugPort = Number(options.debugPort);
@@ -59286,6 +59290,44 @@ function forwardAwsEnv(env) {
59286
59290
  }
59287
59291
  }
59288
59292
  /**
59293
+ * Issue #657: overlay `--profile <p>`-resolved credentials onto the
59294
+ * Lambda container's env block AFTER `forwardAwsEnv` has copied
59295
+ * `process.env.AWS_*`. The overlay covers SSO / IAM Identity Center /
59296
+ * fromIni / role-assumption profiles uniformly (resolved via the SDK's
59297
+ * default credential chain in `resolveProfileCredentials`). Without
59298
+ * this overlay, a dev who runs `cdkd local invoke --profile dev`
59299
+ * AND has no `AWS_ACCESS_KEY_ID` env var (the common SSO / Identity
59300
+ * Center case) sees the Lambda boot with no creds → handler's AWS SDK
59301
+ * call fails with `Could not load credentials from any providers`.
59302
+ *
59303
+ * Precedence (codifies existing semantics + this new layer):
59304
+ * 1. `--assume-role <arn>` (per-Lambda STS creds) — unchanged
59305
+ * 2. NEW: `--profile <p>` resolved + cached (this helper)
59306
+ * 3. `process.env.AWS_*` forwarded — when `--profile` not set
59307
+ *
59308
+ * Region from `forwardAwsEnv` is preserved — only the credential
59309
+ * triple is overlaid.
59310
+ *
59311
+ * When the resolved profile is long-lived (no `sessionToken`), any
59312
+ * inherited `AWS_SESSION_TOKEN` is stripped — a mismatched (long-
59313
+ * lived AKID + foreign session) would otherwise cause an SDK error
59314
+ * inside the container.
59315
+ *
59316
+ * No-op when `profileCreds` is `undefined` (profile not set) or when
59317
+ * `assumeRoleActive` is true (assume-role already won; its STS-issued
59318
+ * creds must not be clobbered by the profile overlay).
59319
+ *
59320
+ * Exported for unit-test isolation (see `local-invoke-profile-creds.test.ts`).
59321
+ */
59322
+ function applyProfileCredentialsOverlay(env, profileCreds, assumeRoleActive) {
59323
+ if (!profileCreds) return;
59324
+ if (assumeRoleActive) return;
59325
+ env["AWS_ACCESS_KEY_ID"] = profileCreds.accessKeyId;
59326
+ env["AWS_SECRET_ACCESS_KEY"] = profileCreds.secretAccessKey;
59327
+ if (profileCreds.sessionToken) env["AWS_SESSION_TOKEN"] = profileCreds.sessionToken;
59328
+ else delete env["AWS_SESSION_TOKEN"];
59329
+ }
59330
+ /**
59289
59331
  * Materialize an inline Lambda body (`Code.ZipFile`) to a tmpdir and
59290
59332
  * return the directory the container should mount at /var/task. The
59291
59333
  * filename is derived from the function's Handler property and the
@@ -60505,7 +60547,7 @@ function reorderArgs(argv) {
60505
60547
  */
60506
60548
  async function main() {
60507
60549
  const program = new Command();
60508
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.164.0");
60550
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.164.1");
60509
60551
  program.addCommand(createBootstrapCommand());
60510
60552
  program.addCommand(createSynthCommand());
60511
60553
  program.addCommand(createListCommand());