cdk-real-drift 0.25.2 → 0.25.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.
package/README.md CHANGED
@@ -586,7 +586,12 @@ autoscaled DynamoDB capacity, a Lambda alias's provisioned concurrency, … —
586
586
  flagged while its live value stays within the declared `MinCapacity`/`MaxCapacity`
587
587
  band (the autoscaler enforcing the template's own delegation is intent, not drift,
588
588
  #688). A value pushed _beyond_ the band still surfaces as real drift, but `revert`
589
- deliberately refuses it (writing the initial value back would just be re-scaled). For
589
+ deliberately refuses it (writing the initial value back would just be re-scaled). The
590
+ same treatment covers an ECS **blue/green** service's production/test listener rule:
591
+ the deployment controller rewrites its forward action to a weighted config over the
592
+ declared production/alternate target-group pair, which is not flagged while the live
593
+ targets stay within that pair — an out-of-band retarget to any other group still
594
+ surfaces, refused by `revert` for the same reason (#1730). For
590
595
  anything cdkrd does not fold — an externally-managed Lambda **reserved** concurrency,
591
596
  a value another controller rewrites — run **`cdkrd ignore`** to pick the drift to
592
597
  suppress, or hand-edit the git-committed `.cdkrd/ignore.yaml`. It is a
package/dist/cli.js CHANGED
@@ -1919,6 +1919,7 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1919
1919
  const bucketNotif = resource.physicalId && opts.bucketNotificationManaged?.has(resource.physicalId) ? [resource.physicalId] : void 0;
1920
1920
  const eipSiblingId = resource.physicalId && opts.siblingEipAssociations?.has(resource.physicalId) ? resource.physicalId : opts.siblingEipAssociations?.has(resource.logicalId) ? resource.logicalId : void 0;
1921
1921
  const tgRegistrarId = resource.physicalId && opts.siblingTargetGroupRegistrars?.has(resource.physicalId) ? resource.physicalId : opts.siblingTargetGroupRegistrars?.has(resource.logicalId) ? resource.logicalId : void 0;
1922
+ const bgRuleKey = resource.resourceType === "AWS::ElasticLoadBalancingV2::ListenerRule" ? opts.ecsBgGovernedListenerRules?.[resource.logicalId] !== void 0 ? resource.logicalId : resource.physicalId && opts.ecsBgGovernedListenerRules?.[resource.physicalId] ? resource.physicalId : void 0 : void 0;
1922
1923
  const subnetSiblingId = resource.physicalId && opts.siblingSubnetCidrBlocks?.has(resource.physicalId) ? resource.physicalId : opts.siblingSubnetCidrBlocks?.has(resource.logicalId) ? resource.logicalId : void 0;
1923
1924
  const echoModel = resource.physicalId && opts.clusterEchoModel?.[resource.physicalId] ? opts.clusterEchoModel[resource.physicalId] : void 0;
1924
1925
  const rdsOptCatalog = resource.physicalId && opts.rdsOptionSettingDefaults?.[resource.physicalId] ? opts.rdsOptionSettingDefaults[resource.physicalId] : void 0;
@@ -1971,6 +1972,7 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1971
1972
  ...eipSiblingId ? { siblingEipAssociations: [eipSiblingId] } : {},
1972
1973
  ...subnetSiblingId ? { siblingSubnetCidrBlocks: [subnetSiblingId] } : {},
1973
1974
  ...tgRegistrarId ? { siblingTargetGroupRegistrars: [tgRegistrarId] } : {},
1975
+ ...bgRuleKey !== void 0 && opts.ecsBgGovernedListenerRules?.[bgRuleKey] ? { ecsBgGovernedListenerRules: { [bgRuleKey]: opts.ecsBgGovernedListenerRules[bgRuleKey] } } : {},
1974
1976
  ...echoModel && resource.physicalId ? { clusterEchoModel: { [resource.physicalId]: echoModel } } : {},
1975
1977
  ...rdsOptCatalog && resource.physicalId ? { rdsOptionSettingDefaults: { [resource.physicalId]: rdsOptCatalog } } : {},
1976
1978
  ...gaListenerPort ? { siblingListenerPorts: gaListenerPort } : {},
@@ -3212,6 +3214,8 @@ const KNOWN_DEFAULT_PATHS = {
3212
3214
  "NetworkConfiguration.AwsvpcConfiguration.AssignPublicIp": "DISABLED",
3213
3215
  "DeploymentConfiguration.Strategy": "ROLLING",
3214
3216
  "DeploymentConfiguration.BakeTimeInMinutes": 0,
3217
+ "DeploymentConfiguration.MaximumPercent": 200,
3218
+ "DeploymentConfiguration.MinimumHealthyPercent": 100,
3215
3219
  "DeploymentConfiguration.DeploymentCircuitBreaker.ResetOnHealthyTask": true,
3216
3220
  "DeploymentConfiguration.DeploymentCircuitBreaker.ThresholdConfiguration": {
3217
3221
  Type: "BOUNDED_PERCENT",
@@ -3227,6 +3231,7 @@ const KNOWN_DEFAULT_PATHS = {
3227
3231
  Rollback: false
3228
3232
  }
3229
3233
  },
3234
+ "AWS::CloudFront::VpcOrigin": { "VpcOriginEndpointConfig.OriginSSLProtocols": ["SSLv3", "TLSv1"] },
3230
3235
  "AWS::Bedrock::Guardrail": {
3231
3236
  "ContentPolicyConfig.ContentFiltersTierConfig": { TierName: "CLASSIC" },
3232
3237
  "TopicPolicyConfig.TopicsTierConfig": { TierName: "CLASSIC" }
@@ -7112,6 +7117,41 @@ function applyAutoscalerBandFold(findings, bands) {
7112
7117
  }
7113
7118
  return out;
7114
7119
  }
7120
+ function applyEcsBlueGreenListenerRuleFold(findings, allowedTgIds, liveRaw) {
7121
+ const liveTgArns = /* @__PURE__ */ new Set();
7122
+ const actions = liveRaw.Actions;
7123
+ if (Array.isArray(actions)) for (const a of actions) {
7124
+ if (!a || typeof a !== "object") continue;
7125
+ const ao = a;
7126
+ if (typeof ao.TargetGroupArn === "string") liveTgArns.add(ao.TargetGroupArn);
7127
+ const fc = ao.ForwardConfig;
7128
+ if (fc && typeof fc === "object") {
7129
+ const tgs = fc.TargetGroups;
7130
+ if (Array.isArray(tgs)) {
7131
+ for (const tg of tgs) if (tg && typeof tg === "object") {
7132
+ const arn = tg.TargetGroupArn;
7133
+ if (typeof arn === "string") liveTgArns.add(arn);
7134
+ }
7135
+ }
7136
+ }
7137
+ }
7138
+ const allowed = new Set(allowedTgIds);
7139
+ const withinAllowed = liveTgArns.size > 0 && [...liveTgArns].every((arn) => allowed.has(arn));
7140
+ const out = [];
7141
+ for (const f of findings) {
7142
+ if (!(f.tier === "declared" && /^Actions[.[]/.test(f.path) && (f.path.includes("TargetGroupArn") || f.path.includes("ForwardConfig")))) {
7143
+ out.push(f);
7144
+ continue;
7145
+ }
7146
+ if (withinAllowed) continue;
7147
+ out.push({
7148
+ ...f,
7149
+ ecsBlueGreenGoverned: true,
7150
+ ...f.hint === void 0 ? { hint: "governed by an ECS blue/green deployment (the service rewrites this listener rule's forward action, swinging weights between the production and alternate target groups); the live forward target is outside that declared pair, so this is a real change — but revert cannot converge (the deployment controller re-writes the rule). Update the service's AdvancedConfiguration, or record/ignore to accept" } : {}
7151
+ });
7152
+ }
7153
+ return out;
7154
+ }
7115
7155
  function classifyResource(resource, liveRaw, schema, opts = {}) {
7116
7156
  const { logicalId, resourceType, physicalId, declared: declaredIn } = resource;
7117
7157
  const findings = [];
@@ -8425,7 +8465,9 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
8425
8465
  const pid = resource.physicalId;
8426
8466
  const unresolvedSibling = IAM_PRINCIPAL_POLICY_TYPES.has(resourceType) && resource.siblingPolicyNames === "unresolved";
8427
8467
  const bands = opts.scalableTargetBands?.[resource.logicalId];
8428
- return (bands ? applyAutoscalerBandFold(findings, bands) : findings).map((f) => ({
8468
+ const folded = bands ? applyAutoscalerBandFold(findings, bands) : findings;
8469
+ const bgAllowed = resourceType === "AWS::ElasticLoadBalancingV2::ListenerRule" ? opts.ecsBgGovernedListenerRules?.[resource.logicalId] ?? (pid !== void 0 ? opts.ecsBgGovernedListenerRules?.[pid] : void 0) : void 0;
8470
+ return (bgAllowed ? applyEcsBlueGreenListenerRuleFold(folded, bgAllowed, liveRaw) : folded).map((f) => ({
8429
8471
  ...f,
8430
8472
  ...pid !== void 0 && { physicalId: pid },
8431
8473
  ...cp !== void 0 && { constructPath: cp },
@@ -9171,6 +9213,11 @@ async function enumerateSnsTopicChildren(ctx) {
9171
9213
  for (const r of desired.resources) if (r.resourceType === "AWS::SNS::Subscription" && parentRefMatches(r.declared.TopicArn, topicArn) && r.physicalId) declaredSubscriptionArns.push(r.physicalId);
9172
9214
  let hasDeclaredPolicy = false;
9173
9215
  for (const r of desired.resources) {
9216
+ if (r.resourceType === "AWS::SNS::TopicInlinePolicy") {
9217
+ const t = r.declared.TopicArn;
9218
+ if (t === topicArn || t !== void 0 && hasUnresolved(t)) hasDeclaredPolicy = true;
9219
+ continue;
9220
+ }
9174
9221
  if (r.resourceType !== "AWS::SNS::TopicPolicy") continue;
9175
9222
  const topics = r.declared.Topics;
9176
9223
  if (Array.isArray(topics)) {
@@ -9602,6 +9649,11 @@ async function enumerateSqsQueueChildren(ctx) {
9602
9649
  if (!queueUrl) return [];
9603
9650
  let hasDeclaredPolicy = false;
9604
9651
  for (const r of desired.resources) {
9652
+ if (r.resourceType === "AWS::SQS::QueueInlinePolicy") {
9653
+ const q = r.declared.Queue;
9654
+ if (q === queueUrl || q !== void 0 && hasUnresolved(q)) hasDeclaredPolicy = true;
9655
+ continue;
9656
+ }
9605
9657
  if (r.resourceType !== "AWS::SQS::QueuePolicy") continue;
9606
9658
  const queues = r.declared.Queues;
9607
9659
  if (Array.isArray(queues)) {
@@ -10518,7 +10570,7 @@ function diffVpcCidrBlockChildren(input) {
10518
10570
  return added;
10519
10571
  }
10520
10572
  function isAwsManagedSecurityGroup(tags) {
10521
- return (tags ?? []).some((t) => typeof t.Key === "string" && (t.Key.startsWith("aws:") || t.Key.startsWith("kubernetes.io/cluster/")));
10573
+ return (tags ?? []).some((t) => typeof t.Key === "string" && (t.Key.startsWith("aws:") || t.Key.startsWith("kubernetes.io/cluster/") || t.Key === "aws.cloudfront.vpcorigin"));
10522
10574
  }
10523
10575
  function diffVpcSecurityGroupChildren(input) {
10524
10576
  const declared = new Set(input.declaredSecurityGroupIds);
@@ -15730,7 +15782,12 @@ function buildSiblingTargetGroupRegistrars(desired) {
15730
15782
  if (r.resourceType === ECS_SERVICE_TYPE) {
15731
15783
  const lbs = d.LoadBalancers;
15732
15784
  if (Array.isArray(lbs)) {
15733
- for (const lb of lbs) if (lb && typeof lb === "object") markTg(lb.TargetGroupArn);
15785
+ for (const lb of lbs) if (lb && typeof lb === "object") {
15786
+ const lbo = lb;
15787
+ markTg(lbo.TargetGroupArn);
15788
+ const adv = lbo.AdvancedConfiguration;
15789
+ if (adv && typeof adv === "object") markTg(adv.AlternateTargetGroupArn);
15790
+ }
15734
15791
  }
15735
15792
  } else if (r.resourceType === AUTO_SCALING_GROUP_TYPE) {
15736
15793
  const arns = d.TargetGroupARNs;
@@ -15742,6 +15799,62 @@ function buildSiblingTargetGroupRegistrars(desired) {
15742
15799
  }
15743
15800
  return registered;
15744
15801
  }
15802
+ function buildEcsBgGovernedListenerRules(desired) {
15803
+ const LISTENER_RULE_TYPE = "AWS::ElasticLoadBalancingV2::ListenerRule";
15804
+ const ruleIdsByLogicalId = /* @__PURE__ */ new Map();
15805
+ const ruleLogicalIdByPhysicalId = /* @__PURE__ */ new Map();
15806
+ const tgIdsByLogicalId = /* @__PURE__ */ new Map();
15807
+ for (const r of desired.resources) if (r.resourceType === LISTENER_RULE_TYPE) {
15808
+ ruleIdsByLogicalId.set(r.logicalId, [r.logicalId, ...r.physicalId ? [r.physicalId] : []]);
15809
+ if (r.physicalId) ruleLogicalIdByPhysicalId.set(r.physicalId, r.logicalId);
15810
+ } else if (r.resourceType === TARGET_GROUP_TYPE) tgIdsByLogicalId.set(r.logicalId, [r.logicalId, ...r.physicalId ? [r.physicalId] : []]);
15811
+ const refLogicalId = (ref) => {
15812
+ if (ref && typeof ref === "object") {
15813
+ if ("Ref" in ref && typeof ref.Ref === "string") return ref.Ref;
15814
+ if ("Fn::GetAtt" in ref) {
15815
+ const g = ref["Fn::GetAtt"];
15816
+ if (Array.isArray(g) && typeof g[0] === "string") return g[0];
15817
+ }
15818
+ }
15819
+ };
15820
+ const out = {};
15821
+ for (const r of desired.resources) {
15822
+ if (r.resourceType !== ECS_SERVICE_TYPE) continue;
15823
+ const decl = r.declared;
15824
+ if (!decl || typeof decl !== "object") continue;
15825
+ const lbs = decl.LoadBalancers;
15826
+ if (!Array.isArray(lbs)) continue;
15827
+ for (const lb of lbs) {
15828
+ if (!lb || typeof lb !== "object") continue;
15829
+ const lbo = lb;
15830
+ const adv = lbo.AdvancedConfiguration;
15831
+ if (!adv || typeof adv !== "object") continue;
15832
+ const advo = adv;
15833
+ const allowed = [];
15834
+ for (const tgRef of [lbo.TargetGroupArn, advo.AlternateTargetGroupArn]) {
15835
+ const lg = refLogicalId(tgRef);
15836
+ if (lg !== void 0) {
15837
+ const ids = tgIdsByLogicalId.get(lg);
15838
+ if (ids) allowed.push(...ids);
15839
+ } else if (typeof tgRef === "string" && tgRef) allowed.push(tgRef);
15840
+ }
15841
+ if (allowed.length === 0) continue;
15842
+ for (const key of ["ProductionListenerRule", "TestListenerRule"]) {
15843
+ const ruleRef = advo[key];
15844
+ let ruleIds;
15845
+ const lg = refLogicalId(ruleRef);
15846
+ if (lg !== void 0) ruleIds = ruleIdsByLogicalId.get(lg);
15847
+ else if (typeof ruleRef === "string" && ruleRef) {
15848
+ const rl = ruleLogicalIdByPhysicalId.get(ruleRef);
15849
+ ruleIds = rl !== void 0 ? ruleIdsByLogicalId.get(rl) : [ruleRef];
15850
+ }
15851
+ if (!ruleIds) continue;
15852
+ for (const id of ruleIds) out[id] = [...new Set([...out[id] ?? [], ...allowed])];
15853
+ }
15854
+ }
15855
+ }
15856
+ return out;
15857
+ }
15745
15858
  function buildClusterEchoModels(desired) {
15746
15859
  const parentTypes = new Set(Object.values(CLUSTER_ECHO_CHILD).map((s) => s.parentType));
15747
15860
  const clusterByPhys = {};
@@ -16083,6 +16196,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
16083
16196
  bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
16084
16197
  clusterEchoModel: buildClusterEchoModels(desired),
16085
16198
  scalableTargetBands: buildScalableTargetBands(desired),
16199
+ ecsBgGovernedListenerRules: buildEcsBgGovernedListenerRules(desired),
16086
16200
  siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
16087
16201
  siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
16088
16202
  siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, liveModelMap(reads)),
@@ -16162,6 +16276,7 @@ async function regatherTouched(gathered, touched, region) {
16162
16276
  bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
16163
16277
  clusterEchoModel: buildClusterEchoModels(desired),
16164
16278
  scalableTargetBands: buildScalableTargetBands(desired),
16279
+ ecsBgGovernedListenerRules: buildEcsBgGovernedListenerRules(desired),
16165
16280
  siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
16166
16281
  siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
16167
16282
  siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
@@ -20478,6 +20593,15 @@ function buildRevertPlan(findings, baseline, opts = {}) {
20478
20593
  });
20479
20594
  continue;
20480
20595
  }
20596
+ if (f.ecsBlueGreenGoverned) {
20597
+ notRevertable.push({
20598
+ displayId,
20599
+ resourceType: f.resourceType,
20600
+ path: f.path,
20601
+ reason: "managed by an ECS blue/green deployment — revert would fight the deployment controller; update the service's AdvancedConfiguration, or record/ignore to accept"
20602
+ });
20603
+ continue;
20604
+ }
20481
20605
  if (f.tier === "deleted") {
20482
20606
  notRevertable.push({
20483
20607
  displayId,