cdk-real-drift 0.25.2 → 0.25.4
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 +8 -2
- package/dist/cli.js +197 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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).
|
|
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
|
|
@@ -689,7 +694,8 @@ The table of every drift kind and its section label is up in
|
|
|
689
694
|
in full as _potential_ (unconfirmed) drift and don't drive the `--fail` exit;
|
|
690
695
|
`result:` points you at `cdkrd record` to accept them (or `revert` to remove).
|
|
691
696
|
Once a resource is fully snapshotted, a value that _appears_ later is real drift
|
|
692
|
-
(`appeared since record`)
|
|
697
|
+
(`appeared since record`) — and the same applies to a whole out-of-band-created
|
|
698
|
+
child resource once its parent's child inventory is recorded.
|
|
693
699
|
- **`↳` origin hint**: when a finding's live value has a recognizable external
|
|
694
700
|
source — e.g. the CloudWatch Application Signals / Lambda Insights
|
|
695
701
|
auto-instrumentation footprint (an added Insights layer + tracer execution
|
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
|
-
|
|
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);
|
|
@@ -15201,6 +15253,8 @@ function addedFinding(parent, c, read) {
|
|
|
15201
15253
|
physicalId: c.identifier,
|
|
15202
15254
|
constructPath: `${parent.constructPath ?? parent.logicalId} ▸ ${c.label}`,
|
|
15203
15255
|
resourceType: c.resourceType,
|
|
15256
|
+
parentLogicalId: parent.logicalId,
|
|
15257
|
+
parentResourceType: parent.resourceType,
|
|
15204
15258
|
path: "",
|
|
15205
15259
|
actual: read.model,
|
|
15206
15260
|
note: read.ok ? "created out of band — not in your CloudFormation template" : "created out of band — not in your CloudFormation template; live model unreadable this run",
|
|
@@ -15730,7 +15784,12 @@ function buildSiblingTargetGroupRegistrars(desired) {
|
|
|
15730
15784
|
if (r.resourceType === ECS_SERVICE_TYPE) {
|
|
15731
15785
|
const lbs = d.LoadBalancers;
|
|
15732
15786
|
if (Array.isArray(lbs)) {
|
|
15733
|
-
for (const lb of lbs) if (lb && typeof lb === "object")
|
|
15787
|
+
for (const lb of lbs) if (lb && typeof lb === "object") {
|
|
15788
|
+
const lbo = lb;
|
|
15789
|
+
markTg(lbo.TargetGroupArn);
|
|
15790
|
+
const adv = lbo.AdvancedConfiguration;
|
|
15791
|
+
if (adv && typeof adv === "object") markTg(adv.AlternateTargetGroupArn);
|
|
15792
|
+
}
|
|
15734
15793
|
}
|
|
15735
15794
|
} else if (r.resourceType === AUTO_SCALING_GROUP_TYPE) {
|
|
15736
15795
|
const arns = d.TargetGroupARNs;
|
|
@@ -15742,6 +15801,62 @@ function buildSiblingTargetGroupRegistrars(desired) {
|
|
|
15742
15801
|
}
|
|
15743
15802
|
return registered;
|
|
15744
15803
|
}
|
|
15804
|
+
function buildEcsBgGovernedListenerRules(desired) {
|
|
15805
|
+
const LISTENER_RULE_TYPE = "AWS::ElasticLoadBalancingV2::ListenerRule";
|
|
15806
|
+
const ruleIdsByLogicalId = /* @__PURE__ */ new Map();
|
|
15807
|
+
const ruleLogicalIdByPhysicalId = /* @__PURE__ */ new Map();
|
|
15808
|
+
const tgIdsByLogicalId = /* @__PURE__ */ new Map();
|
|
15809
|
+
for (const r of desired.resources) if (r.resourceType === LISTENER_RULE_TYPE) {
|
|
15810
|
+
ruleIdsByLogicalId.set(r.logicalId, [r.logicalId, ...r.physicalId ? [r.physicalId] : []]);
|
|
15811
|
+
if (r.physicalId) ruleLogicalIdByPhysicalId.set(r.physicalId, r.logicalId);
|
|
15812
|
+
} else if (r.resourceType === TARGET_GROUP_TYPE) tgIdsByLogicalId.set(r.logicalId, [r.logicalId, ...r.physicalId ? [r.physicalId] : []]);
|
|
15813
|
+
const refLogicalId = (ref) => {
|
|
15814
|
+
if (ref && typeof ref === "object") {
|
|
15815
|
+
if ("Ref" in ref && typeof ref.Ref === "string") return ref.Ref;
|
|
15816
|
+
if ("Fn::GetAtt" in ref) {
|
|
15817
|
+
const g = ref["Fn::GetAtt"];
|
|
15818
|
+
if (Array.isArray(g) && typeof g[0] === "string") return g[0];
|
|
15819
|
+
}
|
|
15820
|
+
}
|
|
15821
|
+
};
|
|
15822
|
+
const out = {};
|
|
15823
|
+
for (const r of desired.resources) {
|
|
15824
|
+
if (r.resourceType !== ECS_SERVICE_TYPE) continue;
|
|
15825
|
+
const decl = r.declared;
|
|
15826
|
+
if (!decl || typeof decl !== "object") continue;
|
|
15827
|
+
const lbs = decl.LoadBalancers;
|
|
15828
|
+
if (!Array.isArray(lbs)) continue;
|
|
15829
|
+
for (const lb of lbs) {
|
|
15830
|
+
if (!lb || typeof lb !== "object") continue;
|
|
15831
|
+
const lbo = lb;
|
|
15832
|
+
const adv = lbo.AdvancedConfiguration;
|
|
15833
|
+
if (!adv || typeof adv !== "object") continue;
|
|
15834
|
+
const advo = adv;
|
|
15835
|
+
const allowed = [];
|
|
15836
|
+
for (const tgRef of [lbo.TargetGroupArn, advo.AlternateTargetGroupArn]) {
|
|
15837
|
+
const lg = refLogicalId(tgRef);
|
|
15838
|
+
if (lg !== void 0) {
|
|
15839
|
+
const ids = tgIdsByLogicalId.get(lg);
|
|
15840
|
+
if (ids) allowed.push(...ids);
|
|
15841
|
+
} else if (typeof tgRef === "string" && tgRef) allowed.push(tgRef);
|
|
15842
|
+
}
|
|
15843
|
+
if (allowed.length === 0) continue;
|
|
15844
|
+
for (const key of ["ProductionListenerRule", "TestListenerRule"]) {
|
|
15845
|
+
const ruleRef = advo[key];
|
|
15846
|
+
let ruleIds;
|
|
15847
|
+
const lg = refLogicalId(ruleRef);
|
|
15848
|
+
if (lg !== void 0) ruleIds = ruleIdsByLogicalId.get(lg);
|
|
15849
|
+
else if (typeof ruleRef === "string" && ruleRef) {
|
|
15850
|
+
const rl = ruleLogicalIdByPhysicalId.get(ruleRef);
|
|
15851
|
+
ruleIds = rl !== void 0 ? ruleIdsByLogicalId.get(rl) : [ruleRef];
|
|
15852
|
+
}
|
|
15853
|
+
if (!ruleIds) continue;
|
|
15854
|
+
for (const id of ruleIds) out[id] = [...new Set([...out[id] ?? [], ...allowed])];
|
|
15855
|
+
}
|
|
15856
|
+
}
|
|
15857
|
+
}
|
|
15858
|
+
return out;
|
|
15859
|
+
}
|
|
15745
15860
|
function buildClusterEchoModels(desired) {
|
|
15746
15861
|
const parentTypes = new Set(Object.values(CLUSTER_ECHO_CHILD).map((s) => s.parentType));
|
|
15747
15862
|
const clusterByPhys = {};
|
|
@@ -15971,6 +16086,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15971
16086
|
const oaiCanonicalIds = buildOaiCanonicalIds(desired);
|
|
15972
16087
|
const siblingStackCache = /* @__PURE__ */ new Map();
|
|
15973
16088
|
const crossRegionProbe = makeCrossRegionSiblingProbe(desired.accountId, region);
|
|
16089
|
+
const childScanComplete = [];
|
|
15974
16090
|
for (const r of desired.resources) {
|
|
15975
16091
|
const enumerate = CHILD_ENUMERATORS[r.resourceType];
|
|
15976
16092
|
if (!enumerate || !r.physicalId) continue;
|
|
@@ -15998,6 +16114,10 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15998
16114
|
const read = await readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds, region, desired.accountId);
|
|
15999
16115
|
findings.push(addedFinding(r, c, read));
|
|
16000
16116
|
}
|
|
16117
|
+
childScanComplete.push({
|
|
16118
|
+
logicalId: r.logicalId,
|
|
16119
|
+
resourceType: r.resourceType
|
|
16120
|
+
});
|
|
16001
16121
|
} catch (e) {
|
|
16002
16122
|
findings.push({
|
|
16003
16123
|
tier: "skipped",
|
|
@@ -16008,6 +16128,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
16008
16128
|
});
|
|
16009
16129
|
}
|
|
16010
16130
|
}
|
|
16131
|
+
desired.childScanComplete = childScanComplete;
|
|
16011
16132
|
let kmsAliasTargets = {};
|
|
16012
16133
|
if (desired.resources.some((r) => usesManagedKmsAlias(r.declared) || typeNeedsManagedKeyResolution(r.resourceType))) {
|
|
16013
16134
|
const resolved = await fetchManagedAliasTargets(region);
|
|
@@ -16083,6 +16204,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
16083
16204
|
bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
|
|
16084
16205
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
16085
16206
|
scalableTargetBands: buildScalableTargetBands(desired),
|
|
16207
|
+
ecsBgGovernedListenerRules: buildEcsBgGovernedListenerRules(desired),
|
|
16086
16208
|
siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
|
|
16087
16209
|
siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
|
|
16088
16210
|
siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, liveModelMap(reads)),
|
|
@@ -16162,6 +16284,7 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
16162
16284
|
bucketNotificationConfigs: buildBucketNotificationConfigs(desired),
|
|
16163
16285
|
clusterEchoModel: buildClusterEchoModels(desired),
|
|
16164
16286
|
scalableTargetBands: buildScalableTargetBands(desired),
|
|
16287
|
+
ecsBgGovernedListenerRules: buildEcsBgGovernedListenerRules(desired),
|
|
16165
16288
|
siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
|
|
16166
16289
|
siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
|
|
16167
16290
|
siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
|
|
@@ -16357,7 +16480,8 @@ const KNOWN_BASELINE_KEYS = new Set([
|
|
|
16357
16480
|
"completeResources",
|
|
16358
16481
|
"recordedPhysicalIds",
|
|
16359
16482
|
"recordedSourceFingerprints",
|
|
16360
|
-
"observedDefaults"
|
|
16483
|
+
"observedDefaults",
|
|
16484
|
+
"enumeratedParents"
|
|
16361
16485
|
]);
|
|
16362
16486
|
const KNOWN_RECORDED_ENTRY_KEYS = new Set([
|
|
16363
16487
|
"logicalId",
|
|
@@ -16419,6 +16543,7 @@ async function loadBaseline(stackName, accountId, region) {
|
|
|
16419
16543
|
validateRecordedPhysicalIds(parsed.recordedPhysicalIds, path);
|
|
16420
16544
|
validateRecordedSourceFingerprints(parsed.recordedSourceFingerprints, path);
|
|
16421
16545
|
validateObservedDefaults(parsed.observedDefaults, path);
|
|
16546
|
+
validateEnumeratedParents(parsed.enumeratedParents, path);
|
|
16422
16547
|
return parsed;
|
|
16423
16548
|
}
|
|
16424
16549
|
/**
|
|
@@ -16532,6 +16657,24 @@ function validateObservedDefaults(value, path) {
|
|
|
16532
16657
|
if (unknown.length > 0) throw new Error(`${at}[${i}]: unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} — known keys: "logicalId", "resourceType", "path"`);
|
|
16533
16658
|
});
|
|
16534
16659
|
}
|
|
16660
|
+
/**
|
|
16661
|
+
* #1737: validate `enumeratedParents` (optional). When present it must be an array of
|
|
16662
|
+
* { logicalId, resourceType } string pairs with no unknown keys — same loud-vs-silent
|
|
16663
|
+
* principle as validateObservedDefaults (a malformed marker would silently disable the
|
|
16664
|
+
* appeared-since-record confirmation this field exists to drive).
|
|
16665
|
+
*/
|
|
16666
|
+
function validateEnumeratedParents(value, path) {
|
|
16667
|
+
if (value === void 0) return;
|
|
16668
|
+
const at = `baseline file ${path}: \`enumeratedParents\``;
|
|
16669
|
+
if (!Array.isArray(value)) throw new Error(`${at} must be an array of { logicalId, resourceType }`);
|
|
16670
|
+
value.forEach((entry, i) => {
|
|
16671
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) throw new Error(`${at}[${i}] must be an object { logicalId, resourceType }`);
|
|
16672
|
+
const obj = entry;
|
|
16673
|
+
for (const k of ["logicalId", "resourceType"]) if (typeof obj[k] !== "string") throw new Error(`${at}[${i}]: "${k}" is required and must be a string`);
|
|
16674
|
+
const unknown = Object.keys(obj).filter((k) => k !== "logicalId" && k !== "resourceType");
|
|
16675
|
+
if (unknown.length > 0) throw new Error(`${at}[${i}]: unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} — known keys: "logicalId", "resourceType"`);
|
|
16676
|
+
});
|
|
16677
|
+
}
|
|
16535
16678
|
/** Deterministic order for `recorded` entries: lexicographic by (logicalId, path).
|
|
16536
16679
|
* The single point where order is imposed — read/compare logic is order-independent,
|
|
16537
16680
|
* so this only affects the bytes on disk. Without it the entries inherit findings
|
|
@@ -16569,7 +16712,8 @@ async function writeBaselineFile(b) {
|
|
|
16569
16712
|
...b.completeResources ? { completeResources: [...b.completeResources].sort() } : {},
|
|
16570
16713
|
...b.recordedPhysicalIds ? { recordedPhysicalIds: sortedPhysicalIds(b.recordedPhysicalIds, b.recorded, b.completeResources ?? []) } : {},
|
|
16571
16714
|
...b.recordedSourceFingerprints ? { recordedSourceFingerprints: sortedSourceFingerprints(b.recordedSourceFingerprints, b.recorded) } : {},
|
|
16572
|
-
...b.observedDefaults && b.observedDefaults.length > 0 ? { observedDefaults: [...b.observedDefaults].sort((a, c) => (a.logicalId < c.logicalId ? -1 : a.logicalId > c.logicalId ? 1 : 0) || (a.path < c.path ? -1 : a.path > c.path ? 1 : 0)) } : {}
|
|
16715
|
+
...b.observedDefaults && b.observedDefaults.length > 0 ? { observedDefaults: [...b.observedDefaults].sort((a, c) => (a.logicalId < c.logicalId ? -1 : a.logicalId > c.logicalId ? 1 : 0) || (a.path < c.path ? -1 : a.path > c.path ? 1 : 0)) } : {},
|
|
16716
|
+
...b.enumeratedParents && b.enumeratedParents.length > 0 ? { enumeratedParents: [...b.enumeratedParents].sort((a, c) => (a.logicalId < c.logicalId ? -1 : a.logicalId > c.logicalId ? 1 : 0) || (a.resourceType < c.resourceType ? -1 : a.resourceType > c.resourceType ? 1 : 0)) } : {}
|
|
16573
16717
|
};
|
|
16574
16718
|
await writeFile(p, JSON.stringify(stable, null, 2) + "\n", "utf8");
|
|
16575
16719
|
return p;
|
|
@@ -16641,12 +16785,37 @@ async function writeBaseline(stackName, region, accountId, findings, rawTemplate
|
|
|
16641
16785
|
completeResources,
|
|
16642
16786
|
...buildRecordedPhysicalIds(recorded, completeResources, opts.physicalIdByLogical, opts.previous),
|
|
16643
16787
|
...buildRecordedSourceFingerprints(recorded, opts.declaredByLogical, opts.previous),
|
|
16644
|
-
...buildObservedDefaults(findings, opts.previous)
|
|
16788
|
+
...buildObservedDefaults(findings, opts.previous),
|
|
16789
|
+
...buildEnumeratedParents(opts.enumeratedParents, findings, recorded)
|
|
16645
16790
|
}),
|
|
16646
16791
|
count: recorded.length
|
|
16647
16792
|
};
|
|
16648
16793
|
}
|
|
16649
16794
|
/**
|
|
16795
|
+
* #1737: finalize the `enumeratedParents` marker for this record run. Seeds from the
|
|
16796
|
+
* gather's scan-complete parents, then DEMOTES any parent that has an `added` finding
|
|
16797
|
+
* this run whose entry is NOT in the final recorded set — the user (selective picker /
|
|
16798
|
+
* drop flow) or the run itself (a model-read-failed child buildRecorded skips) declined
|
|
16799
|
+
* to endorse a PRESENT child, so marking the parent complete would let that child later
|
|
16800
|
+
* false-confirm as "appeared since record" (the #790 completeness-demotion mirror).
|
|
16801
|
+
* Deterministic sort; `{}` (spread to nothing) when empty so old-shaped baselines stay
|
|
16802
|
+
* byte-identical. Pure + exported for unit tests.
|
|
16803
|
+
*/
|
|
16804
|
+
function buildEnumeratedParents(candidates, findings, recorded) {
|
|
16805
|
+
if (!candidates || candidates.length === 0) return {};
|
|
16806
|
+
const recordedKeys = new Set(recorded.map(recordedKey));
|
|
16807
|
+
const blocked = /* @__PURE__ */ new Set();
|
|
16808
|
+
for (const f of findings) {
|
|
16809
|
+
if (f.tier !== "added" || f.parentLogicalId === void 0) continue;
|
|
16810
|
+
if (!recordedKeys.has(recordedKey({
|
|
16811
|
+
logicalId: f.logicalId,
|
|
16812
|
+
path: f.path
|
|
16813
|
+
}))) blocked.add(`${f.parentLogicalId}\0${f.parentResourceType}`);
|
|
16814
|
+
}
|
|
16815
|
+
const out = candidates.filter((p) => !blocked.has(`${p.logicalId}\0${p.resourceType}`)).sort((a, c) => (a.logicalId < c.logicalId ? -1 : a.logicalId > c.logicalId ? 1 : 0) || (a.resourceType < c.resourceType ? -1 : a.resourceType > c.resourceType ? 1 : 0));
|
|
16816
|
+
return out.length > 0 ? { enumeratedParents: out } : {};
|
|
16817
|
+
}
|
|
16818
|
+
/**
|
|
16650
16819
|
* #1637: build the `observedDefaults` entries for this record run. Seeds from THIS run's
|
|
16651
16820
|
* `atDefault` findings on the curated OBSERVED_DEFAULT_TRACKED_PATHS, then carries forward
|
|
16652
16821
|
* the previous baseline's entries for resources this run could NOT observe (a `skipped`
|
|
@@ -17138,6 +17307,7 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
17138
17307
|
} : f);
|
|
17139
17308
|
const recorded = baseline.recorded;
|
|
17140
17309
|
const complete = new Set(baseline.completeResources ?? []);
|
|
17310
|
+
const enumeratedParents = baseline.enumeratedParents ?? [];
|
|
17141
17311
|
const kept = [];
|
|
17142
17312
|
const currentLogicalIds = opts.allLogicalIds === void 0 ? void 0 : Array.isArray(opts.allLogicalIds) ? new Set(opts.allLogicalIds) : opts.allLogicalIds;
|
|
17143
17313
|
const recordedPhysIds = baseline.recordedPhysicalIds ?? {};
|
|
@@ -17181,6 +17351,13 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
17181
17351
|
});
|
|
17182
17352
|
continue;
|
|
17183
17353
|
}
|
|
17354
|
+
if (f.parentLogicalId !== void 0 && enumeratedParents.some((ep) => ep.logicalId === f.parentLogicalId && ep.resourceType === f.parentResourceType)) {
|
|
17355
|
+
kept.push({
|
|
17356
|
+
...f,
|
|
17357
|
+
note: f.note ? `${f.note}; appeared since record` : "appeared since record"
|
|
17358
|
+
});
|
|
17359
|
+
continue;
|
|
17360
|
+
}
|
|
17184
17361
|
kept.push({
|
|
17185
17362
|
...f,
|
|
17186
17363
|
unrecorded: true
|
|
@@ -20203,6 +20380,8 @@ const REVERT_SET_DEFAULT_PATHS = new Set([
|
|
|
20203
20380
|
"AWS::EC2::CapacityReservation\0InstanceMatchCriteria",
|
|
20204
20381
|
"AWS::EC2::CapacityReservation\0EndDateType",
|
|
20205
20382
|
"AWS::CodeDeploy::DeploymentGroup\0DeploymentConfigName",
|
|
20383
|
+
"AWS::CodeDeploy::DeploymentGroup\0DeploymentStyle",
|
|
20384
|
+
"AWS::CodeDeploy::DeploymentGroup\0LoadBalancerInfo",
|
|
20206
20385
|
"AWS::DLM::LifecyclePolicy\0RetainInterval",
|
|
20207
20386
|
"AWS::DLM::LifecyclePolicy\0CreateInterval",
|
|
20208
20387
|
"AWS::IAM::Role\0MaxSessionDuration",
|
|
@@ -20309,7 +20488,8 @@ const REVERT_SET_DEFAULT_VALUES = {
|
|
|
20309
20488
|
"AWS::DocDB::DBCluster\0DeletionProtection": false,
|
|
20310
20489
|
"AWS::EKS::Cluster\0ResourcesVpcConfig.EndpointPrivateAccess": false,
|
|
20311
20490
|
"AWS::ApiGatewayV2::IntegrationResponse\0TemplateSelectionExpression": "",
|
|
20312
|
-
"AWS::ApiGatewayV2::RouteResponse\0ModelSelectionExpression": ""
|
|
20491
|
+
"AWS::ApiGatewayV2::RouteResponse\0ModelSelectionExpression": "",
|
|
20492
|
+
"AWS::CodeDeploy::DeploymentGroup\0LoadBalancerInfo": { TargetGroupInfoList: [] }
|
|
20313
20493
|
};
|
|
20314
20494
|
/**
|
|
20315
20495
|
* A nested undeclared value (a live sub-key inside a declared object, R96/R98) — a dotted
|
|
@@ -20478,6 +20658,15 @@ function buildRevertPlan(findings, baseline, opts = {}) {
|
|
|
20478
20658
|
});
|
|
20479
20659
|
continue;
|
|
20480
20660
|
}
|
|
20661
|
+
if (f.ecsBlueGreenGoverned) {
|
|
20662
|
+
notRevertable.push({
|
|
20663
|
+
displayId,
|
|
20664
|
+
resourceType: f.resourceType,
|
|
20665
|
+
path: f.path,
|
|
20666
|
+
reason: "managed by an ECS blue/green deployment — revert would fight the deployment controller; update the service's AdvancedConfiguration, or record/ignore to accept"
|
|
20667
|
+
});
|
|
20668
|
+
continue;
|
|
20669
|
+
}
|
|
20481
20670
|
if (f.tier === "deleted") {
|
|
20482
20671
|
notRevertable.push({
|
|
20483
20672
|
displayId,
|
|
@@ -21587,6 +21776,7 @@ async function recordStack(p) {
|
|
|
21587
21776
|
allLogicalIds: desired.resources.map((r) => r.logicalId),
|
|
21588
21777
|
previous: existing,
|
|
21589
21778
|
physicalIdByLogical: physicalIdsByLogical(desired.resources),
|
|
21779
|
+
enumeratedParents: desired.childScanComplete,
|
|
21590
21780
|
declaredByLogical: declaredKeysByLogical(desired.resources)
|
|
21591
21781
|
});
|
|
21592
21782
|
if (!p.json) console.log(style.ok(recordOutcomeMessage(stackName, path, count, refreshedOnly, !!existing)));
|