@go-to-k/cdkd 0.23.0 → 0.23.2

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
@@ -7344,13 +7344,11 @@ var CustomResourceProvider = class _CustomResourceProvider {
7344
7344
  );
7345
7345
  }
7346
7346
  try {
7347
- const requestId = `cdkd-${Date.now()}-${Math.random().toString(36).substring(7)}`;
7348
- const responseKey = this.getResponseKey(requestId);
7349
- const responseURL = await this.generateResponseURL(responseKey);
7347
+ const invocation = await this.prepareInvocation();
7350
7348
  const request = {
7351
7349
  RequestType: "Create",
7352
- RequestId: requestId,
7353
- ResponseURL: responseURL,
7350
+ RequestId: invocation.requestId,
7351
+ ResponseURL: invocation.responseURL,
7354
7352
  ResourceType: resourceType,
7355
7353
  LogicalResourceId: logicalId,
7356
7354
  StackId: `arn:aws:cloudformation:us-east-1:000000000000:stack/cdkd-${logicalId}/cdkd`,
@@ -7360,7 +7358,7 @@ var CustomResourceProvider = class _CustomResourceProvider {
7360
7358
  const cfnResponse = await this.sendRequest(
7361
7359
  serviceToken,
7362
7360
  request,
7363
- responseKey,
7361
+ invocation.responseKey,
7364
7362
  logicalId,
7365
7363
  "Create"
7366
7364
  );
@@ -7399,13 +7397,11 @@ var CustomResourceProvider = class _CustomResourceProvider {
7399
7397
  );
7400
7398
  }
7401
7399
  try {
7402
- const requestId = `cdkd-${Date.now()}-${Math.random().toString(36).substring(7)}`;
7403
- const responseKey = this.getResponseKey(requestId);
7404
- const responseURL = await this.generateResponseURL(responseKey);
7400
+ const invocation = await this.prepareInvocation();
7405
7401
  const request = {
7406
7402
  RequestType: "Update",
7407
- RequestId: requestId,
7408
- ResponseURL: responseURL,
7403
+ RequestId: invocation.requestId,
7404
+ ResponseURL: invocation.responseURL,
7409
7405
  ResourceType: resourceType,
7410
7406
  LogicalResourceId: logicalId,
7411
7407
  PhysicalResourceId: physicalId,
@@ -7417,7 +7413,7 @@ var CustomResourceProvider = class _CustomResourceProvider {
7417
7413
  const cfnResponse = await this.sendRequest(
7418
7414
  serviceToken,
7419
7415
  request,
7420
- responseKey,
7416
+ invocation.responseKey,
7421
7417
  logicalId,
7422
7418
  "Update"
7423
7419
  );
@@ -7461,13 +7457,11 @@ var CustomResourceProvider = class _CustomResourceProvider {
7461
7457
  return;
7462
7458
  }
7463
7459
  try {
7464
- const requestId = `cdkd-${Date.now()}-${Math.random().toString(36).substring(7)}`;
7465
- const responseKey = this.getResponseKey(requestId);
7466
- const responseURL = await this.generateResponseURL(responseKey);
7460
+ const invocation = await this.prepareInvocation();
7467
7461
  const request = {
7468
7462
  RequestType: "Delete",
7469
- RequestId: requestId,
7470
- ResponseURL: responseURL,
7463
+ RequestId: invocation.requestId,
7464
+ ResponseURL: invocation.responseURL,
7471
7465
  ResourceType: resourceType,
7472
7466
  LogicalResourceId: logicalId,
7473
7467
  PhysicalResourceId: physicalId,
@@ -7478,7 +7472,7 @@ var CustomResourceProvider = class _CustomResourceProvider {
7478
7472
  const cfnResponse = await this.sendRequest(
7479
7473
  serviceToken,
7480
7474
  request,
7481
- responseKey,
7475
+ invocation.responseKey,
7482
7476
  logicalId,
7483
7477
  "Delete"
7484
7478
  );
@@ -7597,6 +7591,28 @@ var CustomResourceProvider = class _CustomResourceProvider {
7597
7591
  const timeoutMs = isAsyncPattern ? this.asyncResponseTimeoutMs : this.SYNC_RESPONSE_TIMEOUT_MS;
7598
7592
  return await this.pollS3Response(responseKey, logicalId, operation, timeoutMs, isAsyncPattern);
7599
7593
  }
7594
+ /**
7595
+ * Prepare a single Custom Resource invocation: generate the request id,
7596
+ * derive the S3 response key from it, sign the pre-signed PUT URL for that
7597
+ * key, and return all three together.
7598
+ *
7599
+ * **The request id, response key, and response URL must all be derived from
7600
+ * the SAME generation step.** Previously these were generated by separate
7601
+ * calls inside `create` / `update` / `delete`, which made it possible for a
7602
+ * future refactor (e.g. wrapping URL signing in a retry that re-rolls the
7603
+ * id) to silently break the invariant — the Lambda would write to one S3
7604
+ * key while cdkd polled a different one, hanging the deploy until the
7605
+ * polling timeout (up to 1 hour). See issue #90.
7606
+ *
7607
+ * Centralising this in one helper makes that invariant impossible to
7608
+ * violate at the call sites.
7609
+ */
7610
+ async prepareInvocation() {
7611
+ const requestId = `cdkd-${Date.now()}-${Math.random().toString(36).substring(7)}`;
7612
+ const responseKey = this.getResponseKey(requestId);
7613
+ const responseURL = await this.generateResponseURL(responseKey);
7614
+ return { requestId, responseKey, responseURL };
7615
+ }
7600
7616
  /**
7601
7617
  * Generate a pre-signed S3 PUT URL for Lambda to send its response
7602
7618
  */
@@ -32651,7 +32667,7 @@ Preparing to destroy stack: ${stackName}`);
32651
32667
  } else {
32652
32668
  const regions = refs.map((r) => r.region ?? "(legacy)").join(", ");
32653
32669
  throw new Error(
32654
- `Stack '${stackName}' has state in multiple regions: ${regions}. Use 'cdkd state orphan ${stackName} --region <region>' to remove cdkd's record for one region, or run destroy from a CDK app whose env.region matches one of them.`
32670
+ `Stack '${stackName}' has state in multiple regions: ${regions}. Use 'cdkd state orphan ${stackName} --stack-region <region>' to remove cdkd's record for one region, or run destroy from a CDK app whose env.region matches one of them.`
32655
32671
  );
32656
32672
  }
32657
32673
  const stateResult = await stateBackend.getState(stackName, stackTargetRegion);
@@ -33320,7 +33336,7 @@ function resolveSingleRegion(stackName, refs, requestedRegion) {
33320
33336
  return matches[0];
33321
33337
  const regions = matches.map((r) => r.region ?? "(legacy)").join(", ");
33322
33338
  throw new Error(
33323
- `Stack '${stackName}' has state in multiple regions: ${regions}. Re-run with --region <region> to disambiguate.`
33339
+ `Stack '${stackName}' has state in multiple regions: ${regions}. Re-run with --stack-region <region> to disambiguate.`
33324
33340
  );
33325
33341
  }
33326
33342
  async function setupStateBackend(options) {
@@ -33790,7 +33806,7 @@ WARNING: This destroys ${stackNames.length} stack(s) and removes their state rec
33790
33806
  } else {
33791
33807
  const regions = refs.map((r) => r.region ?? "(legacy)").join(", ");
33792
33808
  throw new Error(
33793
- `Stack '${stackName}' has state in multiple regions: ${regions}. Use --region <region> to pick one.`
33809
+ `Stack '${stackName}' has state in multiple regions: ${regions}. Use --stack-region <region> to pick one.`
33794
33810
  );
33795
33811
  }
33796
33812
  for (const ref of targets) {
@@ -34377,7 +34393,7 @@ function reorderArgs(argv) {
34377
34393
  }
34378
34394
  async function main() {
34379
34395
  const program = new Command13();
34380
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.23.0");
34396
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.23.2");
34381
34397
  program.addCommand(createBootstrapCommand());
34382
34398
  program.addCommand(createSynthCommand());
34383
34399
  program.addCommand(createListCommand());