@go-to-k/cdkd 0.102.1 → 0.102.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
@@ -12357,6 +12357,21 @@ var ApiGatewayProvider = class ApiGatewayProvider {
12357
12357
  * `Invalid mapping expression specified: ... [No method response exists
12358
12358
  * for method.]` — the canonical trigger is a CORS preflight OPTIONS
12359
12359
  * method emitted by `RestApi({ defaultCorsPreflightOptions: ... })`.
12360
+ *
12361
+ * Partial-failure cleanup: if any AWS call AFTER `PutMethodCommand`
12362
+ * fails, the method has already been created on AWS but cdkd state
12363
+ * does NOT record it (the throw happens before the success return).
12364
+ * A subsequent redeploy would then attempt CREATE again and AWS would
12365
+ * reject with `Method already exists for this resource`. To prevent
12366
+ * this orphan, the post-`PutMethod` block is wrapped in an inner
12367
+ * try/catch that issues a best-effort `DeleteMethodCommand` before
12368
+ * re-throwing the original error. Cleanup failures are logged at warn
12369
+ * (the underlying create failure is what matters; we don't mask it by
12370
+ * promoting a cleanup error). The class of bug — partial AWS-side
12371
+ * commit on `createMethod` failure — was first seen via the
12372
+ * `PutIntegrationResponse`-before-`PutMethodResponse` ordering bug
12373
+ * fixed in PR #373; this cleanup makes any future shape of
12374
+ * post-`PutMethod` failure self-healing on the next redeploy.
12360
12375
  */
12361
12376
  async createMethod(logicalId, resourceType, properties) {
12362
12377
  this.logger.debug(`Creating API Gateway Method ${logicalId}`);
@@ -12386,54 +12401,68 @@ var ApiGatewayProvider = class ApiGatewayProvider {
12386
12401
  requestValidatorId,
12387
12402
  authorizationScopes
12388
12403
  }));
12389
- const integration = properties["Integration"];
12390
- if (integration) await this.apiGatewayClient.send(new PutIntegrationCommand({
12391
- restApiId,
12392
- resourceId,
12393
- httpMethod,
12394
- type: integration["Type"],
12395
- integrationHttpMethod: integration["IntegrationHttpMethod"],
12396
- uri: integration["Uri"],
12397
- connectionType: integration["ConnectionType"],
12398
- connectionId: integration["ConnectionId"],
12399
- credentials: integration["Credentials"],
12400
- requestParameters: integration["RequestParameters"],
12401
- requestTemplates: integration["RequestTemplates"],
12402
- passthroughBehavior: integration["PassthroughBehavior"],
12403
- contentHandling: integration["ContentHandling"],
12404
- timeoutInMillis: integration["TimeoutInMillis"],
12405
- cacheNamespace: integration["CacheNamespace"],
12406
- cacheKeyParameters: integration["CacheKeyParameters"],
12407
- tlsConfig: integration["TlsConfig"] ? { insecureSkipVerification: integration["TlsConfig"]["InsecureSkipVerification"] } : void 0,
12408
- responseTransferMode: integration["ResponseTransferMode"]
12409
- }));
12410
- const methodResponses = properties["MethodResponses"];
12411
- if (methodResponses) for (const resp of methodResponses) {
12412
- const statusCode = String(resp["StatusCode"]);
12413
- await this.apiGatewayClient.send(new PutMethodResponseCommand({
12404
+ try {
12405
+ const integration = properties["Integration"];
12406
+ if (integration) await this.apiGatewayClient.send(new PutIntegrationCommand({
12414
12407
  restApiId,
12415
12408
  resourceId,
12416
12409
  httpMethod,
12417
- statusCode,
12418
- responseModels: resp["ResponseModels"],
12419
- responseParameters: resp["ResponseParameters"]
12410
+ type: integration["Type"],
12411
+ integrationHttpMethod: integration["IntegrationHttpMethod"],
12412
+ uri: integration["Uri"],
12413
+ connectionType: integration["ConnectionType"],
12414
+ connectionId: integration["ConnectionId"],
12415
+ credentials: integration["Credentials"],
12416
+ requestParameters: integration["RequestParameters"],
12417
+ requestTemplates: integration["RequestTemplates"],
12418
+ passthroughBehavior: integration["PassthroughBehavior"],
12419
+ contentHandling: integration["ContentHandling"],
12420
+ timeoutInMillis: integration["TimeoutInMillis"],
12421
+ cacheNamespace: integration["CacheNamespace"],
12422
+ cacheKeyParameters: integration["CacheKeyParameters"],
12423
+ tlsConfig: integration["TlsConfig"] ? { insecureSkipVerification: integration["TlsConfig"]["InsecureSkipVerification"] } : void 0,
12424
+ responseTransferMode: integration["ResponseTransferMode"]
12420
12425
  }));
12421
- }
12422
- if (integration) {
12423
- const integrationResponses = integration["IntegrationResponses"];
12424
- if (integrationResponses) for (const ir of integrationResponses) {
12425
- const statusCode = String(ir["StatusCode"]);
12426
- await this.apiGatewayClient.send(new PutIntegrationResponseCommand({
12426
+ const methodResponses = properties["MethodResponses"];
12427
+ if (methodResponses) for (const resp of methodResponses) {
12428
+ const statusCode = String(resp["StatusCode"]);
12429
+ await this.apiGatewayClient.send(new PutMethodResponseCommand({
12427
12430
  restApiId,
12428
12431
  resourceId,
12429
12432
  httpMethod,
12430
12433
  statusCode,
12431
- selectionPattern: ir["SelectionPattern"],
12432
- responseParameters: ir["ResponseParameters"],
12433
- responseTemplates: ir["ResponseTemplates"],
12434
- contentHandling: ir["ContentHandling"]
12434
+ responseModels: resp["ResponseModels"],
12435
+ responseParameters: resp["ResponseParameters"]
12436
+ }));
12437
+ }
12438
+ if (integration) {
12439
+ const integrationResponses = integration["IntegrationResponses"];
12440
+ if (integrationResponses) for (const ir of integrationResponses) {
12441
+ const statusCode = String(ir["StatusCode"]);
12442
+ await this.apiGatewayClient.send(new PutIntegrationResponseCommand({
12443
+ restApiId,
12444
+ resourceId,
12445
+ httpMethod,
12446
+ statusCode,
12447
+ selectionPattern: ir["SelectionPattern"],
12448
+ responseParameters: ir["ResponseParameters"],
12449
+ responseTemplates: ir["ResponseTemplates"],
12450
+ contentHandling: ir["ContentHandling"]
12451
+ }));
12452
+ }
12453
+ }
12454
+ } catch (innerError) {
12455
+ try {
12456
+ await this.apiGatewayClient.send(new DeleteMethodCommand({
12457
+ restApiId,
12458
+ resourceId,
12459
+ httpMethod
12435
12460
  }));
12461
+ this.logger.debug(`Cleaned up partially-created API Gateway Method ${logicalId} (${restApiId}/${resourceId}/${httpMethod}) after wiring failure`);
12462
+ } catch (cleanupError) {
12463
+ this.logger.warn(`Failed to clean up partially-created API Gateway Method ${logicalId} (${restApiId}/${resourceId}/${httpMethod}): ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}. Manual deletion may be required before the next deploy: aws apigateway delete-method --rest-api-id ${restApiId} --resource-id ${resourceId} --http-method ${httpMethod}`);
12436
12464
  }
12465
+ throw innerError;
12437
12466
  }
12438
12467
  const physicalId = `${restApiId}|${resourceId}|${httpMethod}`;
12439
12468
  this.logger.debug(`Successfully created API Gateway Method ${logicalId}: ${physicalId}`);
@@ -42709,7 +42738,7 @@ function reorderArgs(argv) {
42709
42738
  */
42710
42739
  async function main() {
42711
42740
  const program = new Command();
42712
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.102.1");
42741
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.102.2");
42713
42742
  program.addCommand(createBootstrapCommand());
42714
42743
  program.addCommand(createSynthCommand());
42715
42744
  program.addCommand(createListCommand());