@go-to-k/cdkd 0.0.2 → 0.0.3

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.
Binary file
package/dist/index.js CHANGED
@@ -2508,6 +2508,7 @@ import {
2508
2508
  GetObjectCommand,
2509
2509
  PutObjectCommand as PutObjectCommand2,
2510
2510
  DeleteObjectCommand,
2511
+ HeadBucketCommand,
2511
2512
  HeadObjectCommand as HeadObjectCommand2,
2512
2513
  ListObjectsV2Command,
2513
2514
  NoSuchKey
@@ -2524,6 +2525,28 @@ var S3StateBackend = class {
2524
2525
  getStateKey(stackName) {
2525
2526
  return `${this.config.prefix}/${stackName}/state.json`;
2526
2527
  }
2528
+ /**
2529
+ * Verify that the configured state bucket exists.
2530
+ *
2531
+ * Called early in deploy/destroy to fail fast before expensive work
2532
+ * (asset publishing, Docker builds) runs against a missing bucket.
2533
+ */
2534
+ async verifyBucketExists() {
2535
+ try {
2536
+ await this.s3Client.send(new HeadBucketCommand({ Bucket: this.config.bucket }));
2537
+ } catch (error) {
2538
+ const name = error.name;
2539
+ if (name === "NotFound" || name === "NoSuchBucket") {
2540
+ throw new StateError(
2541
+ `State bucket '${this.config.bucket}' does not exist. Run 'cdkd bootstrap' to create it, or specify an existing bucket via --state-bucket, CDKD_STATE_BUCKET, or cdk.json context.cdkd.stateBucket.`
2542
+ );
2543
+ }
2544
+ throw new StateError(
2545
+ `Failed to verify state bucket '${this.config.bucket}': ${error instanceof Error ? error.message : String(error)}`,
2546
+ error instanceof Error ? error : void 0
2547
+ );
2548
+ }
2549
+ }
2527
2550
  /**
2528
2551
  * Check if state exists for a stack
2529
2552
  */