@go-to-k/cdkd 0.30.0 → 0.30.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
@@ -12966,7 +12966,9 @@ import {
12966
12966
  GetFunctionCommand,
12967
12967
  ListFunctionsCommand,
12968
12968
  ListTagsCommand,
12969
- ResourceNotFoundException
12969
+ ResourceNotFoundException,
12970
+ waitUntilFunctionActiveV2,
12971
+ waitUntilFunctionUpdatedV2
12970
12972
  } from "@aws-sdk/client-lambda";
12971
12973
  import {
12972
12974
  DescribeNetworkInterfacesCommand,
@@ -13009,6 +13011,14 @@ var LambdaFunctionProvider = class {
13009
13011
  eniWaitTimeoutMs = 10 * 60 * 1e3;
13010
13012
  eniWaitInitialDelayMs = 1e4;
13011
13013
  eniWaitMaxDelayMs = 3e4;
13014
+ // Budget for the post-CreateFunction / post-Update wait that blocks until
13015
+ // Configuration.State === 'Active' and LastUpdateStatus === 'Successful'.
13016
+ // Must NOT be skipped by --no-wait: downstream resources (Custom Resource
13017
+ // Invokes, EventSourceMappings, etc.) cannot operate against a function
13018
+ // still in Pending / InProgress, so this is required for correctness, not
13019
+ // a "convenience wait" like CloudFront / RDS readiness.
13020
+ // Seconds (the SDK waiter contract is seconds, not ms).
13021
+ functionReadyMaxWaitSeconds = 10 * 60;
13012
13022
  // delstack-style ENI cleanup tunables.
13013
13023
  // - initial sleep: gives AWS time to publish post-detach ENI state via
13014
13024
  // DescribeNetworkInterfaces (right after the update, the API can return
@@ -13077,6 +13087,7 @@ var LambdaFunctionProvider = class {
13077
13087
  Tags: tags
13078
13088
  };
13079
13089
  const response = await this.lambdaClient.send(new CreateFunctionCommand(createParams));
13090
+ await this.waitForFunctionActive(logicalId, resourceType, functionName);
13080
13091
  this.logger.debug(`Successfully created Lambda function ${logicalId}: ${functionName}`);
13081
13092
  return {
13082
13093
  physicalId: response.FunctionName || functionName,
@@ -13086,6 +13097,9 @@ var LambdaFunctionProvider = class {
13086
13097
  }
13087
13098
  };
13088
13099
  } catch (error) {
13100
+ if (error instanceof ProvisioningError) {
13101
+ throw error;
13102
+ }
13089
13103
  const cause = error instanceof Error ? error : void 0;
13090
13104
  throw new ProvisioningError(
13091
13105
  `Failed to create Lambda function ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,
@@ -13142,6 +13156,7 @@ var LambdaFunctionProvider = class {
13142
13156
  };
13143
13157
  await this.lambdaClient.send(new UpdateFunctionConfigurationCommand(configParams));
13144
13158
  this.logger.debug(`Updated configuration for Lambda function ${physicalId}`);
13159
+ await this.waitForFunctionUpdated(logicalId, resourceType, physicalId);
13145
13160
  }
13146
13161
  const newCode = properties["Code"];
13147
13162
  const oldCode = previousProperties["Code"];
@@ -13157,6 +13172,7 @@ var LambdaFunctionProvider = class {
13157
13172
  };
13158
13173
  await this.lambdaClient.send(new UpdateFunctionCodeCommand(codeParams));
13159
13174
  this.logger.debug(`Updated code for Lambda function ${physicalId}`);
13175
+ await this.waitForFunctionUpdated(logicalId, resourceType, physicalId);
13160
13176
  }
13161
13177
  const getResponse = await this.lambdaClient.send(
13162
13178
  new GetFunctionCommand({ FunctionName: physicalId })
@@ -13170,6 +13186,9 @@ var LambdaFunctionProvider = class {
13170
13186
  }
13171
13187
  };
13172
13188
  } catch (error) {
13189
+ if (error instanceof ProvisioningError) {
13190
+ throw error;
13191
+ }
13173
13192
  const cause = error instanceof Error ? error : void 0;
13174
13193
  throw new ProvisioningError(
13175
13194
  `Failed to update Lambda function ${logicalId}: ${error instanceof Error ? error.message : String(error)}`,
@@ -13336,6 +13355,58 @@ var LambdaFunctionProvider = class {
13336
13355
  * Timeout is a soft warning — downstream Subnet/SG deletion has its own
13337
13356
  * retries.
13338
13357
  */
13358
+ /**
13359
+ * Block until the function's State === 'Active'.
13360
+ *
13361
+ * Used after CreateFunction. Wraps the SDK's built-in
13362
+ * `waitUntilFunctionActiveV2` (acceptors: SUCCESS=Active, FAILURE=Failed,
13363
+ * RETRY=Pending). The waiter throws on FAILURE / TIMEOUT — both surface
13364
+ * as `ProvisioningError` with the function-name as physicalId so the
13365
+ * deploy engine's per-resource error handling treats them identically to
13366
+ * a CreateFunction failure.
13367
+ */
13368
+ async waitForFunctionActive(logicalId, resourceType, functionName) {
13369
+ try {
13370
+ await waitUntilFunctionActiveV2(
13371
+ { client: this.lambdaClient, maxWaitTime: this.functionReadyMaxWaitSeconds },
13372
+ { FunctionName: functionName }
13373
+ );
13374
+ } catch (error) {
13375
+ const cause = error instanceof Error ? error : void 0;
13376
+ throw new ProvisioningError(
13377
+ `Lambda function ${logicalId} did not reach Active state: ${error instanceof Error ? error.message : String(error)}`,
13378
+ resourceType,
13379
+ logicalId,
13380
+ functionName,
13381
+ cause
13382
+ );
13383
+ }
13384
+ }
13385
+ /**
13386
+ * Block until the function's LastUpdateStatus === 'Successful'.
13387
+ *
13388
+ * Used after UpdateFunctionConfiguration / UpdateFunctionCode. Wraps the
13389
+ * SDK's `waitUntilFunctionUpdatedV2` (acceptors: SUCCESS=Successful,
13390
+ * FAILURE=Failed, RETRY=InProgress). Same error-wrapping contract as
13391
+ * `waitForFunctionActive`.
13392
+ */
13393
+ async waitForFunctionUpdated(logicalId, resourceType, functionName) {
13394
+ try {
13395
+ await waitUntilFunctionUpdatedV2(
13396
+ { client: this.lambdaClient, maxWaitTime: this.functionReadyMaxWaitSeconds },
13397
+ { FunctionName: functionName }
13398
+ );
13399
+ } catch (error) {
13400
+ const cause = error instanceof Error ? error : void 0;
13401
+ throw new ProvisioningError(
13402
+ `Lambda function ${logicalId} update did not complete: ${error instanceof Error ? error.message : String(error)}`,
13403
+ resourceType,
13404
+ logicalId,
13405
+ functionName,
13406
+ cause
13407
+ );
13408
+ }
13409
+ }
13339
13410
  /**
13340
13411
  * Poll GetFunction until LastUpdateStatus is no longer `InProgress`.
13341
13412
  *
@@ -13348,6 +13419,12 @@ var LambdaFunctionProvider = class {
13348
13419
  * Bounded by eniWaitTimeoutMs (10min) and treated as a soft warning on
13349
13420
  * timeout: the subsequent ENI cleanup loop and downstream retries cover
13350
13421
  * the residual edge case.
13422
+ *
13423
+ * NOTE: deliberately separate from `waitForFunctionUpdated` (which uses
13424
+ * the SDK's `waitUntilFunctionUpdatedV2` and throws on FAILURE). The
13425
+ * pre-delete path needs a more lenient acceptor: if a prior update
13426
+ * failed, we still want to proceed with DeleteFunction rather than
13427
+ * abort, because the function is going away anyway.
13351
13428
  */
13352
13429
  async waitForLambdaUpdateCompleted(functionName) {
13353
13430
  const start = Date.now();
@@ -36062,7 +36139,7 @@ function reorderArgs(argv) {
36062
36139
  }
36063
36140
  async function main() {
36064
36141
  const program = new Command13();
36065
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.30.0");
36142
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.30.1");
36066
36143
  program.addCommand(createBootstrapCommand());
36067
36144
  program.addCommand(createSynthCommand());
36068
36145
  program.addCommand(createListCommand());