cdk-real-drift 0.17.2 → 0.18.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.
package/README.md CHANGED
@@ -1181,6 +1181,9 @@ Control cannot sub-path patch it),
1181
1181
  `AWS::Glue::Job` / `Classifier` / `Workflow`),
1182
1182
  `servicediscovery:UpdateHttpNamespace` (reverts an
1183
1183
  `AWS::ServiceDiscovery::HttpNamespace` `Description`),
1184
+ `servicediscovery:UpdateService` (reverts an `AWS::ServiceDiscovery::Service`'s
1185
+ `Description` / `DnsConfig.DnsRecords` / `HealthCheckConfig` — a DNS-namespace
1186
+ service; an API-only (HTTP) namespace service cannot be updated),
1184
1187
  `cognito-sync:SetCognitoEvents` (reverts an `AWS::Cognito::IdentityPool`'s
1185
1188
  writeOnly `CognitoEvents`),
1186
1189
  `kinesisvideo:UpdateDataRetention` / `kinesisvideo:UpdateSignalingChannel` /
package/dist/cli.js CHANGED
@@ -56,7 +56,7 @@ import { BuildBotLocaleCommand, CreateIntentCommand, CreateSlotCommand, CreateSl
56
56
  import { GetScheduleCommand, SchedulerClient } from "@aws-sdk/client-scheduler";
57
57
  import { DescribeReceiptRuleCommand, DescribeReceiptRuleSetCommand, ListReceiptFiltersCommand, SESClient, UpdateReceiptRuleCommand } from "@aws-sdk/client-ses";
58
58
  import { DescribeEndpointConfigCommand, DescribeMonitoringScheduleCommand, ListTagsCommand as ListTagsCommand$1, SageMakerClient } from "@aws-sdk/client-sagemaker";
59
- import { GetNamespaceCommand, GetServiceCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$4, ServiceDiscoveryClient, UpdateHttpNamespaceCommand } from "@aws-sdk/client-servicediscovery";
59
+ import { GetNamespaceCommand, GetServiceCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$4, ServiceDiscoveryClient, UpdateHttpNamespaceCommand, UpdateServiceCommand as UpdateServiceCommand$1 } from "@aws-sdk/client-servicediscovery";
60
60
  import { createHash } from "node:crypto";
61
61
  import { S_BAR, S_BAR_END, S_BAR_START, S_CHECKBOX_INACTIVE, S_CHECKBOX_SELECTED, confirm, isCancel, select, spinner } from "@clack/prompts";
62
62
  import pc from "picocolors";
@@ -1922,6 +1922,8 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1922
1922
  const gaListenerPort = typeof listenerArn === "string" && opts.siblingListenerPorts?.[listenerArn] !== void 0 ? { [listenerArn]: opts.siblingListenerPorts[listenerArn] } : void 0;
1923
1923
  const dmsClass = resource.resourceType === "AWS::DMS::ReplicationInstance" ? resource.declared?.ReplicationInstanceClass : void 0;
1924
1924
  const dmsStorageDefault = typeof dmsClass === "string" && opts.accountDefaults?.dmsAllocatedStorageDefaults?.[dmsClass] !== void 0 ? { dmsAllocatedStorageDefaults: { [dmsClass]: opts.accountDefaults.dmsAllocatedStorageDefaults[dmsClass] } } : void 0;
1925
+ const cvpnVpcMap = opts.siblingClientVpnEndpointVpcs;
1926
+ const cvpnVpcKey = resource.resourceType !== "AWS::EC2::ClientVpnEndpoint" || cvpnVpcMap === void 0 ? void 0 : resource.logicalId in cvpnVpcMap ? resource.logicalId : resource.physicalId !== void 0 && resource.physicalId in cvpnVpcMap ? resource.physicalId : void 0;
1925
1927
  return sanitizeAccountId({
1926
1928
  corpusVersion: 1,
1927
1929
  resource: {
@@ -1959,7 +1961,8 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1959
1961
  ...echoModel && resource.physicalId ? { clusterEchoModel: { [resource.physicalId]: echoModel } } : {},
1960
1962
  ...rdsOptCatalog && resource.physicalId ? { rdsOptionSettingDefaults: { [resource.physicalId]: rdsOptCatalog } } : {},
1961
1963
  ...gaListenerPort ? { siblingListenerPorts: gaListenerPort } : {},
1962
- ...dmsStorageDefault ? { accountDefaults: dmsStorageDefault } : {}
1964
+ ...dmsStorageDefault ? { accountDefaults: dmsStorageDefault } : {},
1965
+ ...cvpnVpcKey !== void 0 && cvpnVpcMap !== void 0 ? { siblingClientVpnEndpointVpcs: { [cvpnVpcKey]: cvpnVpcMap[cvpnVpcKey] ?? null } } : {}
1963
1966
  },
1964
1967
  expected: findings
1965
1968
  }, opts.accountId);
@@ -5831,7 +5834,8 @@ const DEFAULT_SG_LIST_PATHS = {
5831
5834
  "AWS::RedshiftServerless::Workgroup": "SecurityGroupIds",
5832
5835
  "AWS::EC2::Instance": "SecurityGroupIds",
5833
5836
  "AWS::DAX::Cluster": "SecurityGroupIds",
5834
- "AWS::DMS::ReplicationInstance": "VpcSecurityGroupIds"
5837
+ "AWS::DMS::ReplicationInstance": "VpcSecurityGroupIds",
5838
+ "AWS::EC2::ClientVpnEndpoint": "SecurityGroupIds"
5835
5839
  };
5836
5840
  /** #1269 fold decision for an UNDECLARED default-SUBNET list (RedshiftServerless Workgroup
5837
5841
  * SubnetIds). Unlike the SG gate (which folds only a SINGLE default SG), a workgroup placed into
@@ -7480,6 +7484,20 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7480
7484
  });
7481
7485
  continue;
7482
7486
  }
7487
+ if (resourceType === "AWS::EC2::ClientVpnEndpoint" && k === "VpcId" && typeof v === "string") {
7488
+ const vpcMap = opts.siblingClientVpnEndpointVpcs;
7489
+ const derived = vpcMap === void 0 ? void 0 : logicalId in vpcMap ? vpcMap[logicalId] : physicalId !== void 0 && physicalId in vpcMap ? vpcMap[physicalId] : void 0;
7490
+ if (derived !== void 0) {
7491
+ findings.push({
7492
+ tier: derived === null || derived === v ? "atDefault" : "undeclared",
7493
+ logicalId,
7494
+ resourceType,
7495
+ path: k,
7496
+ actual: v
7497
+ });
7498
+ continue;
7499
+ }
7500
+ }
7483
7501
  if (DEFAULT_SUBNET_LIST_PATHS[resourceType] === k && !isTrivialEmpty(v)) {
7484
7502
  findings.push({
7485
7503
  tier: shouldFoldDefaultSubnetList(resourceType, k, v, opts.defaultSubnetIds) ? "atDefault" : "undeclared",
@@ -13920,7 +13938,8 @@ const DEFAULT_SG_LIST_TYPES = new Set([
13920
13938
  "AWS::DocDB::DBCluster",
13921
13939
  "AWS::EC2::Instance",
13922
13940
  "AWS::DAX::Cluster",
13923
- "AWS::DMS::ReplicationInstance"
13941
+ "AWS::DMS::ReplicationInstance",
13942
+ "AWS::EC2::ClientVpnEndpoint"
13924
13943
  ]);
13925
13944
  const DEFAULT_SUBNET_LIST_TYPES = new Set(["AWS::RedshiftServerless::Workgroup"]);
13926
13945
  const defaultSgIdsCache = /* @__PURE__ */ new Map();
@@ -14436,6 +14455,50 @@ function buildSiblingEipAssociations(desired) {
14436
14455
  }
14437
14456
  return associated;
14438
14457
  }
14458
+ function buildClientVpnEndpointSiblingVpcs(desired) {
14459
+ const refLogicalId = (ref) => {
14460
+ if (ref && typeof ref === "object") {
14461
+ if ("Ref" in ref && typeof ref.Ref === "string") return ref.Ref;
14462
+ if ("Fn::GetAtt" in ref) {
14463
+ const g = ref["Fn::GetAtt"];
14464
+ if (Array.isArray(g) && typeof g[0] === "string") return g[0];
14465
+ }
14466
+ }
14467
+ };
14468
+ const endpointIds = /* @__PURE__ */ new Map();
14469
+ const subnetVpcRaw = /* @__PURE__ */ new Map();
14470
+ const vpcPhysical = /* @__PURE__ */ new Map();
14471
+ for (const r of desired.resources) if (r.resourceType === "AWS::EC2::ClientVpnEndpoint") {
14472
+ const ids = [r.logicalId];
14473
+ if (r.physicalId) ids.push(r.physicalId);
14474
+ endpointIds.set(r.logicalId, ids);
14475
+ } else if (r.resourceType === "AWS::EC2::Subnet") {
14476
+ const raw = r.declared?.VpcId;
14477
+ subnetVpcRaw.set(r.logicalId, raw);
14478
+ if (r.physicalId) subnetVpcRaw.set(r.physicalId, raw);
14479
+ } else if (r.resourceType === "AWS::EC2::VPC" && r.physicalId) vpcPhysical.set(r.logicalId, r.physicalId);
14480
+ const out = {};
14481
+ for (const r of desired.resources) {
14482
+ if (r.resourceType !== "AWS::EC2::ClientVpnTargetNetworkAssociation") continue;
14483
+ const d = r.declared ?? {};
14484
+ const epLogical = refLogicalId(d.ClientVpnEndpointId);
14485
+ const epKeys = epLogical !== void 0 ? endpointIds.get(epLogical) ?? [] : typeof d.ClientVpnEndpointId === "string" && d.ClientVpnEndpointId ? [d.ClientVpnEndpointId] : [];
14486
+ if (epKeys.length === 0) continue;
14487
+ const subnetKey = refLogicalId(d.SubnetId) ?? (typeof d.SubnetId === "string" ? d.SubnetId : "");
14488
+ const rawVpc = subnetVpcRaw.get(subnetKey);
14489
+ let derived = null;
14490
+ if (typeof rawVpc === "string" && rawVpc) derived = rawVpc;
14491
+ else {
14492
+ const vpcLogical = refLogicalId(rawVpc);
14493
+ if (vpcLogical !== void 0) derived = vpcPhysical.get(vpcLogical) ?? null;
14494
+ }
14495
+ for (const key of epKeys) {
14496
+ if (key in out && out[key] !== derived) derived = null;
14497
+ out[key] = derived;
14498
+ }
14499
+ }
14500
+ return out;
14501
+ }
14439
14502
  function buildSiblingSubnetCidrBlocks(desired) {
14440
14503
  const subnetIdentities = /* @__PURE__ */ new Map();
14441
14504
  for (const r of desired.resources) {
@@ -14862,6 +14925,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
14862
14925
  bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
14863
14926
  clusterEchoModel: buildClusterEchoModels(desired),
14864
14927
  scalableTargetBands: buildScalableTargetBands(desired),
14928
+ siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
14865
14929
  rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
14866
14930
  };
14867
14931
  const corpusDir = process.env[CORPUS_DIR_ENV];
@@ -14938,6 +15002,7 @@ async function regatherTouched(gathered, touched, region) {
14938
15002
  bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
14939
15003
  clusterEchoModel: buildClusterEchoModels(desired),
14940
15004
  scalableTargetBands: buildScalableTargetBands(desired),
15005
+ siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
14941
15006
  rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
14942
15007
  };
14943
15008
  const fresh = [];
@@ -16794,6 +16859,54 @@ const writeServiceDiscoveryHttpNamespace = async (ctx, ops) => {
16794
16859
  Namespace: { Description: str(m.Description) ?? "" }
16795
16860
  }));
16796
16861
  };
16862
+ const SD_SERVICE_MUTABLE_TOPS = new Set([
16863
+ "Description",
16864
+ "DnsConfig",
16865
+ "HealthCheckConfig"
16866
+ ]);
16867
+ const writeServiceDiscoveryService = async (ctx, ops) => {
16868
+ const id = str(ctx.physicalId);
16869
+ if (!id) throw new Error("cannot resolve Cloud Map service id for revert");
16870
+ const desired = await desiredModel("AWS::ServiceDiscovery::Service", ctx, ops);
16871
+ if (desired.Type === "HTTP") throw new Error(`ServiceDiscovery Service ${id} lives in an API-only (HTTP) namespace — UpdateService cannot modify it, so its drift is not revertable`);
16872
+ const unExpressible = /* @__PURE__ */ new Set();
16873
+ let anyExpressible = false;
16874
+ for (const op of ops) {
16875
+ const top = opTopSeg(op.path);
16876
+ if (!SD_SERVICE_MUTABLE_TOPS.has(top)) {
16877
+ unExpressible.add(top);
16878
+ continue;
16879
+ }
16880
+ const sub = op.path.replace(/^\//, "").split("/")[1] ?? "";
16881
+ if (top === "DnsConfig" && sub !== "DnsRecords" && sub !== "") {
16882
+ unExpressible.add(`DnsConfig/${sub}`);
16883
+ continue;
16884
+ }
16885
+ anyExpressible = true;
16886
+ }
16887
+ if (anyExpressible) {
16888
+ const service = {};
16889
+ if (str(desired.Description)) service.Description = desired.Description;
16890
+ const dns = desired.DnsConfig;
16891
+ const records = dns && Array.isArray(dns.DnsRecords) ? dns.DnsRecords : void 0;
16892
+ if (records && records.length > 0) service.DnsConfig = { DnsRecords: records.map((r) => {
16893
+ const rec = r;
16894
+ return {
16895
+ Type: rec.Type,
16896
+ TTL: typeof rec.TTL === "number" ? rec.TTL : Number(rec.TTL)
16897
+ };
16898
+ }) };
16899
+ if (desired.HealthCheckConfig !== void 0) service.HealthCheckConfig = desired.HealthCheckConfig;
16900
+ await new ServiceDiscoveryClient({
16901
+ region: ctx.region,
16902
+ ...CLIENT_TIMEOUTS
16903
+ }).send(new UpdateServiceCommand$1({
16904
+ Id: id,
16905
+ Service: service
16906
+ }));
16907
+ }
16908
+ if (unExpressible.size > 0) throw new Error(`ServiceDiscovery Service ${id}: UpdateService cannot express ${[...unExpressible].join(", ")} (create-only / immutable)${anyExpressible ? " — the other drifted values were reverted" : ""}`);
16909
+ };
16797
16910
  const DOCDB_CLUSTER_MODIFY_PARAMS = new Set([
16798
16911
  "BackupRetentionPeriod",
16799
16912
  "PreferredBackupWindow",
@@ -18217,6 +18330,7 @@ const SDK_WRITERS = {
18217
18330
  "AWS::DocDB::DBCluster": writeDocDbCluster,
18218
18331
  "AWS::DocDB::DBInstance": writeDocDbInstance,
18219
18332
  "AWS::ServiceDiscovery::HttpNamespace": writeServiceDiscoveryHttpNamespace,
18333
+ "AWS::ServiceDiscovery::Service": writeServiceDiscoveryService,
18220
18334
  "AWS::S3::BucketPolicy": writeS3BucketPolicy,
18221
18335
  "AWS::SNS::TopicPolicy": writeSnsTopicPolicy,
18222
18336
  "AWS::SQS::QueuePolicy": writeSqsQueuePolicy,