cdk-real-drift 0.4.44 → 0.5.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.
package/dist/cli.js CHANGED
@@ -23,6 +23,7 @@ import { DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2C
23
23
  import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermissionCommand } from "@aws-sdk/client-eventbridge";
24
24
  import { GetPolicyCommand, LambdaClient, ListAliasesCommand as ListAliasesCommand$1, ListEventSourceMappingsCommand, ListFunctionUrlConfigsCommand, ListVersionsByFunctionCommand } from "@aws-sdk/client-lambda";
25
25
  import { DescribeDBClustersCommand, DescribeDBInstancesCommand, RDSClient } from "@aws-sdk/client-rds";
26
+ import { ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
26
27
  import { GetTopicAttributesCommand, ListSubscriptionsByTopicCommand, SNSClient, SetTopicAttributesCommand } from "@aws-sdk/client-sns";
27
28
  import { ACMClient, DescribeCertificateCommand, ListTagsForCertificateCommand } from "@aws-sdk/client-acm";
28
29
  import { BudgetsClient, DescribeBudgetCommand } from "@aws-sdk/client-budgets";
@@ -32,7 +33,6 @@ import { BatchGetProjectsCommand, BatchGetReportGroupsCommand, CodeBuildClient,
32
33
  import { DescribeDBClustersCommand as DescribeDBClustersCommand$1, DescribeDBInstancesCommand as DescribeDBInstancesCommand$1, DocDBClient, ModifyDBClusterCommand, ModifyDBInstanceCommand } from "@aws-sdk/client-docdb";
33
34
  import { DAXClient, DescribeClustersCommand, DescribeParameterGroupsCommand, DescribeParametersCommand, DescribeSubnetGroupsCommand, UpdateClusterCommand, UpdateParameterGroupCommand } from "@aws-sdk/client-dax";
34
35
  import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetTableCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
35
- import { ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
36
36
  import { AttachGroupPolicyCommand, AttachRolePolicyCommand, AttachUserPolicyCommand, CreatePolicyVersionCommand, DeletePolicyVersionCommand, DeleteRolePolicyCommand, DetachGroupPolicyCommand, DetachRolePolicyCommand, DetachUserPolicyCommand, GetGroupPolicyCommand, GetPolicyCommand as GetPolicyCommand$1, GetPolicyVersionCommand, GetRolePolicyCommand, GetUserPolicyCommand, IAMClient, ListAccessKeysCommand, ListEntitiesForPolicyCommand, ListPolicyVersionsCommand, PutGroupPolicyCommand, PutRolePolicyCommand, PutUserPolicyCommand } from "@aws-sdk/client-iam";
37
37
  import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
38
38
  import { DescribeCacheClustersCommand, DescribeCacheParameterGroupsCommand, DescribeCacheParametersCommand, DescribeReplicationGroupsCommand, DescribeUsersCommand, ElastiCacheClient, ModifyCacheParameterGroupCommand, ResetCacheParameterGroupCommand } from "@aws-sdk/client-elasticache";
@@ -5933,7 +5933,8 @@ const CHILD_ENUMERATORS = {
5933
5933
  "AWS::KMS::Key": enumerateKmsKeyChildren,
5934
5934
  "AWS::AppConfig::Application": enumerateAppConfigApplicationChildren,
5935
5935
  "AWS::EFS::FileSystem": enumerateEfsFileSystemChildren,
5936
- "AWS::RDS::DBCluster": enumerateRdsClusterChildren
5936
+ "AWS::RDS::DBCluster": enumerateRdsClusterChildren,
5937
+ "AWS::Route53::HostedZone": enumerateRoute53HostedZoneChildren
5937
5938
  };
5938
5939
  function isBodyDefinedRestApi(declared) {
5939
5940
  return declared.Body != null || declared.BodyS3Location != null;
@@ -7611,6 +7612,102 @@ async function enumerateRdsClusterChildren(ctx) {
7611
7612
  clusterMemberIds
7612
7613
  });
7613
7614
  }
7615
+ const canonRoute53Name = (s) => s.replace(/\.$/, "").toLowerCase();
7616
+ const route53RecordKey = (name, type, setIdentifier) => `${canonRoute53Name(name)}|${type.toUpperCase()}${setIdentifier !== void 0 ? `|${setIdentifier}` : ""}`;
7617
+ function diffRoute53HostedZoneChildren(input) {
7618
+ const { hostedZoneId, zoneApex, declaredRecords, liveRecords } = input;
7619
+ const declared = new Set(declaredRecords.map((r) => route53RecordKey(r.name, r.type, r.setIdentifier)));
7620
+ const soaName = liveRecords.find((r) => r.type.toUpperCase() === "SOA")?.name;
7621
+ const apex = zoneApex !== void 0 ? canonRoute53Name(zoneApex) : soaName !== void 0 ? canonRoute53Name(soaName) : void 0;
7622
+ const added = [];
7623
+ for (const r of liveRecords) {
7624
+ const type = r.type.toUpperCase();
7625
+ const name = canonRoute53Name(r.name);
7626
+ if (type === "SOA") continue;
7627
+ if (type === "NS" && apex !== void 0 && name === apex) continue;
7628
+ if (declared.has(route53RecordKey(r.name, r.type, r.setIdentifier))) continue;
7629
+ const identifier = `${hostedZoneId}_${r.name}_${type}` + (r.setIdentifier !== void 0 ? `_${r.setIdentifier}` : "");
7630
+ added.push({
7631
+ resourceType: "AWS::Route53::RecordSet",
7632
+ identifier,
7633
+ label: `${type} ${name}`,
7634
+ live: r.live ?? {
7635
+ Name: r.name,
7636
+ Type: r.type
7637
+ }
7638
+ });
7639
+ }
7640
+ return added;
7641
+ }
7642
+ async function pageResourceRecordSets(client, hostedZoneId) {
7643
+ const out = [];
7644
+ let startName;
7645
+ let startType;
7646
+ let startId;
7647
+ for (;;) {
7648
+ const res = await client.send(new ListResourceRecordSetsCommand({
7649
+ HostedZoneId: hostedZoneId,
7650
+ StartRecordName: startName,
7651
+ StartRecordType: startType,
7652
+ ...startId !== void 0 && { StartRecordIdentifier: startId }
7653
+ }));
7654
+ out.push(...res.ResourceRecordSets ?? []);
7655
+ if (!res.IsTruncated) break;
7656
+ startName = res.NextRecordName;
7657
+ startType = res.NextRecordType;
7658
+ startId = res.NextRecordIdentifier;
7659
+ }
7660
+ return out;
7661
+ }
7662
+ function route53ZoneRefMatches(declared, hostedZoneId, zoneApex) {
7663
+ if (declared.HostedZoneId !== void 0 && parentRefMatches(declared.HostedZoneId, hostedZoneId)) return true;
7664
+ const hzName = declared.HostedZoneName;
7665
+ if (hzName === void 0) return false;
7666
+ if (hzName === UNRESOLVED || hasUnresolved(hzName)) return true;
7667
+ return typeof hzName === "string" && zoneApex !== void 0 && canonRoute53Name(hzName) === canonRoute53Name(zoneApex);
7668
+ }
7669
+ async function enumerateRoute53HostedZoneChildren(ctx) {
7670
+ const { parent, desired, region } = ctx;
7671
+ const hostedZoneId = parent.physicalId;
7672
+ if (!hostedZoneId) return [];
7673
+ const zoneApex = typeof parent.declared.Name === "string" ? parent.declared.Name : void 0;
7674
+ const declaredRecords = [];
7675
+ for (const r of desired.resources) {
7676
+ if (r.resourceType !== "AWS::Route53::RecordSet") continue;
7677
+ if (!route53ZoneRefMatches(r.declared, hostedZoneId, zoneApex)) continue;
7678
+ const name = typeof r.declared.Name === "string" ? r.declared.Name : void 0;
7679
+ const type = typeof r.declared.Type === "string" ? r.declared.Type : void 0;
7680
+ if (name && type) declaredRecords.push({
7681
+ name,
7682
+ type,
7683
+ setIdentifier: typeof r.declared.SetIdentifier === "string" ? r.declared.SetIdentifier : void 0
7684
+ });
7685
+ }
7686
+ return diffRoute53HostedZoneChildren({
7687
+ hostedZoneId,
7688
+ zoneApex,
7689
+ declaredRecords,
7690
+ liveRecords: (await pageResourceRecordSets(new Route53Client({
7691
+ region,
7692
+ ...READ_RETRY
7693
+ }), hostedZoneId)).filter((r) => typeof r.Name === "string" && typeof r.Type === "string").map((r) => {
7694
+ const live = {
7695
+ Name: r.Name,
7696
+ Type: r.Type
7697
+ };
7698
+ if (r.TTL !== void 0) live.TTL = String(r.TTL);
7699
+ const values = r.ResourceRecords?.map((rr) => rr.Value).filter((v) => !!v);
7700
+ if (values && values.length > 0) live.ResourceRecords = values;
7701
+ if (r.AliasTarget) live.AliasTarget = r.AliasTarget;
7702
+ return {
7703
+ name: r.Name,
7704
+ type: r.Type,
7705
+ setIdentifier: r.SetIdentifier,
7706
+ live
7707
+ };
7708
+ })
7709
+ });
7710
+ }
7614
7711
 
7615
7712
  //#endregion
7616
7713
  //#region src/read/pem.ts
@@ -8560,7 +8657,7 @@ const readCodeBuildProject = async ({ physicalId, declared, region }) => {
8560
8657
  region,
8561
8658
  ...READ_RETRY
8562
8659
  }).send(new BatchGetProjectsCommand({ names: [name] }))).projects?.[0];
8563
- if (!p) return void 0;
8660
+ if (!p) throw new ResourceGoneError(`CodeBuild Project ${name} absent`);
8564
8661
  const model = { Name: p.name };
8565
8662
  if (p.serviceRole !== void 0) model.ServiceRole = p.serviceRole;
8566
8663
  if (p.description !== void 0) model.Description = p.description;
@@ -8894,7 +8991,15 @@ const readAcmCertificate = async ({ physicalId, declared, region }) => {
8894
8991
  Value: tag.Value ?? ""
8895
8992
  }));
8896
8993
  if (tags.length > 0) model.Tags = tags;
8897
- } catch {}
8994
+ } catch (err) {
8995
+ const declaredTags = Array.isArray(declared.Tags) ? declared.Tags.filter((t) => typeof t === "object" && t !== null).filter((t) => str$1(t.Key) !== void 0).map((t) => ({
8996
+ Key: t.Key,
8997
+ Value: str$1(t.Value) ?? ""
8998
+ })) : [];
8999
+ if (declaredTags.length > 0) model.Tags = declaredTags;
9000
+ const call = err?.name || "unknown error";
9001
+ process.stderr.write(`[cdkrd] warning: ACM ListTagsForCertificate for ${arn} failed (${call}) — mirroring declared Tags to avoid a false drift; grant acm:ListTagsForCertificate to detect out-of-band tag changes\n`);
9002
+ }
8898
9003
  return model;
8899
9004
  };
8900
9005
  const SDK_OVERRIDES = {
@@ -15551,6 +15656,7 @@ function safeStringifyJson(value) {
15551
15656
  const seen = /* @__PURE__ */ new WeakSet();
15552
15657
  const replacer = (_key, v) => {
15553
15658
  if (typeof v === "bigint") return v.toString();
15659
+ if (typeof v === "symbol") return v === UNRESOLVED ? "⟨unresolved⟩" : `⟨${v.description ?? "symbol"}⟩`;
15554
15660
  if (typeof v === "object" && v !== null) {
15555
15661
  if (seen.has(v)) return "[Circular]";
15556
15662
  seen.add(v);