@go-to-k/cdkd 0.45.0 → 0.46.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.
Binary file
package/dist/index.js CHANGED
@@ -7679,6 +7679,31 @@ function matchesCdkPath(tags, cdkPath) {
7679
7679
  }
7680
7680
  return false;
7681
7681
  }
7682
+ function normalizeAwsTagsToCfn(tags) {
7683
+ if (!tags)
7684
+ return [];
7685
+ const out = [];
7686
+ if (Array.isArray(tags)) {
7687
+ for (const t of tags) {
7688
+ const obj = t;
7689
+ const k = (typeof obj["Key"] === "string" ? obj["Key"] : void 0) ?? (typeof obj["TagKey"] === "string" ? obj["TagKey"] : void 0) ?? (typeof obj["key"] === "string" ? obj["key"] : void 0);
7690
+ const v = (typeof obj["Value"] === "string" ? obj["Value"] : void 0) ?? (typeof obj["TagValue"] === "string" ? obj["TagValue"] : void 0) ?? (typeof obj["value"] === "string" ? obj["value"] : void 0);
7691
+ if (typeof k !== "string" || k.length === 0)
7692
+ continue;
7693
+ if (k.startsWith("aws:"))
7694
+ continue;
7695
+ out.push({ Key: k, Value: typeof v === "string" ? v : "" });
7696
+ }
7697
+ } else {
7698
+ for (const [k, v] of Object.entries(tags)) {
7699
+ if (!k || k.startsWith("aws:"))
7700
+ continue;
7701
+ out.push({ Key: k, Value: typeof v === "string" ? v : "" });
7702
+ }
7703
+ }
7704
+ out.sort((a, b) => a.Key < b.Key ? -1 : a.Key > b.Key ? 1 : 0);
7705
+ return out;
7706
+ }
7682
7707
 
7683
7708
  // src/provisioning/providers/iam-role-provider.ts
7684
7709
  var IAMRoleProvider = class {
@@ -8238,9 +8263,10 @@ var IAMRoleProvider = class {
8238
8263
  * costs one extra `GetRolePolicy` per inline policy. Out of scope for
8239
8264
  * v1 — drift detection on inline IAM policy bodies can ship in a
8240
8265
  * follow-up.
8241
- * - `Tags` is omitted for the same reason as Lambda's tags handling
8242
- * (CDK auto-injects `aws:cdk:path` and the shape decision belongs in a
8243
- * dedicated tags PR).
8266
+ * - `Tags` is surfaced via `ListRoleTags` (paginated). CDK's `aws:*`
8267
+ * auto-tags are filtered out by `normalizeAwsTagsToCfn` so they don't
8268
+ * fire false-positive drift; the result key is omitted entirely when
8269
+ * AWS reports no user tags (matches `create()`'s behavior).
8244
8270
  *
8245
8271
  * Returns `undefined` when the role is gone (`NoSuchEntityException`).
8246
8272
  */
@@ -8290,8 +8316,46 @@ var IAMRoleProvider = class {
8290
8316
  if (!(err instanceof NoSuchEntityException))
8291
8317
  throw err;
8292
8318
  }
8319
+ try {
8320
+ const collected = [];
8321
+ let marker;
8322
+ while (true) {
8323
+ const tagsResp = await this.iamClient.send(
8324
+ new ListRoleTagsCommand({
8325
+ RoleName: physicalId,
8326
+ ...marker ? { Marker: marker } : {}
8327
+ })
8328
+ );
8329
+ if (tagsResp.Tags) {
8330
+ for (const t of tagsResp.Tags) {
8331
+ collected.push({ Key: t.Key, Value: t.Value });
8332
+ }
8333
+ }
8334
+ if (!tagsResp.IsTruncated)
8335
+ break;
8336
+ marker = tagsResp.Marker;
8337
+ }
8338
+ const tags = normalizeAwsTagsToCfn(collected);
8339
+ if (tags.length > 0)
8340
+ result["Tags"] = tags;
8341
+ } catch (err) {
8342
+ if (!(err instanceof NoSuchEntityException))
8343
+ throw err;
8344
+ }
8293
8345
  return result;
8294
8346
  }
8347
+ /**
8348
+ * `Policies` (inline policy bodies) are intentionally omitted from
8349
+ * `readCurrentState`: surfacing the names without bodies would
8350
+ * guarantee a `PolicyDocument`-shaped drift on every role, and
8351
+ * fetching every body costs one extra `GetRolePolicy` per inline
8352
+ * policy. Tell the drift comparator to skip the whole subtree until a
8353
+ * dedicated PR adds proper inline-policy drift via per-name
8354
+ * `GetRolePolicy`.
8355
+ */
8356
+ getDriftUnknownPaths() {
8357
+ return ["Policies"];
8358
+ }
8295
8359
  /**
8296
8360
  * Adopt an existing IAM role into cdkd state.
8297
8361
  *