cdk-real-drift 0.12.66 → 0.12.68
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 +9 -0
- package/dist/cli.js +113 -13
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -496,6 +496,15 @@ from a **changed local `Default`** is applied only if you pass
|
|
|
496
496
|
`--parameters <key>=<value>` / `--no-previous-parameters` — `check` prints a
|
|
497
497
|
stderr note naming each such parameter and both values.
|
|
498
498
|
|
|
499
|
+
A second caveat on **server-side transforms** (SAM `AWS::Serverless-2016-10-31`,
|
|
500
|
+
`AWS::LanguageExtensions`, macros): CloudFormation expands these in the cloud at
|
|
501
|
+
deploy time, but `--pre-deploy` compares against your **local, unprocessed** synth
|
|
502
|
+
template. So under `--pre-deploy` every `AWS::Serverless::*` resource is `skipped`
|
|
503
|
+
(its declared props are not compared) and transform-generated resources are
|
|
504
|
+
invisible — `check` prints a per-stack stderr note when it sees a transformed
|
|
505
|
+
template. Normal `check` (against the deployed, already-**processed** template) has
|
|
506
|
+
no such gap and compares transformed stacks fully; prefer it for SAM/macro apps.
|
|
507
|
+
|
|
499
508
|
### Ignoring externally-managed properties
|
|
500
509
|
|
|
501
510
|
Some properties are _legitimately_ rewritten by another system, such as Application
|
package/dist/cli.js
CHANGED
|
@@ -1680,6 +1680,7 @@ function resolve$1(node, ctx, inCondition = false) {
|
|
|
1680
1680
|
break;
|
|
1681
1681
|
}
|
|
1682
1682
|
}
|
|
1683
|
+
if ("Fn::Transform" in obj) return UNRESOLVED;
|
|
1683
1684
|
const out = {};
|
|
1684
1685
|
for (const [kk, vv] of Object.entries(obj)) out[kk] = resolve$1(vv, ctx, inCondition);
|
|
1685
1686
|
return out;
|
|
@@ -3419,7 +3420,6 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3419
3420
|
"AWS::EC2::VPCEndpoint": new Set(["ServiceRegion", "DnsOptions"]),
|
|
3420
3421
|
"AWS::EC2::VPCPeeringConnection": new Set(["PeerRegion"]),
|
|
3421
3422
|
"AWS::EC2::VPCCidrBlock": new Set(["Ipv6CidrBlock", "Ipv6CidrBlockNetworkBorderGroup"]),
|
|
3422
|
-
"AWS::EC2::TransitGateway": new Set(["AssociationDefaultRouteTableId", "PropagationDefaultRouteTableId"]),
|
|
3423
3423
|
"AWS::Grafana::Workspace": new Set(["GrafanaVersion"]),
|
|
3424
3424
|
"AWS::Bedrock::AgentAlias": new Set(["RoutingConfiguration"]),
|
|
3425
3425
|
"AWS::AppSync::ApiKey": new Set(["Expires"]),
|
|
@@ -3427,11 +3427,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3427
3427
|
"AWS::StepFunctions::StateMachineVersion": new Set(["StateMachineRevisionId"]),
|
|
3428
3428
|
"AWS::StepFunctions::StateMachineAlias": new Set(["StateMachineArn"]),
|
|
3429
3429
|
"AWS::AutoScaling::ScheduledAction": new Set(["StartTime"]),
|
|
3430
|
-
"AWS::RedshiftServerless::Workgroup": new Set([
|
|
3431
|
-
"ConfigParameters",
|
|
3432
|
-
"SecurityGroupIds",
|
|
3433
|
-
"SubnetIds"
|
|
3434
|
-
]),
|
|
3430
|
+
"AWS::RedshiftServerless::Workgroup": new Set(["ConfigParameters"]),
|
|
3435
3431
|
"AWS::CloudFormation::Stack": new Set(["TemplateBody", "Capabilities"])
|
|
3436
3432
|
};
|
|
3437
3433
|
function isPhysicalIdSegment(value, physicalId) {
|
|
@@ -4593,6 +4589,21 @@ function changedDefaultParamInfo(template, stackParams, stackName) {
|
|
|
4593
4589
|
const more = diverged.length > shown.length ? `, …(+${diverged.length - shown.length} more)` : "";
|
|
4594
4590
|
return `warning: ${stackName}: ${diverged.length} local parameter(s) changed their Default vs the deployed value — the preview resolves them from the NEW local Default, but a plain \`cdk deploy\` KEEPS the deployed value (UsePreviousValue) unless \`--parameters <key>=<value>\` / \`--no-previous-parameters\` is passed: ${shown.join(", ")}${more}`;
|
|
4595
4591
|
}
|
|
4592
|
+
function transformStackWarning(template, stackName) {
|
|
4593
|
+
const rawTransform = template.Transform;
|
|
4594
|
+
const transforms = (Array.isArray(rawTransform) ? rawTransform : [rawTransform]).filter((t) => typeof t === "string" && t.length > 0).sort();
|
|
4595
|
+
const resources = template.Resources ?? {};
|
|
4596
|
+
const serverless = Object.entries(resources).filter(([, def]) => typeof def?.Type === "string" && def.Type.startsWith("AWS::Serverless::")).map(([logicalId]) => logicalId).sort();
|
|
4597
|
+
if (transforms.length === 0 && serverless.length === 0) return null;
|
|
4598
|
+
const parts = [];
|
|
4599
|
+
if (transforms.length > 0) parts.push(`Transform ${transforms.join(", ")}`);
|
|
4600
|
+
if (serverless.length > 0) {
|
|
4601
|
+
const shown = serverless.slice(0, 10);
|
|
4602
|
+
const more = serverless.length > shown.length ? `, …(+${serverless.length - shown.length} more)` : "";
|
|
4603
|
+
parts.push(`${serverless.length} AWS::Serverless::* resource(s): ${shown.join(", ")}${more}`);
|
|
4604
|
+
}
|
|
4605
|
+
return `warning: ${stackName}: --pre-deploy CANNOT process server-side transforms — CDK's local synth output is UNPROCESSED, so transform-expanded resources are NOT previewed (${parts.join("; ")}). Each AWS::Serverless::* resource is \`skipped\` (its declared props are not compared) and any transform-generated resource is invisible. Run \`check\` WITHOUT --pre-deploy (the deployed, already-processed template) for a full comparison of a transformed stack.`;
|
|
4606
|
+
}
|
|
4596
4607
|
function partitionForRegion(region) {
|
|
4597
4608
|
if (region.startsWith("us-gov-")) return {
|
|
4598
4609
|
partition: "aws-us-gov",
|
|
@@ -4767,7 +4778,10 @@ async function listStackResources(client, stackName) {
|
|
|
4767
4778
|
}
|
|
4768
4779
|
async function loadDesired(client, stackName, region, templateOverride, recoveryTemplate) {
|
|
4769
4780
|
const [tmplRes, stkRes, { physIds, typeOf: deployedTypeOf }] = await Promise.all([
|
|
4770
|
-
templateOverride ? Promise.resolve({ TemplateBody: void 0 }) : client.send(new GetTemplateCommand({
|
|
4781
|
+
templateOverride ? Promise.resolve({ TemplateBody: void 0 }) : client.send(new GetTemplateCommand({
|
|
4782
|
+
StackName: stackName,
|
|
4783
|
+
TemplateStage: "Processed"
|
|
4784
|
+
})),
|
|
4771
4785
|
client.send(new DescribeStacksCommand({ StackName: stackName })),
|
|
4772
4786
|
listStackResources(client, stackName)
|
|
4773
4787
|
]);
|
|
@@ -4796,6 +4810,8 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4796
4810
|
if (noValueInfo) console.error(noValueInfo);
|
|
4797
4811
|
const changedDefaultInfo = changedDefaultParamInfo(template, stackParams, stackName);
|
|
4798
4812
|
if (changedDefaultInfo) console.error(changedDefaultInfo);
|
|
4813
|
+
const transformInfo = transformStackWarning(template, stackName);
|
|
4814
|
+
if (transformInfo) console.error(transformInfo);
|
|
4799
4815
|
}
|
|
4800
4816
|
const templateResourcesForTypeCheck = template.Resources ?? {};
|
|
4801
4817
|
const typeChanged = new Set(typeChangedResources(templateResourcesForTypeCheck, deployedTypeOf));
|
|
@@ -5486,8 +5502,26 @@ const DEFAULT_SG_LIST_PATHS = {
|
|
|
5486
5502
|
"AWS::ElasticLoadBalancingV2::LoadBalancer": "SecurityGroups",
|
|
5487
5503
|
"AWS::EC2::NetworkInterface": "GroupSet",
|
|
5488
5504
|
"AWS::Neptune::DBCluster": "VpcSecurityGroupIds",
|
|
5489
|
-
"AWS::AmazonMQ::Broker": "SecurityGroups"
|
|
5505
|
+
"AWS::AmazonMQ::Broker": "SecurityGroups",
|
|
5506
|
+
"AWS::RedshiftServerless::Workgroup": "SecurityGroupIds"
|
|
5490
5507
|
};
|
|
5508
|
+
/** #1269 fold decision for an UNDECLARED default-SUBNET list (RedshiftServerless Workgroup
|
|
5509
|
+
* SubnetIds). Unlike the SG gate (which folds only a SINGLE default SG), a workgroup placed into
|
|
5510
|
+
* the default VPC reads back ALL of that VPC's subnets, so the clean-deploy list has MANY
|
|
5511
|
+
* elements — fold when EVERY element is a known default-VPC subnet; surface if ANY subnet is
|
|
5512
|
+
* outside the default VPC (an out-of-band re-placement, e.g. into a public subnet).
|
|
5513
|
+
* - `true` → FOLD (atDefault): every live subnet is a default-VPC subnet, OR the prefetch is
|
|
5514
|
+
* unavailable (fail OPEN — no ec2:DescribeSubnets / lookup failed / empty).
|
|
5515
|
+
* - `false` → SURFACE (undeclared): at least one live subnet is NOT a default-VPC subnet.
|
|
5516
|
+
* Pure; `defaultSubnetIds` is the resolved set of default-VPC subnet ids (undefined/empty when
|
|
5517
|
+
* unresolved). */
|
|
5518
|
+
function shouldFoldDefaultSubnetList(resourceType, key, liveValue, defaultSubnetIds) {
|
|
5519
|
+
if (DEFAULT_SUBNET_LIST_PATHS[resourceType] !== key) return false;
|
|
5520
|
+
if (!defaultSubnetIds || defaultSubnetIds.size === 0) return true;
|
|
5521
|
+
if (!Array.isArray(liveValue)) return true;
|
|
5522
|
+
return liveValue.every((s) => typeof s === "string" && defaultSubnetIds.has(s));
|
|
5523
|
+
}
|
|
5524
|
+
const DEFAULT_SUBNET_LIST_PATHS = { "AWS::RedshiftServerless::Workgroup": "SubnetIds" };
|
|
5491
5525
|
/** #889 fold decision for an UNDECLARED default-SG list (ALB SecurityGroups / ENI GroupSet).
|
|
5492
5526
|
* Returns whether the value-independent fold should still apply for this live value:
|
|
5493
5527
|
* - `true` → FOLD (atDefault): the live list is a single VPC-default SG id, OR the prefetch is
|
|
@@ -6916,6 +6950,29 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6916
6950
|
});
|
|
6917
6951
|
continue;
|
|
6918
6952
|
}
|
|
6953
|
+
if (DEFAULT_SUBNET_LIST_PATHS[resourceType] === k && !isTrivialEmpty(v)) {
|
|
6954
|
+
findings.push({
|
|
6955
|
+
tier: shouldFoldDefaultSubnetList(resourceType, k, v, opts.defaultSubnetIds) ? "atDefault" : "undeclared",
|
|
6956
|
+
logicalId,
|
|
6957
|
+
resourceType,
|
|
6958
|
+
path: k,
|
|
6959
|
+
actual: v
|
|
6960
|
+
});
|
|
6961
|
+
continue;
|
|
6962
|
+
}
|
|
6963
|
+
if (resourceType === "AWS::EC2::TransitGateway" && (k === "AssociationDefaultRouteTableId" || k === "PropagationDefaultRouteTableId") && typeof v === "string") {
|
|
6964
|
+
const assoc = live.AssociationDefaultRouteTableId;
|
|
6965
|
+
const prop = live.PropagationDefaultRouteTableId;
|
|
6966
|
+
const bothPresentAndDiffer = typeof assoc === "string" && typeof prop === "string" && assoc !== prop;
|
|
6967
|
+
findings.push({
|
|
6968
|
+
tier: bothPresentAndDiffer ? "undeclared" : "atDefault",
|
|
6969
|
+
logicalId,
|
|
6970
|
+
resourceType,
|
|
6971
|
+
path: k,
|
|
6972
|
+
actual: v
|
|
6973
|
+
});
|
|
6974
|
+
continue;
|
|
6975
|
+
}
|
|
6919
6976
|
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)) {
|
|
6920
6977
|
findings.push({
|
|
6921
6978
|
tier: "atDefault",
|
|
@@ -8625,7 +8682,8 @@ function diffLogGroupFilters(logGroupName, resourceType, declaredFilterNames, li
|
|
|
8625
8682
|
live: {
|
|
8626
8683
|
FilterName: f.name,
|
|
8627
8684
|
LogGroupName: logGroupName
|
|
8628
|
-
}
|
|
8685
|
+
},
|
|
8686
|
+
siblingLookupId: f.name
|
|
8629
8687
|
});
|
|
8630
8688
|
}
|
|
8631
8689
|
return added;
|
|
@@ -11793,6 +11851,7 @@ const EMPTY = {
|
|
|
11793
11851
|
readOnlyPaths: [],
|
|
11794
11852
|
writeOnlyPaths: [],
|
|
11795
11853
|
createOnlyPaths: [],
|
|
11854
|
+
conditionalCreateOnlyPaths: [],
|
|
11796
11855
|
defaults: {},
|
|
11797
11856
|
defaultPaths: {},
|
|
11798
11857
|
unorderedScalarPaths: [],
|
|
@@ -12037,6 +12096,7 @@ function parseSchema(schemaJson) {
|
|
|
12037
12096
|
const readOnlyPaths = dotted(schema.readOnlyProperties);
|
|
12038
12097
|
const writeOnlyPaths = dotted(schema.writeOnlyProperties);
|
|
12039
12098
|
const createOnlyPaths = dotted(schema.createOnlyProperties);
|
|
12099
|
+
const conditionalCreateOnlyPaths = dotted(schema.conditionalCreateOnlyProperties);
|
|
12040
12100
|
const definitions = schema.definitions ?? {};
|
|
12041
12101
|
const defaults = {};
|
|
12042
12102
|
for (const [k, def] of Object.entries(schema.properties ?? {})) {
|
|
@@ -12057,6 +12117,7 @@ function parseSchema(schemaJson) {
|
|
|
12057
12117
|
readOnlyPaths,
|
|
12058
12118
|
writeOnlyPaths,
|
|
12059
12119
|
createOnlyPaths,
|
|
12120
|
+
conditionalCreateOnlyPaths,
|
|
12060
12121
|
defaults,
|
|
12061
12122
|
defaultPaths,
|
|
12062
12123
|
unorderedScalarPaths: unorderedArrayPaths.scalar,
|
|
@@ -12288,8 +12349,10 @@ const DEFAULT_SG_LIST_TYPES = new Set([
|
|
|
12288
12349
|
"AWS::ElasticLoadBalancingV2::LoadBalancer",
|
|
12289
12350
|
"AWS::EC2::NetworkInterface",
|
|
12290
12351
|
"AWS::Neptune::DBCluster",
|
|
12291
|
-
"AWS::AmazonMQ::Broker"
|
|
12352
|
+
"AWS::AmazonMQ::Broker",
|
|
12353
|
+
"AWS::RedshiftServerless::Workgroup"
|
|
12292
12354
|
]);
|
|
12355
|
+
const DEFAULT_SUBNET_LIST_TYPES = new Set(["AWS::RedshiftServerless::Workgroup"]);
|
|
12293
12356
|
const defaultSgIdsCache = /* @__PURE__ */ new Map();
|
|
12294
12357
|
async function fetchDefaultSgIds(region) {
|
|
12295
12358
|
const cached = defaultSgIdsCache.get(region);
|
|
@@ -12319,6 +12382,35 @@ async function fetchDefaultSgIds(region) {
|
|
|
12319
12382
|
defaultSgIdsCache.set(region, ids);
|
|
12320
12383
|
return ids;
|
|
12321
12384
|
}
|
|
12385
|
+
const defaultSubnetIdsCache = /* @__PURE__ */ new Map();
|
|
12386
|
+
async function fetchDefaultVpcSubnetIds(region) {
|
|
12387
|
+
const cached = defaultSubnetIdsCache.get(region);
|
|
12388
|
+
if (cached) return cached;
|
|
12389
|
+
const ids = /* @__PURE__ */ new Set();
|
|
12390
|
+
try {
|
|
12391
|
+
const c = new EC2Client({
|
|
12392
|
+
region,
|
|
12393
|
+
...READ_RETRY
|
|
12394
|
+
});
|
|
12395
|
+
let token;
|
|
12396
|
+
do {
|
|
12397
|
+
const r = await c.send(new DescribeSubnetsCommand({
|
|
12398
|
+
Filters: [{
|
|
12399
|
+
Name: "default-for-az",
|
|
12400
|
+
Values: ["true"]
|
|
12401
|
+
}],
|
|
12402
|
+
NextToken: token,
|
|
12403
|
+
MaxResults: 1e3
|
|
12404
|
+
}));
|
|
12405
|
+
for (const s of r.Subnets ?? []) if (s.SubnetId) ids.add(s.SubnetId);
|
|
12406
|
+
token = r.NextToken;
|
|
12407
|
+
} while (token);
|
|
12408
|
+
} catch {
|
|
12409
|
+
return ids;
|
|
12410
|
+
}
|
|
12411
|
+
defaultSubnetIdsCache.set(region, ids);
|
|
12412
|
+
return ids;
|
|
12413
|
+
}
|
|
12322
12414
|
const kmsDeniedWarned = /* @__PURE__ */ new Set();
|
|
12323
12415
|
const kmsTransientWarned = /* @__PURE__ */ new Set();
|
|
12324
12416
|
const POOL_SIZE = 6;
|
|
@@ -12389,7 +12481,8 @@ function hasForeignScopeSignal(c, accountId, region) {
|
|
|
12389
12481
|
return (c.scopeArns ?? []).some((arn) => arn.startsWith("arn:") && !isDefinitiveNotManaged(arn, accountId, region));
|
|
12390
12482
|
}
|
|
12391
12483
|
async function probeSiblingPhysicalId(cfn, c, physicalId, cache, accountId, region) {
|
|
12392
|
-
const
|
|
12484
|
+
const cacheKey = `${c.resourceType}|${physicalId}`;
|
|
12485
|
+
const cached = cache.get(cacheKey);
|
|
12393
12486
|
if (cached !== void 0) return cached;
|
|
12394
12487
|
let managed = false;
|
|
12395
12488
|
try {
|
|
@@ -12416,13 +12509,13 @@ async function probeSiblingPhysicalId(cfn, c, physicalId, cache, accountId, regi
|
|
|
12416
12509
|
}
|
|
12417
12510
|
} catch (e) {
|
|
12418
12511
|
if (e.name === "ValidationError" && isDefinitiveNotManaged(physicalId, accountId, region) && !hasForeignScopeSignal(c, accountId, region)) {
|
|
12419
|
-
cache.set(
|
|
12512
|
+
cache.set(cacheKey, "notManaged");
|
|
12420
12513
|
return "notManaged";
|
|
12421
12514
|
}
|
|
12422
12515
|
return "unverified";
|
|
12423
12516
|
}
|
|
12424
12517
|
const result = managed ? "managed" : "notManaged";
|
|
12425
|
-
cache.set(
|
|
12518
|
+
cache.set(cacheKey, result);
|
|
12426
12519
|
return result;
|
|
12427
12520
|
}
|
|
12428
12521
|
async function isManagedBySiblingStack(cfn, c, cache, accountId, region) {
|
|
@@ -12889,12 +12982,15 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
12889
12982
|
}
|
|
12890
12983
|
let defaultSgIds = /* @__PURE__ */ new Set();
|
|
12891
12984
|
if (desired.resources.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
|
|
12985
|
+
let defaultSubnetIds = /* @__PURE__ */ new Set();
|
|
12986
|
+
if (desired.resources.some((r) => DEFAULT_SUBNET_LIST_TYPES.has(r.resourceType))) defaultSubnetIds = await fetchDefaultVpcSubnetIds(region);
|
|
12892
12987
|
const classifyOpts = {
|
|
12893
12988
|
accountId: desired.accountId,
|
|
12894
12989
|
region,
|
|
12895
12990
|
kmsAliasTargets,
|
|
12896
12991
|
stackTags: desired.stackTags ?? {},
|
|
12897
12992
|
defaultSgIds,
|
|
12993
|
+
defaultSubnetIds,
|
|
12898
12994
|
oaiCanonicalIds,
|
|
12899
12995
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
12900
12996
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|
|
@@ -12960,12 +13056,15 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
12960
13056
|
const oaiCanonicalIds = buildOaiCanonicalIds(desired);
|
|
12961
13057
|
let defaultSgIds = /* @__PURE__ */ new Set();
|
|
12962
13058
|
if (targets.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
|
|
13059
|
+
let defaultSubnetIds = /* @__PURE__ */ new Set();
|
|
13060
|
+
if (targets.some((r) => DEFAULT_SUBNET_LIST_TYPES.has(r.resourceType))) defaultSubnetIds = await fetchDefaultVpcSubnetIds(region);
|
|
12963
13061
|
const classifyOpts = {
|
|
12964
13062
|
accountId: desired.accountId,
|
|
12965
13063
|
region,
|
|
12966
13064
|
kmsAliasTargets,
|
|
12967
13065
|
stackTags: desired.stackTags ?? {},
|
|
12968
13066
|
defaultSgIds,
|
|
13067
|
+
defaultSubnetIds,
|
|
12969
13068
|
oaiCanonicalIds,
|
|
12970
13069
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
12971
13070
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|
|
@@ -16912,6 +17011,7 @@ function writeOnlyReincludeOps(declared, schema, existingOps) {
|
|
|
16912
17011
|
for (const path of schema.writeOnlyPaths) {
|
|
16913
17012
|
if (path.includes("*")) continue;
|
|
16914
17013
|
if (isUnderCreateOnly(path, schema.createOnlyPaths)) continue;
|
|
17014
|
+
if (isUnderCreateOnly(path, schema.conditionalCreateOnlyPaths ?? [])) continue;
|
|
16915
17015
|
const value = valueAtDottedPath(declared, path);
|
|
16916
17016
|
if (value === void 0 || value === UNRESOLVED || hasUnresolved(value)) continue;
|
|
16917
17017
|
const pointer = toPointer(path);
|