cdk-real-drift 0.2.15 → 0.2.17
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 +96 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1609,6 +1609,11 @@ const KNOWN_DEFAULTS = {
|
|
|
1609
1609
|
}
|
|
1610
1610
|
]
|
|
1611
1611
|
},
|
|
1612
|
+
"AWS::KinesisVideo::Stream": { DataRetentionInHours: 0 },
|
|
1613
|
+
"AWS::KinesisVideo::SignalingChannel": {
|
|
1614
|
+
Type: "SINGLE_MASTER",
|
|
1615
|
+
MessageTtlSeconds: 60
|
|
1616
|
+
},
|
|
1612
1617
|
"AWS::CodeStarNotifications::NotificationRule": { Status: "ENABLED" },
|
|
1613
1618
|
"AWS::Rbin::Rule": { Status: "available" },
|
|
1614
1619
|
"AWS::RolesAnywhere::TrustAnchor": { NotificationSettings: [{
|
|
@@ -1920,7 +1925,10 @@ const GENERATED_PATHS = {
|
|
|
1920
1925
|
"AWS::XRay::SamplingRule": ["SamplingRule.RuleARN"]
|
|
1921
1926
|
};
|
|
1922
1927
|
const CONTEXT_DEFAULTS = { "AWS::EC2::VPCEndpointService": { SupportedRegions: "regionList" } };
|
|
1923
|
-
const CONTEXT_ARN_DEFAULTS = {
|
|
1928
|
+
const CONTEXT_ARN_DEFAULTS = {
|
|
1929
|
+
"AWS::ResourceExplorer2::View": { Scope: "arn:{partition}:iam::{accountId}:root" },
|
|
1930
|
+
"AWS::KinesisVideo::Stream": { KmsKeyId: "arn:{partition}:kms:{region}:{accountId}:alias/aws/kinesisvideo" }
|
|
1931
|
+
};
|
|
1924
1932
|
const ENGINE_DEFAULTS = {
|
|
1925
1933
|
"AWS::RDS::DBInstance": {
|
|
1926
1934
|
StorageType: (e) => e.startsWith("aurora") ? "aurora" : void 0,
|
|
@@ -1972,7 +1980,8 @@ const GENERATED_TOPLEVEL_PATHS = {
|
|
|
1972
1980
|
};
|
|
1973
1981
|
const DESCEND_UNDECLARED_OBJECT_PATHS = {
|
|
1974
1982
|
"AWS::EKS::Cluster": new Set(["KubernetesNetworkConfig"]),
|
|
1975
|
-
"AWS::Athena::WorkGroup": new Set(["WorkGroupConfiguration"])
|
|
1983
|
+
"AWS::Athena::WorkGroup": new Set(["WorkGroupConfiguration"]),
|
|
1984
|
+
"AWS::KinesisVideo::Stream": new Set(["StreamStorageConfiguration"])
|
|
1976
1985
|
};
|
|
1977
1986
|
const GENERATED_LOGICALID_PREFIX_PATHS = {
|
|
1978
1987
|
"AWS::Cognito::UserPoolClient": new Set(["ClientName"]),
|
|
@@ -3671,6 +3680,25 @@ function alignCompositeKeySubset(declared, live, spec) {
|
|
|
3671
3680
|
});
|
|
3672
3681
|
}
|
|
3673
3682
|
const isNestedObject = (x) => x !== null && typeof x === "object" && !Array.isArray(x);
|
|
3683
|
+
const DDB_TABLE_TYPES = new Set(["AWS::DynamoDB::Table", "AWS::DynamoDB::GlobalTable"]);
|
|
3684
|
+
function warmThroughputDefault(provisionedThroughput) {
|
|
3685
|
+
if (isNestedObject(provisionedThroughput) && typeof provisionedThroughput.ReadCapacityUnits === "number" && typeof provisionedThroughput.WriteCapacityUnits === "number") return {
|
|
3686
|
+
ReadUnitsPerSecond: provisionedThroughput.ReadCapacityUnits,
|
|
3687
|
+
WriteUnitsPerSecond: provisionedThroughput.WriteCapacityUnits
|
|
3688
|
+
};
|
|
3689
|
+
return {
|
|
3690
|
+
ReadUnitsPerSecond: 12e3,
|
|
3691
|
+
WriteUnitsPerSecond: 4e3
|
|
3692
|
+
};
|
|
3693
|
+
}
|
|
3694
|
+
function dynamoGsiWarmThroughputAtDefault(resourceType, path, value, live) {
|
|
3695
|
+
if (!DDB_TABLE_TYPES.has(resourceType)) return false;
|
|
3696
|
+
const m = /^GlobalSecondaryIndexes\[(.*)\]\.WarmThroughput$/.exec(path);
|
|
3697
|
+
if (m === null || !Array.isArray(live.GlobalSecondaryIndexes)) return false;
|
|
3698
|
+
const gsi = live.GlobalSecondaryIndexes.find((g) => isNestedObject(g) && g.IndexName === m[1]);
|
|
3699
|
+
if (!isNestedObject(gsi)) return false;
|
|
3700
|
+
return deepEqual(value, warmThroughputDefault(gsi.ProvisionedThroughput));
|
|
3701
|
+
}
|
|
3674
3702
|
const CFN_RANDOM_SUFFIX = /-[0-9A-Za-z]{12,}$/;
|
|
3675
3703
|
function stripInjectedJsonStringDefaults(declared, live, defaults) {
|
|
3676
3704
|
const stripObject = (d, l) => {
|
|
@@ -3885,7 +3913,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
3885
3913
|
const emitNested = (path, value) => {
|
|
3886
3914
|
if (isAllAwsTags(value) || isTrivialEmpty(value)) return;
|
|
3887
3915
|
const schemaPath = path.replace(/\[[^\]]*\]/g, ".*");
|
|
3888
|
-
const tier = schemaPath in schema.defaultPaths && matchesKnownDefault(value, schema.defaultPaths[schemaPath]) || schemaPath in knownDefPaths && matchesKnownDefault(value, knownDefPaths[schemaPath]) ? "atDefault" : generatedPaths.includes(schemaPath) && isPhysicalIdSegment(value, physicalId) || generatedNestedPaths?.has(schemaPath) ? "generated" : "undeclared";
|
|
3916
|
+
const tier = schemaPath in schema.defaultPaths && matchesKnownDefault(value, schema.defaultPaths[schemaPath]) || schemaPath in knownDefPaths && matchesKnownDefault(value, knownDefPaths[schemaPath]) || dynamoGsiWarmThroughputAtDefault(resourceType, path, value, live) ? "atDefault" : generatedPaths.includes(schemaPath) && isPhysicalIdSegment(value, physicalId) || generatedNestedPaths?.has(schemaPath) ? "generated" : "undeclared";
|
|
3889
3917
|
const freeFormKey = tier === "undeclared" && underFreeFormMap(schemaPath);
|
|
3890
3918
|
findings.push({
|
|
3891
3919
|
tier,
|
|
@@ -4258,6 +4286,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4258
4286
|
continue;
|
|
4259
4287
|
}
|
|
4260
4288
|
}
|
|
4289
|
+
if (DDB_TABLE_TYPES.has(resourceType) && k === "WarmThroughput" && deepEqual(v, warmThroughputDefault(live.ProvisionedThroughput))) {
|
|
4290
|
+
findings.push({
|
|
4291
|
+
tier: "atDefault",
|
|
4292
|
+
logicalId,
|
|
4293
|
+
resourceType,
|
|
4294
|
+
path: k,
|
|
4295
|
+
actual: v
|
|
4296
|
+
});
|
|
4297
|
+
continue;
|
|
4298
|
+
}
|
|
4261
4299
|
const namePattern = DEFAULT_MANAGED_NAME_PATHS[resourceType]?.[k];
|
|
4262
4300
|
if (namePattern !== void 0 && typeof v === "string" && namePattern.test(v)) {
|
|
4263
4301
|
findings.push({
|
|
@@ -4332,6 +4370,35 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4332
4370
|
collectNestedUndeclared({}, v, k, emitNested, NESTED_ARRAY_IDENTITY[resourceType]);
|
|
4333
4371
|
continue;
|
|
4334
4372
|
}
|
|
4373
|
+
const subsetSpecU = IDENTITY_KEYED_SUBSET_ARRAYS[resourceType]?.[k];
|
|
4374
|
+
const defaultElsU = IDENTITY_KEYED_DEFAULT_ELEMENTS[resourceType]?.[k];
|
|
4375
|
+
if (subsetSpecU !== void 0 && defaultElsU !== void 0 && Array.isArray(v)) {
|
|
4376
|
+
const { idField, normalizeId } = subsetSpecU;
|
|
4377
|
+
for (const lEl of v) {
|
|
4378
|
+
if (!isNestedObject(lEl) || typeof lEl[idField] !== "string") {
|
|
4379
|
+
findings.push({
|
|
4380
|
+
tier: "undeclared",
|
|
4381
|
+
logicalId,
|
|
4382
|
+
resourceType,
|
|
4383
|
+
path: k,
|
|
4384
|
+
actual: lEl
|
|
4385
|
+
});
|
|
4386
|
+
continue;
|
|
4387
|
+
}
|
|
4388
|
+
const raw = lEl[idField];
|
|
4389
|
+
const id = normalizeId ? normalizeId(raw) : raw;
|
|
4390
|
+
const atDefault = id in defaultElsU && deepEqual(lEl, defaultElsU[id]);
|
|
4391
|
+
findings.push({
|
|
4392
|
+
tier: atDefault ? "atDefault" : "undeclared",
|
|
4393
|
+
logicalId,
|
|
4394
|
+
resourceType,
|
|
4395
|
+
path: `${k}[${id}]`,
|
|
4396
|
+
actual: lEl,
|
|
4397
|
+
nested: true
|
|
4398
|
+
});
|
|
4399
|
+
}
|
|
4400
|
+
continue;
|
|
4401
|
+
}
|
|
4335
4402
|
findings.push({
|
|
4336
4403
|
tier: "undeclared",
|
|
4337
4404
|
logicalId,
|
|
@@ -11270,6 +11337,7 @@ async function revertStack(p) {
|
|
|
11270
11337
|
const cc = new CloudControlClient({ region });
|
|
11271
11338
|
const byLogical = new Map(gathered.desired.resources.map((res) => [res.logicalId, res]));
|
|
11272
11339
|
const failedDeleteIds = /* @__PURE__ */ new Set();
|
|
11340
|
+
const failedUpdateIds = /* @__PURE__ */ new Set();
|
|
11273
11341
|
const applied = [];
|
|
11274
11342
|
const clock = waitNow ?? Date.now;
|
|
11275
11343
|
const buildRetryOpts = (displayId) => ({
|
|
@@ -11334,6 +11402,7 @@ async function revertStack(p) {
|
|
|
11334
11402
|
...r.hint !== void 0 && { hint: r.hint }
|
|
11335
11403
|
});
|
|
11336
11404
|
if (!r.ok) worst = Math.max(worst, 2);
|
|
11405
|
+
if (!r.ok && item.kind !== "delete") failedUpdateIds.add(item.logicalId);
|
|
11337
11406
|
}
|
|
11338
11407
|
for (const s of summarizeRevertResults(applied)) if (s.ok) console.log(style.ok(` reverted: ${s.displayId}`));
|
|
11339
11408
|
else {
|
|
@@ -11358,14 +11427,35 @@ async function revertStack(p) {
|
|
|
11358
11427
|
}
|
|
11359
11428
|
const remainingDrift = post.filter(isDrift);
|
|
11360
11429
|
const remaining = remainingDrift.length;
|
|
11430
|
+
const okIds = new Set(applied.filter((a) => a.ok).map((a) => a.logicalId));
|
|
11431
|
+
const preActual = /* @__PURE__ */ new Map();
|
|
11432
|
+
for (const f of gathered.findings) preActual.set(`${f.logicalId}\0${f.path}`, f.actual);
|
|
11433
|
+
const noOpRemovals = [];
|
|
11434
|
+
for (const item of plan.items) {
|
|
11435
|
+
if (item.kind === "delete" || !okIds.has(item.logicalId)) continue;
|
|
11436
|
+
for (const op of item.ops) {
|
|
11437
|
+
if (op.op !== "remove") continue;
|
|
11438
|
+
const dotted = op.path.replace(/^\//, "").replace(/\//g, ".");
|
|
11439
|
+
const key = `${item.logicalId}\0${dotted}`;
|
|
11440
|
+
if (!preActual.has(key)) continue;
|
|
11441
|
+
const pre = preActual.get(key);
|
|
11442
|
+
if (post.some((f) => f.logicalId === item.logicalId && f.path === dotted && !isDrift(f) && deepEqual(f.actual, pre))) noOpRemovals.push({
|
|
11443
|
+
displayId: item.displayId,
|
|
11444
|
+
path: dotted
|
|
11445
|
+
});
|
|
11446
|
+
}
|
|
11447
|
+
}
|
|
11361
11448
|
const unverified = post.filter((f) => touched.has(f.logicalId) && f.tier === "skipped").length;
|
|
11362
|
-
const unconfirmed = unverified + failedDeleteIds.size;
|
|
11363
|
-
|
|
11449
|
+
const unconfirmed = unverified + failedDeleteIds.size + failedUpdateIds.size;
|
|
11450
|
+
const converged = remaining === 0 && unconfirmed === 0 && noOpRemovals.length === 0;
|
|
11451
|
+
for (const n of noOpRemovals) console.log(style.fail(` NOT reverted: ${n.displayId}.${n.path} — removal was a no-op (the provider ignored the omitted property; it needs an explicit default write — see #597 / REVERT_SET_DEFAULT_PATHS)`));
|
|
11452
|
+
const notConverged = unconfirmed + noOpRemovals.length;
|
|
11453
|
+
console.log(converged ? style.clean(`${stackName}: CLEAN after revert.`) : remaining > 0 ? style.drift(`${stackName}: ${remaining} drift(s) remain.`) : style.drift(`${stackName}: revert applied, but ${notConverged} value(s) could not be confirmed converged (see above).`));
|
|
11364
11454
|
const unrecordedLeft = unrecordedCount(post);
|
|
11365
11455
|
if (unrecordedLeft > 0) console.log(style.note(` (${unrecordedLeft} unrecorded value(s) still await a baseline — run cdkrd record)`));
|
|
11366
11456
|
if (unverified > 0) console.log(style.note(` (${unverified} resource(s) could not be re-read to verify — re-run cdkrd check to confirm)`));
|
|
11367
11457
|
for (const line of formatSurvivingDrift(remainingDrift, stackName)) console.log(line);
|
|
11368
|
-
if (remaining > 0 || unverified > 0) worst = Math.max(worst, 1);
|
|
11458
|
+
if (remaining > 0 || unverified > 0 || noOpRemovals.length > 0) worst = Math.max(worst, 1);
|
|
11369
11459
|
return {
|
|
11370
11460
|
exit: worst,
|
|
11371
11461
|
aborted: false
|