@go-to-k/cdkd 0.34.0 → 0.35.0

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
@@ -6767,6 +6767,50 @@ Error: ${err.message || "Unknown error"}`,
6767
6767
  }
6768
6768
  return resourceType.startsWith("AWS::");
6769
6769
  }
6770
+ /**
6771
+ * Read the AWS-current properties of a resource managed via Cloud Control
6772
+ * API, for `cdkd drift` comparison.
6773
+ *
6774
+ * Strategy: `GetResource(TypeName, Identifier)` returns `ResourceModel` as
6775
+ * a JSON string of every property AWS reports for the resource. Parse and
6776
+ * surface it as the AWS-current snapshot — the drift command intersects
6777
+ * this against the keys present in cdkd state, so AWS-only keys (timestamps,
6778
+ * generated ids, etc.) are filtered out at compare time.
6779
+ *
6780
+ * Returns `undefined` for the unique cases that mean "drift unknown" (the
6781
+ * resource was deleted out from under cdkd, or the response had no
6782
+ * Properties field). Re-throws on any other error so the drift command can
6783
+ * surface throttling / access-denied issues to the user.
6784
+ *
6785
+ * This single CC API implementation gives drift detection coverage to every
6786
+ * resource type that goes through CC API — the majority of cdkd's surface.
6787
+ * SDK Providers add their own `readCurrentState` incrementally (PR D).
6788
+ */
6789
+ async readCurrentState(physicalId, _logicalId, resourceType) {
6790
+ try {
6791
+ const response = await this.cloudControlClient.send(
6792
+ new GetResourceCommand2({
6793
+ TypeName: resourceType,
6794
+ Identifier: physicalId
6795
+ })
6796
+ );
6797
+ const raw = response.ResourceDescription?.Properties;
6798
+ if (typeof raw !== "string" || raw.length === 0) {
6799
+ return void 0;
6800
+ }
6801
+ const parsed = JSON.parse(raw);
6802
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
6803
+ return void 0;
6804
+ }
6805
+ return parsed;
6806
+ } catch (error) {
6807
+ const err = error;
6808
+ if (err.name === "ResourceNotFoundException") {
6809
+ return void 0;
6810
+ }
6811
+ throw error;
6812
+ }
6813
+ }
6770
6814
  /**
6771
6815
  * Adopt an already-deployed resource into cdkd state via Cloud Control API.
6772
6816
  *