cdk-real-drift 0.25.4 → 0.25.5

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
@@ -1982,7 +1982,8 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1982
1982
  } } : {},
1983
1983
  ...cvpnVpcKey !== void 0 && cvpnVpcMap !== void 0 ? { siblingClientVpnEndpointVpcs: { [cvpnVpcKey]: cvpnVpcMap[cvpnVpcKey] ?? null } } : {},
1984
1984
  ...cfCdKey !== void 0 && cfCdMap !== void 0 ? { siblingCloudFrontCdPolicyIds: { [cfCdKey]: cfCdMap[cfCdKey] ?? null } } : {},
1985
- ...rdsSrcKey !== void 0 && rdsSrcMap !== void 0 && rdsSrcMap[rdsSrcKey] ? { siblingRdsSourceModels: { [rdsSrcKey]: rdsSrcMap[rdsSrcKey] } } : {}
1985
+ ...rdsSrcKey !== void 0 && rdsSrcMap !== void 0 && rdsSrcMap[rdsSrcKey] ? { siblingRdsSourceModels: { [rdsSrcKey]: rdsSrcMap[rdsSrcKey] } } : {},
1986
+ ...resource.resourceType === "AWS::ElasticBeanstalk::Environment" && opts.ebSgNamesById && Object.keys(opts.ebSgNamesById).length > 0 ? { ebSgNamesById: opts.ebSgNamesById } : {}
1986
1987
  },
1987
1988
  expected: findings
1988
1989
  }, opts.accountId);
@@ -3632,15 +3633,20 @@ const EB_OPTION_VALUE_INDEPENDENT = new Set([
3632
3633
  "aws:elasticbeanstalk:healthreporting:system|ConfigDocument",
3633
3634
  "aws:elasticbeanstalk:healthreporting:system|EnhancedHealthAuthEnabled"
3634
3635
  ]);
3635
- function isEbGeneratedGroup(el) {
3636
- const name = el.trim();
3636
+ function isEbGeneratedGroup(el, sgNamesById) {
3637
+ let name = el.trim();
3637
3638
  if (name === "") return false;
3639
+ if (/^sg-[0-9a-f]+$/i.test(name)) {
3640
+ const resolved = sgNamesById?.[name];
3641
+ if (resolved === void 0) return false;
3642
+ name = resolved;
3643
+ }
3638
3644
  if (/^awseb-e-/i.test(name)) return true;
3639
3645
  return /AWSEB(LoadBalancer)?SecurityGroup/.test(name);
3640
3646
  }
3641
- function isAllEbGeneratedGroups(value) {
3647
+ function isAllEbGeneratedGroups(value, sgNamesById) {
3642
3648
  if (typeof value !== "string" || value === "") return false;
3643
- return value.split(",").every((el) => isEbGeneratedGroup(el));
3649
+ return value.split(",").every((el) => isEbGeneratedGroup(el, sgNamesById));
3644
3650
  }
3645
3651
  const EB_INSTANCE_TYPES_DEFAULT_BY_ARCH = {
3646
3652
  x86_64: new Set(["t3.micro", "t3.small"]),
@@ -3654,10 +3660,10 @@ function ebInstanceTypesDefaultSet(supportedArchitectures) {
3654
3660
  const arch = typeof supportedArchitectures === "string" && supportedArchitectures.trim() !== "" ? supportedArchitectures.split(",")[0]?.trim() : "x86_64";
3655
3661
  return arch === void 0 ? EB_INSTANCE_TYPES_DEFAULT_BY_ARCH.x86_64 : EB_INSTANCE_TYPES_DEFAULT_BY_ARCH[arch];
3656
3662
  }
3657
- function ebOptionSettingTier(namespace, optionName, value, envType, siblingOption) {
3663
+ function ebOptionSettingTier(namespace, optionName, value, envType, siblingOption, sgNamesById) {
3658
3664
  if (value == null || value === "") return "atDefault";
3659
3665
  const key = `${String(namespace)}|${String(optionName)}`;
3660
- if (key === "aws:autoscaling:launchconfiguration|SecurityGroups" || key === "aws:elb:loadbalancer|SecurityGroups") return isAllEbGeneratedGroups(value) ? "atDefault" : "undeclared";
3666
+ if (key === "aws:autoscaling:launchconfiguration|SecurityGroups" || key === "aws:elb:loadbalancer|SecurityGroups") return isAllEbGeneratedGroups(value, sgNamesById) ? "atDefault" : "undeclared";
3661
3667
  if (key === "aws:autoscaling:launchconfiguration|InstanceType") {
3662
3668
  const instanceTypes = siblingOption?.("aws:ec2:instances", "InstanceTypes");
3663
3669
  const first = typeof instanceTypes === "string" ? instanceTypes.split(",")[0]?.trim() : void 0;
@@ -4075,12 +4081,14 @@ const CASE_INSENSITIVE_PATHS = {
4075
4081
  "DBParameterGroupName",
4076
4082
  "DBSubnetGroupName",
4077
4083
  "OptionGroupName",
4078
- "DBClusterIdentifier"
4084
+ "DBClusterIdentifier",
4085
+ "Engine"
4079
4086
  ]),
4080
4087
  "AWS::RDS::DBCluster": new Set([
4081
4088
  "DBClusterIdentifier",
4082
4089
  "DBClusterParameterGroupName",
4083
- "DBSubnetGroupName"
4090
+ "DBSubnetGroupName",
4091
+ "Engine"
4084
4092
  ]),
4085
4093
  "AWS::ElastiCache::SubnetGroup": new Set(["CacheSubnetGroupName"]),
4086
4094
  "AWS::ElastiCache::ReplicationGroup": new Set([
@@ -4114,9 +4122,9 @@ const CASE_INSENSITIVE_PATHS = {
4114
4122
  "DBSubnetGroupName"
4115
4123
  ]),
4116
4124
  "AWS::Neptune::DBSubnetGroup": new Set(["DBSubnetGroupName"]),
4117
- "AWS::RDS::DBParameterGroup": new Set(["DBParameterGroupName"]),
4118
- "AWS::RDS::DBClusterParameterGroup": new Set(["DBClusterParameterGroupName"]),
4119
- "AWS::RDS::OptionGroup": new Set(["OptionGroupName"]),
4125
+ "AWS::RDS::DBParameterGroup": new Set(["DBParameterGroupName", "Family"]),
4126
+ "AWS::RDS::DBClusterParameterGroup": new Set(["DBClusterParameterGroupName", "Family"]),
4127
+ "AWS::RDS::OptionGroup": new Set(["OptionGroupName", "EngineName"]),
4120
4128
  "AWS::RDS::DBSubnetGroup": new Set(["DBSubnetGroupName"]),
4121
4129
  "AWS::Neptune::DBParameterGroup": new Set(["Name"]),
4122
4130
  "AWS::Neptune::DBClusterParameterGroup": new Set(["Name"]),
@@ -5557,6 +5565,30 @@ function logsDeliveryDerivedRetention(logGroupClass) {
5557
5565
  function rdsReplicaDerivedBackupRetention(sourceDbInstanceIdentifier) {
5558
5566
  return sourceDbInstanceIdentifier !== void 0 ? 0 : void 0;
5559
5567
  }
5568
+ function ecsDaemonDerivedMaximumPercent(schedulingStrategy) {
5569
+ return schedulingStrategy === "DAEMON" ? 100 : void 0;
5570
+ }
5571
+ function ecsDaemonDerivedMinimumHealthyPercent(schedulingStrategy) {
5572
+ return schedulingStrategy === "DAEMON" ? 0 : void 0;
5573
+ }
5574
+ function ecsDaemonDerivedDeploymentConfiguration(schedulingStrategy) {
5575
+ if (schedulingStrategy !== "DAEMON") return void 0;
5576
+ return {
5577
+ BakeTimeInMinutes: 0,
5578
+ Strategy: "ROLLING",
5579
+ DeploymentCircuitBreaker: {
5580
+ ThresholdConfiguration: {
5581
+ Type: "BOUNDED_PERCENT",
5582
+ Value: 50
5583
+ },
5584
+ Enable: false,
5585
+ ResetOnHealthyTask: true,
5586
+ Rollback: false
5587
+ },
5588
+ MaximumPercent: 100,
5589
+ MinimumHealthyPercent: 0
5590
+ };
5591
+ }
5560
5592
 
5561
5593
  //#endregion
5562
5594
  //#region src/read/kms-aliases.ts
@@ -6449,12 +6481,12 @@ const IAM_ATTACHMENT_SUBSET = { "AWS::IAM::ManagedPolicy": new Set([
6449
6481
  "Users",
6450
6482
  "Groups"
6451
6483
  ]) };
6452
- const ebOptionSettingsEntryTier = (entry, liveArray) => {
6484
+ const ebOptionSettingsEntryTier = (entry, liveArray, ebSgNamesById) => {
6453
6485
  const arr = Array.isArray(liveArray) ? liveArray : [];
6454
6486
  const envEntry = arr.find((e) => e && e.OptionName === "EnvironmentType");
6455
6487
  const envType = typeof envEntry?.Value === "string" ? envEntry.Value : "LoadBalanced";
6456
6488
  const siblingOption = (ns, opt) => arr.find((e) => e && e.Namespace === ns && e.OptionName === opt)?.Value;
6457
- return ebOptionSettingTier(entry.Namespace, entry.OptionName, entry.Value, envType, siblingOption);
6489
+ return ebOptionSettingTier(entry.Namespace, entry.OptionName, entry.Value, envType, siblingOption, ebSgNamesById);
6458
6490
  };
6459
6491
  const ebOptionSettingsSubsetSpec = {
6460
6492
  re: /(^|\.)OptionSettings$/,
@@ -7362,6 +7394,26 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7362
7394
  StorageType: storageDefault
7363
7395
  };
7364
7396
  }
7397
+ if (resourceType === "AWS::ECS::Service") {
7398
+ const daemonMax = ecsDaemonDerivedMaximumPercent(declared["SchedulingStrategy"]);
7399
+ const daemonMin = ecsDaemonDerivedMinimumHealthyPercent(declared["SchedulingStrategy"]);
7400
+ if (daemonMax !== void 0 && daemonMin !== void 0) {
7401
+ const dcPin = knownDef["DeploymentConfiguration"];
7402
+ if (dcPin && typeof dcPin === "object") knownDef = {
7403
+ ...knownDef,
7404
+ DeploymentConfiguration: {
7405
+ ...dcPin,
7406
+ MaximumPercent: daemonMax,
7407
+ MinimumHealthyPercent: daemonMin
7408
+ }
7409
+ };
7410
+ knownDefPaths = {
7411
+ ...knownDefPaths,
7412
+ "DeploymentConfiguration.MaximumPercent": daemonMax,
7413
+ "DeploymentConfiguration.MinimumHealthyPercent": daemonMin
7414
+ };
7415
+ }
7416
+ }
7365
7417
  if (resourceType === "AWS::CE::AnomalySubscription") {
7366
7418
  const threshold = declared["Threshold"];
7367
7419
  if (typeof threshold === "number" && Number.isFinite(threshold)) {
@@ -7921,7 +7973,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7921
7973
  const r = lo;
7922
7974
  const key = ckSubsetSpec.keyFields.map((f) => String(r[f])).join("|");
7923
7975
  findings.push({
7924
- tier: ckSubsetSpec.entryTier?.(r, d.awsValue) ?? "undeclared",
7976
+ tier: ckSubsetSpec.entryTier?.(r, d.awsValue, opts.ebSgNamesById) ?? "undeclared",
7925
7977
  logicalId,
7926
7978
  resourceType,
7927
7979
  path: `${d.path}[${key}]`,
@@ -8148,7 +8200,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
8148
8200
  continue;
8149
8201
  }
8150
8202
  }
8151
- if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in schema.defaultPaths && matchesKnownDefault(v, schema.defaultPaths[k]) || k in knownDef && matchesKnownDefault(v, knownDef[k]) || KNOWN_DEFAULT_ONE_OF[resourceType]?.[k]?.some((d) => matchesKnownDefault(v, d)) || VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS[resourceType]?.has(k) && !isTrivialEmpty(v) && !(k in knownDef) || clbDefaultSslPoliciesAtDefault(resourceType, k, v) || vpnTunnelOptionsAtDefault(resourceType, k, v)) {
8203
+ if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in schema.defaultPaths && matchesKnownDefault(v, schema.defaultPaths[k]) || k in knownDef && matchesKnownDefault(v, knownDef[k]) || KNOWN_DEFAULT_ONE_OF[resourceType]?.[k]?.some((d) => matchesKnownDefault(v, d)) || VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS[resourceType]?.has(k) && !isTrivialEmpty(v) && !(k in knownDef) || resourceType === "AWS::ECS::Service" && k === "DesiredCount" && declared["SchedulingStrategy"] === "DAEMON" || clbDefaultSslPoliciesAtDefault(resourceType, k, v) || vpnTunnelOptionsAtDefault(resourceType, k, v)) {
8152
8204
  findings.push({
8153
8205
  tier: "atDefault",
8154
8206
  logicalId,
@@ -11410,27 +11462,41 @@ function route53ZoneRefMatches(declared, hostedZoneId, zoneApex) {
11410
11462
  if (hzName === UNRESOLVED || hasUnresolved(hzName)) return true;
11411
11463
  return typeof hzName === "string" && zoneApex !== void 0 && canonRoute53Name(hzName) === canonRoute53Name(zoneApex);
11412
11464
  }
11413
- async function enumerateRoute53HostedZoneChildren(ctx) {
11414
- const { parent, desired, region } = ctx;
11415
- const hostedZoneId = parent.physicalId;
11416
- if (!hostedZoneId) return [];
11417
- const zoneApex = typeof parent.declared.Name === "string" ? parent.declared.Name : void 0;
11465
+ function collectDeclaredRoute53Records(resources, hostedZoneId, zoneApex) {
11418
11466
  const declaredRecords = [];
11419
- for (const r of desired.resources) {
11420
- if (r.resourceType !== "AWS::Route53::RecordSet") continue;
11421
- if (!route53ZoneRefMatches(r.declared, hostedZoneId, zoneApex)) continue;
11422
- const name = typeof r.declared.Name === "string" ? r.declared.Name : void 0;
11423
- const type = typeof r.declared.Type === "string" ? r.declared.Type : void 0;
11467
+ const pushDeclared = (rec) => {
11468
+ const name = typeof rec.Name === "string" ? rec.Name : void 0;
11469
+ const type = typeof rec.Type === "string" ? rec.Type : void 0;
11424
11470
  if (name && type) declaredRecords.push({
11425
11471
  name,
11426
11472
  type,
11427
- setIdentifier: typeof r.declared.SetIdentifier === "string" ? r.declared.SetIdentifier : void 0
11473
+ setIdentifier: typeof rec.SetIdentifier === "string" ? rec.SetIdentifier : void 0
11428
11474
  });
11475
+ };
11476
+ for (const r of resources) if (r.resourceType === "AWS::Route53::RecordSet") {
11477
+ if (!route53ZoneRefMatches(r.declared, hostedZoneId, zoneApex)) continue;
11478
+ pushDeclared(r.declared);
11479
+ } else if (r.resourceType === "AWS::Route53::RecordSetGroup") {
11480
+ const groupMatches = route53ZoneRefMatches(r.declared, hostedZoneId, zoneApex);
11481
+ const sets = Array.isArray(r.declared.RecordSets) ? r.declared.RecordSets : [];
11482
+ for (const rs of sets) {
11483
+ if (!rs || typeof rs !== "object") continue;
11484
+ const rec = rs;
11485
+ if (!groupMatches && !route53ZoneRefMatches(rec, hostedZoneId, zoneApex)) continue;
11486
+ pushDeclared(rec);
11487
+ }
11429
11488
  }
11489
+ return declaredRecords;
11490
+ }
11491
+ async function enumerateRoute53HostedZoneChildren(ctx) {
11492
+ const { parent, desired, region } = ctx;
11493
+ const hostedZoneId = parent.physicalId;
11494
+ if (!hostedZoneId) return [];
11495
+ const zoneApex = typeof parent.declared.Name === "string" ? parent.declared.Name : void 0;
11430
11496
  return diffRoute53HostedZoneChildren({
11431
11497
  hostedZoneId,
11432
11498
  zoneApex,
11433
- declaredRecords,
11499
+ declaredRecords: collectDeclaredRoute53Records(desired.resources, hostedZoneId, zoneApex),
11434
11500
  liveRecords: (await pageResourceRecordSets(new Route53Client({
11435
11501
  region,
11436
11502
  ...READ_RETRY
@@ -15056,6 +15122,52 @@ const DEFAULT_SG_LIST_TYPES = new Set([
15056
15122
  "AWS::EC2::VPCEndpoint"
15057
15123
  ]);
15058
15124
  const DEFAULT_SUBNET_LIST_TYPES = new Set(["AWS::RedshiftServerless::Workgroup"]);
15125
+ const EB_SG_OPTION_KEYS = new Set(["aws:elb:loadbalancer|SecurityGroups", "aws:autoscaling:launchconfiguration|SecurityGroups"]);
15126
+ function collectEbSecurityGroupIds(resources, liveById) {
15127
+ const ids = /* @__PURE__ */ new Set();
15128
+ for (const r of resources) {
15129
+ if (r.resourceType !== "AWS::ElasticBeanstalk::Environment") continue;
15130
+ const live = liveById.get(r.logicalId);
15131
+ if (!live) continue;
15132
+ const settings = live.OptionSettings;
15133
+ if (!Array.isArray(settings)) continue;
15134
+ for (const s of settings) {
15135
+ if (!s || typeof s !== "object") continue;
15136
+ const e = s;
15137
+ if (!EB_SG_OPTION_KEYS.has(`${String(e.Namespace)}|${String(e.OptionName)}`)) continue;
15138
+ if (typeof e.Value !== "string") continue;
15139
+ for (const el of e.Value.split(",")) {
15140
+ const t = el.trim();
15141
+ if (/^sg-[0-9a-f]+$/i.test(t)) ids.add(t);
15142
+ }
15143
+ }
15144
+ }
15145
+ return [...ids];
15146
+ }
15147
+ async function fetchSgNamesByIds(region, ids) {
15148
+ try {
15149
+ const c = new EC2Client({
15150
+ region,
15151
+ ...READ_RETRY
15152
+ });
15153
+ const out = {};
15154
+ let token;
15155
+ do {
15156
+ const r = await c.send(new DescribeSecurityGroupsCommand({
15157
+ Filters: [{
15158
+ Name: "group-id",
15159
+ Values: [...ids]
15160
+ }],
15161
+ NextToken: token
15162
+ }));
15163
+ for (const g of r.SecurityGroups ?? []) if (g.GroupId && g.GroupName) out[g.GroupId] = g.GroupName;
15164
+ token = r.NextToken;
15165
+ } while (token);
15166
+ return out;
15167
+ } catch {
15168
+ return;
15169
+ }
15170
+ }
15059
15171
  const defaultSgIdsCache = /* @__PURE__ */ new Map();
15060
15172
  async function fetchDefaultSgIds(region) {
15061
15173
  const cached = defaultSgIdsCache.get(region);
@@ -16208,7 +16320,11 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
16208
16320
  siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
16209
16321
  siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
16210
16322
  siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, liveModelMap(reads)),
16211
- rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
16323
+ rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region),
16324
+ ebSgNamesById: await (async () => {
16325
+ const ids = collectEbSecurityGroupIds(desired.resources, liveModelMap(reads));
16326
+ return ids.length > 0 ? fetchSgNamesByIds(region, ids) : void 0;
16327
+ })()
16212
16328
  };
16213
16329
  const corpusDir = process.env[CORPUS_DIR_ENV];
16214
16330
  for (const r of desired.resources) {
@@ -16288,7 +16404,12 @@ async function regatherTouched(gathered, touched, region) {
16288
16404
  siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
16289
16405
  siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
16290
16406
  siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
16291
- rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
16407
+ rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region),
16408
+ ebSgNamesById: await (async () => {
16409
+ const merged = new Map([...gathered.liveByLogical, ...liveModelMap(reads)]);
16410
+ const ids = collectEbSecurityGroupIds(desired.resources, merged);
16411
+ return ids.length > 0 ? fetchSgNamesByIds(region, ids) : void 0;
16412
+ })()
16292
16413
  };
16293
16414
  const fresh = [];
16294
16415
  for (const r of targets) fresh.push(...await classifyRead(cfn, r, reads.get(r.logicalId), schemas, classifyOpts));
@@ -19996,6 +20117,16 @@ const writeBudget = async (ctx, ops) => {
19996
20117
  ...budget,
19997
20118
  BudgetLimit: void 0
19998
20119
  } : budget;
20120
+ const stringifySpend = (s) => {
20121
+ if (!s || typeof s !== "object") return void 0;
20122
+ const sp = s;
20123
+ return {
20124
+ ...sp,
20125
+ ...sp.Amount !== void 0 && { Amount: String(sp.Amount) }
20126
+ };
20127
+ };
20128
+ if (newBudget.BudgetLimit) newBudget.BudgetLimit = stringifySpend(newBudget.BudgetLimit);
20129
+ if (newBudget.PlannedBudgetLimits) newBudget.PlannedBudgetLimits = Object.fromEntries(Object.entries(newBudget.PlannedBudgetLimits).map(([k, v]) => [k, stringifySpend(v)]));
19999
20130
  await new BudgetsClient({
20000
20131
  region: ctx.region,
20001
20132
  ...CLIENT_TIMEOUTS
@@ -20519,6 +20650,15 @@ function isNestedUndeclared(f) {
20519
20650
  function isUnrevertableNested(f) {
20520
20651
  return isNestedUndeclared(f) && f.path.includes("[");
20521
20652
  }
20653
+ function elbAttributeBagElementOf(f) {
20654
+ const bag = ELB_ATTRIBUTE_BAGS[f.resourceType];
20655
+ if (!bag || !f.path.startsWith(`${bag}[`) || !f.path.endsWith("]")) return void 0;
20656
+ const key = f.path.slice(bag.length + 1, -1);
20657
+ return key ? {
20658
+ prop: bag,
20659
+ key
20660
+ } : void 0;
20661
+ }
20522
20662
  function isManagedPolicyAttachmentMember(f) {
20523
20663
  return f.tier === "undeclared" && f.resourceType === "AWS::IAM::ManagedPolicy" && /^(Roles|Users|Groups)\[.+\]$/.test(f.path);
20524
20664
  }
@@ -20727,7 +20867,9 @@ function buildRevertPlan(findings, baseline, opts = {}) {
20727
20867
  });
20728
20868
  continue;
20729
20869
  }
20730
- if (isUnrevertableNested(f) && !isManagedPolicyAttachmentMember(f) && !isNestedSdkWritable(f)) {
20870
+ const bagElement = elbAttributeBagElementOf(f);
20871
+ const bagElementRevertible = bagElement !== void 0 && !SDK_WRITERS[f.resourceType] && SDK_PROP_WRITERS[f.resourceType]?.[bagElement.prop] !== void 0 && (f.desired !== void 0 || recorded.some((a) => a.logicalId === f.logicalId && a.path === f.path) || elbAttributeDefaultsFor(f.resourceType, opts.declaredForLogical?.(f.logicalId) ?? {}, {})[bagElement.key] !== void 0);
20872
+ if (isUnrevertableNested(f) && !isManagedPolicyAttachmentMember(f) && !isNestedSdkWritable(f) && !bagElementRevertible) {
20731
20873
  notRevertable.push({
20732
20874
  displayId,
20733
20875
  resourceType: f.resourceType,
@@ -20820,7 +20962,7 @@ function buildRevertPlan(findings, baseline, opts = {}) {
20820
20962
  });
20821
20963
  continue;
20822
20964
  }
20823
- const propScoped = !SDK_WRITERS[f.resourceType] && SDK_PROP_WRITERS[f.resourceType]?.[f.path] !== void 0;
20965
+ const propScoped = !SDK_WRITERS[f.resourceType] && SDK_PROP_WRITERS[f.resourceType]?.[bagElement?.prop ?? f.path] !== void 0;
20824
20966
  const nestedScoped = !SDK_WRITERS[f.resourceType] && !propScoped && isNestedSdkWritable(f);
20825
20967
  if (JSON_STRING_PROPS[f.resourceType]?.has(f.path) && !propScoped && !SDK_WRITERS[f.resourceType]) {
20826
20968
  notRevertable.push({
@@ -20872,7 +21014,7 @@ function buildRevertPlan(findings, baseline, opts = {}) {
20872
21014
  }
20873
21015
  const declaredModel = opts.declaredForLogical?.(f.logicalId);
20874
21016
  const op = revertOp(toRevert, recorded, opts.identity, declaredModel);
20875
- const key = `${f.logicalId} ${kind}${propScoped ? ` ${f.path}` : ""}`;
21017
+ const key = `${f.logicalId} ${kind}${propScoped ? ` ${bagElement?.prop ?? f.path}` : ""}`;
20876
21018
  const item = itemsByLogical.get(key) ?? {
20877
21019
  logicalId: f.logicalId,
20878
21020
  displayId,
@@ -20892,6 +21034,7 @@ function buildRevertPlan(findings, baseline, opts = {}) {
20892
21034
  item.ops.push({
20893
21035
  op: "remove",
20894
21036
  path: siblingPointer,
21037
+ contract: true,
20895
21038
  human: `${sibling} -> remove (incompatible with the restored default)`
20896
21039
  });
20897
21040
  }
@@ -20943,11 +21086,17 @@ function derivedRevertDefaultFor(resourceType, path, declared) {
20943
21086
  if (path === "HealthCheckPort") return elbTargetGroupDerivedHealthCheckPort(declared["Protocol"]);
20944
21087
  }
20945
21088
  if (resourceType === "AWS::RDS::DBInstance" && path === "BackupRetentionPeriod") return rdsReplicaDerivedBackupRetention(declared["SourceDBInstanceIdentifier"]);
21089
+ if (resourceType === "AWS::ECS::Service") {
21090
+ if (path === "DeploymentConfiguration") return ecsDaemonDerivedDeploymentConfiguration(declared["SchedulingStrategy"]);
21091
+ if (path === "DeploymentConfiguration.MaximumPercent") return ecsDaemonDerivedMaximumPercent(declared["SchedulingStrategy"]);
21092
+ if (path === "DeploymentConfiguration.MinimumHealthyPercent") return ecsDaemonDerivedMinimumHealthyPercent(declared["SchedulingStrategy"]);
21093
+ }
20946
21094
  if (resourceType === "AWS::Logs::LogGroup" && path === "RetentionInDays") return logsDeliveryDerivedRetention(declared["LogGroupClass"]);
20947
21095
  }
20948
21096
  const REVERT_COMPANION_REMOVES = {
20949
21097
  "AWS::ElasticLoadBalancingV2::TargetGroup\0HealthCheckProtocol": (value) => value === "TCP" ? ["Matcher", "HealthCheckPath"] : [],
20950
- "AWS::EC2::Volume\0VolumeType": (value) => value === "gp2" || value === "standard" || value === "st1" || value === "sc1" ? ["Iops", "Throughput"] : value === "io1" || value === "io2" ? ["Throughput"] : []
21098
+ "AWS::EC2::Volume\0VolumeType": (value) => value === "gp2" || value === "standard" || value === "st1" || value === "sc1" ? ["Iops", "Throughput"] : value === "io1" || value === "io2" ? ["Throughput"] : [],
21099
+ "AWS::ECS::Service\0DeploymentConfiguration": () => ["DesiredCount"]
20951
21100
  };
20952
21101
  function revertOp(f, recorded, identity, declaredModel) {
20953
21102
  const pointer = toPointer(f.path);
@@ -20960,6 +21109,19 @@ function revertOp(f, recorded, identity, declaredModel) {
20960
21109
  human: `${f.path}${f.attributeKey ? `[${f.attributeKey}]` : ""} -> deployed-template value`
20961
21110
  };
20962
21111
  const wasRecorded = recorded.find((a) => a.logicalId === f.logicalId && a.path === f.path);
21112
+ const bagEl = elbAttributeBagElementOf(f);
21113
+ if (bagEl) {
21114
+ const baselineValue = f.desired !== void 0 ? f.desired : wasRecorded?.value;
21115
+ const value = baselineValue !== void 0 ? baselineValue : elbAttributeDefaultsFor(f.resourceType, declaredModel ?? {}, {})[bagEl.key];
21116
+ if (value !== void 0) return {
21117
+ op: "add",
21118
+ path: toPointer(bagEl.prop),
21119
+ value,
21120
+ prior: f.actual,
21121
+ attributeKey: bagEl.key,
21122
+ human: `${bagEl.prop}[${bagEl.key}] -> ${baselineValue !== void 0 ? "baseline value" : "AWS default (undeclared, not in baseline)"}`
21123
+ };
21124
+ }
20963
21125
  if (f.actual === void 0 && f.desired !== void 0) return {
20964
21126
  op: "add",
20965
21127
  path: pointer,
@@ -22247,6 +22409,7 @@ async function revertStack(p) {
22247
22409
  if (item.kind === "delete" || !okIds.has(item.logicalId)) continue;
22248
22410
  for (const op of item.ops) {
22249
22411
  if (op.op !== "remove" && op.op !== "add") continue;
22412
+ if (op.contract) continue;
22250
22413
  const dotted = op.path.replace(/^\//, "").replace(/\//g, ".");
22251
22414
  const key = `${item.logicalId}\0${dotted}`;
22252
22415
  if (!preActual.has(key)) continue;