cdk-real-drift 0.19.2 → 0.20.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 +128 -11
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2266,6 +2266,25 @@ const KNOWN_DEFAULTS = {
|
|
|
2266
2266
|
"AWS::EKS::Addon": { NamespaceConfig: { Namespace: "kube-system" } },
|
|
2267
2267
|
"AWS::WAFv2::WebACL": { OnSourceDDoSProtectionConfig: { ALBLowReputationMode: "ACTIVE_UNDER_DDOS" } },
|
|
2268
2268
|
"AWS::VpcLattice::ServiceNetwork": { SharingConfig: { enabled: true } },
|
|
2269
|
+
"AWS::VpcLattice::AccessLogSubscription": { ServiceNetworkLogType: "SERVICE" },
|
|
2270
|
+
"AWS::VpcLattice::ResourceGateway": {
|
|
2271
|
+
IpAddressType: "IPV4",
|
|
2272
|
+
Ipv4AddressesPerEni: 16,
|
|
2273
|
+
ResourceConfigDnsResolution: "PUBLIC"
|
|
2274
|
+
},
|
|
2275
|
+
"AWS::VpcLattice::ResourceConfiguration": { AllowAssociationToSharableServiceNetwork: true },
|
|
2276
|
+
"AWS::SES::DedicatedIpPool": { ScalingMode: "STANDARD" },
|
|
2277
|
+
"AWS::CodeDeploy::Application": { ComputePlatform: "Server" },
|
|
2278
|
+
"AWS::EC2::TransitGatewayAttachment": { Options: {
|
|
2279
|
+
DnsSupport: "disable",
|
|
2280
|
+
SecurityGroupReferencingSupport: "enable",
|
|
2281
|
+
Ipv6Support: "disable",
|
|
2282
|
+
ApplianceModeSupport: "disable"
|
|
2283
|
+
} },
|
|
2284
|
+
"AWS::Backup::RestoreTestingPlan": {
|
|
2285
|
+
StartWindowHours: 24,
|
|
2286
|
+
ScheduleExpressionTimezone: "Etc/UTC"
|
|
2287
|
+
},
|
|
2269
2288
|
"AWS::AmazonMQ::Broker": {
|
|
2270
2289
|
AuthenticationStrategy: "SIMPLE",
|
|
2271
2290
|
EncryptionOptions: { UseAwsOwnedKey: true },
|
|
@@ -2970,6 +2989,7 @@ const KNOWN_DEFAULT_ONE_OF_PATHS = {
|
|
|
2970
2989
|
"AWS::OpenSearchService::Domain": { "EBSOptions.VolumeType": ["gp3", "gp2"] }
|
|
2971
2990
|
};
|
|
2972
2991
|
const KNOWN_DEFAULT_PATHS = {
|
|
2992
|
+
"AWS::Backup::RestoreTestingPlan": { "RecoveryPointSelection.SelectionWindowDays": 30 },
|
|
2973
2993
|
"AWS::IoT::TopicRule": { "TopicRulePayload.AwsIotSqlVersion": "2015-10-08" },
|
|
2974
2994
|
"AWS::SageMaker::DataQualityJobDefinition": {
|
|
2975
2995
|
"DataQualityJobInput.BatchTransformInput.S3DataDistributionType": "FullyReplicated",
|
|
@@ -3564,6 +3584,7 @@ function ebOptionSettingTier(namespace, optionName, value, envType, siblingOptio
|
|
|
3564
3584
|
const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
3565
3585
|
"AWS::ApiGateway::ApiKey": new Set(["Value"]),
|
|
3566
3586
|
"AWS::Backup::BackupVault": new Set(["EncryptionKeyArn"]),
|
|
3587
|
+
"AWS::Lambda::Version": new Set(["Description"]),
|
|
3567
3588
|
"AWS::Batch::JobQueue": new Set(["JobQueueType"]),
|
|
3568
3589
|
"AWS::ECS::Service": new Set(["AvailabilityZoneRebalancing", "PlatformVersion"]),
|
|
3569
3590
|
"AWS::KinesisAnalyticsV2::Application": new Set(["ApplicationMaintenanceConfiguration"]),
|
|
@@ -5878,6 +5899,7 @@ const notRestored = (...restoreSourceKeys) => ({ declared }) => restoreSourceKey
|
|
|
5878
5899
|
const MEANINGFUL_WHEN_OFF = {
|
|
5879
5900
|
"AWS::KMS::Key": { Enabled: () => true },
|
|
5880
5901
|
"AWS::ServiceCatalog::TagOption": { Active: () => true },
|
|
5902
|
+
"AWS::VpcLattice::ResourceConfiguration": { AllowAssociationToSharableServiceNetwork: () => true },
|
|
5881
5903
|
"AWS::SQS::Queue": { SqsManagedSseEnabled: ({ declared, live }) => declared["KmsMasterKeyId"] === void 0 && live["KmsMasterKeyId"] === void 0 },
|
|
5882
5904
|
"AWS::EC2::VPC": { EnableDnsSupport: () => true },
|
|
5883
5905
|
"AWS::EC2::Instance": { SourceDestCheck: () => true },
|
|
@@ -5965,7 +5987,8 @@ const DEFAULT_SG_LIST_PATHS = {
|
|
|
5965
5987
|
"AWS::EC2::Instance": "SecurityGroupIds",
|
|
5966
5988
|
"AWS::DAX::Cluster": "SecurityGroupIds",
|
|
5967
5989
|
"AWS::DMS::ReplicationInstance": "VpcSecurityGroupIds",
|
|
5968
|
-
"AWS::EC2::ClientVpnEndpoint": "SecurityGroupIds"
|
|
5990
|
+
"AWS::EC2::ClientVpnEndpoint": "SecurityGroupIds",
|
|
5991
|
+
"AWS::VpcLattice::ResourceGateway": "SecurityGroupIds"
|
|
5969
5992
|
};
|
|
5970
5993
|
/** #1269 fold decision for an UNDECLARED default-SUBNET list (RedshiftServerless Workgroup
|
|
5971
5994
|
* SubnetIds). Unlike the SG gate (which folds only a SINGLE default SG), a workgroup placed into
|
|
@@ -6371,21 +6394,23 @@ function stripInjectedJsonStringDefaults(declared, live, defaults) {
|
|
|
6371
6394
|
function isCfnGeneratedName(value, constructPath, physicalId, logicalId) {
|
|
6372
6395
|
if (typeof value !== "string" || value === physicalId) return false;
|
|
6373
6396
|
if (logicalId && value === logicalId) return true;
|
|
6397
|
+
const valueLc = value.toLowerCase();
|
|
6374
6398
|
if (logicalId && CFN_RANDOM_SUFFIX.test(value)) {
|
|
6375
|
-
const base =
|
|
6376
|
-
|
|
6399
|
+
const base = valueLc.replace(CFN_RANDOM_SUFFIX, "");
|
|
6400
|
+
const logicalLc = logicalId.toLowerCase();
|
|
6401
|
+
if (base.length > logicalLc.length && base.endsWith(`-${logicalLc}`)) return true;
|
|
6377
6402
|
}
|
|
6378
6403
|
if (!constructPath) return false;
|
|
6379
|
-
const stackName = constructPath.split("/")[0];
|
|
6404
|
+
const stackName = constructPath.split("/")[0]?.toLowerCase();
|
|
6380
6405
|
if (!stackName || !CFN_RANDOM_SUFFIX.test(value)) return false;
|
|
6381
|
-
if (
|
|
6406
|
+
if (valueLc.startsWith(`${stackName}-`)) return true;
|
|
6382
6407
|
if (!logicalId) return false;
|
|
6383
|
-
const base =
|
|
6408
|
+
const base = valueLc.replace(CFN_RANDOM_SUFFIX, "");
|
|
6384
6409
|
const sep = base.lastIndexOf("-");
|
|
6385
6410
|
if (sep <= 0) return false;
|
|
6386
6411
|
const stackPart = base.slice(0, sep);
|
|
6387
6412
|
const logicalPart = base.slice(sep + 1);
|
|
6388
|
-
return stackPart.length < stackName.length && stackName.startsWith(stackPart) && logicalPart.length > 0 && logicalId.startsWith(logicalPart);
|
|
6413
|
+
return stackPart.length < stackName.length && stackName.startsWith(stackPart) && logicalPart.length > 0 && logicalId.toLowerCase().startsWith(logicalPart);
|
|
6389
6414
|
}
|
|
6390
6415
|
function isSelfEchoTrivialEmpty(v, physicalId) {
|
|
6391
6416
|
if (physicalId === void 0 || v === null || typeof v !== "object" || Array.isArray(v)) return false;
|
|
@@ -14133,7 +14158,8 @@ const DEFAULT_SG_LIST_TYPES = new Set([
|
|
|
14133
14158
|
"AWS::EC2::Instance",
|
|
14134
14159
|
"AWS::DAX::Cluster",
|
|
14135
14160
|
"AWS::DMS::ReplicationInstance",
|
|
14136
|
-
"AWS::EC2::ClientVpnEndpoint"
|
|
14161
|
+
"AWS::EC2::ClientVpnEndpoint",
|
|
14162
|
+
"AWS::VpcLattice::ResourceGateway"
|
|
14137
14163
|
]);
|
|
14138
14164
|
const DEFAULT_SUBNET_LIST_TYPES = new Set(["AWS::RedshiftServerless::Workgroup"]);
|
|
14139
14165
|
const defaultSgIdsCache = /* @__PURE__ */ new Map();
|
|
@@ -15377,6 +15403,7 @@ function redactedHashOf(sentinelOrCanonical) {
|
|
|
15377
15403
|
|
|
15378
15404
|
//#endregion
|
|
15379
15405
|
//#region src/baseline/baseline-file.ts
|
|
15406
|
+
const OBSERVED_DEFAULT_TRACKED_PATHS = { "AWS::S3::Bucket": ["PublicAccessBlockConfiguration"] };
|
|
15380
15407
|
const KNOWN_BASELINE_KEYS = new Set([
|
|
15381
15408
|
"schemaVersion",
|
|
15382
15409
|
"stackName",
|
|
@@ -15387,7 +15414,8 @@ const KNOWN_BASELINE_KEYS = new Set([
|
|
|
15387
15414
|
"recorded",
|
|
15388
15415
|
"completeResources",
|
|
15389
15416
|
"recordedPhysicalIds",
|
|
15390
|
-
"recordedSourceFingerprints"
|
|
15417
|
+
"recordedSourceFingerprints",
|
|
15418
|
+
"observedDefaults"
|
|
15391
15419
|
]);
|
|
15392
15420
|
const KNOWN_RECORDED_ENTRY_KEYS = new Set([
|
|
15393
15421
|
"logicalId",
|
|
@@ -15448,6 +15476,7 @@ async function loadBaseline(stackName, accountId, region) {
|
|
|
15448
15476
|
validateCompleteResources(parsed.completeResources, path);
|
|
15449
15477
|
validateRecordedPhysicalIds(parsed.recordedPhysicalIds, path);
|
|
15450
15478
|
validateRecordedSourceFingerprints(parsed.recordedSourceFingerprints, path);
|
|
15479
|
+
validateObservedDefaults(parsed.observedDefaults, path);
|
|
15451
15480
|
return parsed;
|
|
15452
15481
|
}
|
|
15453
15482
|
/**
|
|
@@ -15538,6 +15567,29 @@ function validateRecordedSourceFingerprints(value, path) {
|
|
|
15538
15567
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${at} must be an object mapping "<logicalId>::<path>" to a fingerprint`);
|
|
15539
15568
|
for (const [key, v] of Object.entries(value)) if (typeof v !== "string") throw new Error(`${at}: "${key}" must map to a string`);
|
|
15540
15569
|
}
|
|
15570
|
+
/**
|
|
15571
|
+
* #1637: validate `observedDefaults` (optional). When present it must be an array of
|
|
15572
|
+
* { logicalId, resourceType, path } string triples with no unknown keys — the same
|
|
15573
|
+
* loud-vs-silent principle as validateRecordedEntry (a typo'd key silently disables the
|
|
15574
|
+
* vanish detection this field exists to drive). No `value` field by design: the restore
|
|
15575
|
+
* value is the KNOWN_DEFAULTS pin.
|
|
15576
|
+
*/
|
|
15577
|
+
function validateObservedDefaults(value, path) {
|
|
15578
|
+
if (value === void 0) return;
|
|
15579
|
+
const at = `baseline file ${path}: \`observedDefaults\``;
|
|
15580
|
+
if (!Array.isArray(value)) throw new Error(`${at} must be an array of { logicalId, resourceType, path }`);
|
|
15581
|
+
value.forEach((entry, i) => {
|
|
15582
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) throw new Error(`${at}[${i}] must be an object { logicalId, resourceType, path }`);
|
|
15583
|
+
const obj = entry;
|
|
15584
|
+
for (const k of [
|
|
15585
|
+
"logicalId",
|
|
15586
|
+
"resourceType",
|
|
15587
|
+
"path"
|
|
15588
|
+
]) if (typeof obj[k] !== "string") throw new Error(`${at}[${i}]: "${k}" is required and must be a string`);
|
|
15589
|
+
const unknown = Object.keys(obj).filter((k) => k !== "logicalId" && k !== "resourceType" && k !== "path");
|
|
15590
|
+
if (unknown.length > 0) throw new Error(`${at}[${i}]: unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} — known keys: "logicalId", "resourceType", "path"`);
|
|
15591
|
+
});
|
|
15592
|
+
}
|
|
15541
15593
|
/** Deterministic order for `recorded` entries: lexicographic by (logicalId, path).
|
|
15542
15594
|
* The single point where order is imposed — read/compare logic is order-independent,
|
|
15543
15595
|
* so this only affects the bytes on disk. Without it the entries inherit findings
|
|
@@ -15574,7 +15626,8 @@ async function writeBaselineFile(b) {
|
|
|
15574
15626
|
recorded: sortRecorded(b.recorded),
|
|
15575
15627
|
...b.completeResources ? { completeResources: [...b.completeResources].sort() } : {},
|
|
15576
15628
|
...b.recordedPhysicalIds ? { recordedPhysicalIds: sortedPhysicalIds(b.recordedPhysicalIds, b.recorded, b.completeResources ?? []) } : {},
|
|
15577
|
-
...b.recordedSourceFingerprints ? { recordedSourceFingerprints: sortedSourceFingerprints(b.recordedSourceFingerprints, b.recorded) } : {}
|
|
15629
|
+
...b.recordedSourceFingerprints ? { recordedSourceFingerprints: sortedSourceFingerprints(b.recordedSourceFingerprints, b.recorded) } : {},
|
|
15630
|
+
...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)) } : {}
|
|
15578
15631
|
};
|
|
15579
15632
|
await writeFile(p, JSON.stringify(stable, null, 2) + "\n", "utf8");
|
|
15580
15633
|
return p;
|
|
@@ -15645,12 +15698,47 @@ async function writeBaseline(stackName, region, accountId, findings, rawTemplate
|
|
|
15645
15698
|
recorded,
|
|
15646
15699
|
completeResources,
|
|
15647
15700
|
...buildRecordedPhysicalIds(recorded, completeResources, opts.physicalIdByLogical, opts.previous),
|
|
15648
|
-
...buildRecordedSourceFingerprints(recorded, opts.declaredByLogical, opts.previous)
|
|
15701
|
+
...buildRecordedSourceFingerprints(recorded, opts.declaredByLogical, opts.previous),
|
|
15702
|
+
...buildObservedDefaults(findings, opts.previous)
|
|
15649
15703
|
}),
|
|
15650
15704
|
count: recorded.length
|
|
15651
15705
|
};
|
|
15652
15706
|
}
|
|
15653
15707
|
/**
|
|
15708
|
+
* #1637: build the `observedDefaults` entries for this record run. Seeds from THIS run's
|
|
15709
|
+
* `atDefault` findings on the curated OBSERVED_DEFAULT_TRACKED_PATHS, then carries forward
|
|
15710
|
+
* the previous baseline's entries for resources this run could NOT observe (a `skipped`
|
|
15711
|
+
* finding — unread, symmetric with carryForwardUnreadable), so a transient read failure
|
|
15712
|
+
* never silently drops the watch. A resource READ this run whose tracked value is ABSENT
|
|
15713
|
+
* (already vanished, or a legacy resource that never had it) is deliberately NOT observed —
|
|
15714
|
+
* re-recording ACCEPTS the current state, exactly like the recorded-value flow. Returns
|
|
15715
|
+
* `{}` (spread to nothing) when empty so old-shaped baselines stay byte-identical.
|
|
15716
|
+
*/
|
|
15717
|
+
function buildObservedDefaults(findings, previous) {
|
|
15718
|
+
const out = [];
|
|
15719
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15720
|
+
for (const f of findings) {
|
|
15721
|
+
if (f.tier !== "atDefault") continue;
|
|
15722
|
+
if (!OBSERVED_DEFAULT_TRACKED_PATHS[f.resourceType]?.includes(f.path)) continue;
|
|
15723
|
+
const key = `${f.logicalId}\0${f.path}`;
|
|
15724
|
+
if (seen.has(key)) continue;
|
|
15725
|
+
seen.add(key);
|
|
15726
|
+
out.push({
|
|
15727
|
+
logicalId: f.logicalId,
|
|
15728
|
+
resourceType: f.resourceType,
|
|
15729
|
+
path: f.path
|
|
15730
|
+
});
|
|
15731
|
+
}
|
|
15732
|
+
const skipped = new Set(findings.filter((f) => f.tier === "skipped").map((f) => f.logicalId));
|
|
15733
|
+
for (const o of previous?.observedDefaults ?? []) {
|
|
15734
|
+
const key = `${o.logicalId}\0${o.path}`;
|
|
15735
|
+
if (seen.has(key) || !skipped.has(o.logicalId)) continue;
|
|
15736
|
+
seen.add(key);
|
|
15737
|
+
out.push(o);
|
|
15738
|
+
}
|
|
15739
|
+
return out.length > 0 ? { observedDefaults: out } : {};
|
|
15740
|
+
}
|
|
15741
|
+
/**
|
|
15654
15742
|
* #674/#792: build the `recordedPhysicalIds` map (logicalId -> physical id) for the
|
|
15655
15743
|
* resources being written. Covers every RECORDED logicalId PLUS every snapshot-`complete`
|
|
15656
15744
|
* resource — the latter so a resource recorded as complete but with ZERO undeclared
|
|
@@ -16268,6 +16356,31 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
16268
16356
|
note: "baseline value removed since record"
|
|
16269
16357
|
});
|
|
16270
16358
|
}
|
|
16359
|
+
const readGapLogical = new Set(findings.filter((f) => f.tier === "readGap").map((f) => f.logicalId));
|
|
16360
|
+
for (const o of baseline.observedDefaults ?? []) {
|
|
16361
|
+
if (currentPaths.has(`${o.logicalId}.${o.path}`)) continue;
|
|
16362
|
+
if (recorded.some((a) => a.logicalId === o.logicalId && a.path === o.path && a.resourceType === o.resourceType)) continue;
|
|
16363
|
+
if (skippedLogical.has(o.logicalId)) continue;
|
|
16364
|
+
if (deletedLogical.has(o.logicalId)) continue;
|
|
16365
|
+
if (!readParentLogical.has(o.logicalId)) continue;
|
|
16366
|
+
if (readGapLogical.has(o.logicalId)) continue;
|
|
16367
|
+
if (isTypeVoid(o)) continue;
|
|
16368
|
+
if (replacedLogical.has(o.logicalId)) continue;
|
|
16369
|
+
if (currentLogicalIds !== void 0 && !currentLogicalIds.has(o.logicalId)) continue;
|
|
16370
|
+
if (underDeclaredDrift(o.logicalId, o.path)) continue;
|
|
16371
|
+
if (declaredPathIsPromoted(opts.declaredByLogical?.get(o.logicalId), o.path)) continue;
|
|
16372
|
+
kept.push({
|
|
16373
|
+
tier: "undeclared",
|
|
16374
|
+
logicalId: o.logicalId,
|
|
16375
|
+
resourceType: o.resourceType,
|
|
16376
|
+
...opts.constructPathByLogical?.get(o.logicalId) !== void 0 && { constructPath: opts.constructPathByLogical.get(o.logicalId) },
|
|
16377
|
+
...opts.physicalIdByLogical?.get(o.logicalId) !== void 0 && { physicalId: opts.physicalIdByLogical.get(o.logicalId) },
|
|
16378
|
+
path: o.path,
|
|
16379
|
+
desired: KNOWN_DEFAULTS[o.resourceType]?.[o.path],
|
|
16380
|
+
actual: void 0,
|
|
16381
|
+
note: "observed default deleted since record (the whole value vanished from the live read)"
|
|
16382
|
+
});
|
|
16383
|
+
}
|
|
16271
16384
|
if (promotedStale.length > 0) opts.warn?.(formatPromotedStaleNote(promotedStale));
|
|
16272
16385
|
if (removedFromTemplate.length > 0) opts.warn?.(formatRemovedFromTemplateNote(removedFromTemplate));
|
|
16273
16386
|
if (replacedStale.length > 0) opts.warn?.(formatReplacedStaleNote(replacedStale));
|
|
@@ -19038,6 +19151,10 @@ const REVERT_SET_DEFAULT_PATHS = new Set([
|
|
|
19038
19151
|
"AWS::Cognito::UserPoolClient\0RefreshTokenValidity",
|
|
19039
19152
|
"AWS::RUM::AppMonitor\0CustomEvents",
|
|
19040
19153
|
"AWS::ServiceCatalog::TagOption\0Active",
|
|
19154
|
+
"AWS::VpcLattice::ResourceConfiguration\0AllowAssociationToSharableServiceNetwork",
|
|
19155
|
+
"AWS::Backup::RestoreTestingPlan\0StartWindowHours",
|
|
19156
|
+
"AWS::Backup::RestoreTestingPlan\0ScheduleExpressionTimezone",
|
|
19157
|
+
"AWS::EC2::TransitGatewayAttachment\0Options",
|
|
19041
19158
|
"AWS::Lambda::Url\0InvokeMode",
|
|
19042
19159
|
"AWS::RolesAnywhere::Profile\0DurationSeconds",
|
|
19043
19160
|
"AWS::RolesAnywhere::Profile\0AttributeMappings",
|