cdk-real-drift 0.12.65 → 0.12.67
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 +109 -20
- 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;
|
|
@@ -3158,7 +3159,8 @@ const DEFAULT_MANAGED_NAME_PATHS = {
|
|
|
3158
3159
|
"AWS::Neptune::DBCluster": { DBClusterParameterGroupName: /^default\./ },
|
|
3159
3160
|
"AWS::Neptune::DBInstance": { DBParameterGroupName: /^default\./ },
|
|
3160
3161
|
"AWS::Redshift::Cluster": { ClusterParameterGroupName: /^default\./ },
|
|
3161
|
-
"AWS::MemoryDB::Cluster": { ParameterGroupName: /^default\./ }
|
|
3162
|
+
"AWS::MemoryDB::Cluster": { ParameterGroupName: /^default\./ },
|
|
3163
|
+
"AWS::CloudFormation::Stack": { RoleARN: /^arn:aws[\w-]*:iam::\d{12}:role\/cdk-[a-z0-9]+-cfn-exec-role-\d{12}-[a-z0-9-]+$/ }
|
|
3162
3164
|
};
|
|
3163
3165
|
const GENERATED_TOPLEVEL_PATHS = {
|
|
3164
3166
|
"AWS::ApiGatewayV2::Stage": new Set(["DeploymentId"]),
|
|
@@ -3401,11 +3403,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3401
3403
|
"ClusterVersion"
|
|
3402
3404
|
]),
|
|
3403
3405
|
"AWS::OpenSearchService::Domain": new Set(["OffPeakWindowOptions"]),
|
|
3404
|
-
"AWS::AmazonMQ::Broker": new Set([
|
|
3405
|
-
"MaintenanceWindowStartTime",
|
|
3406
|
-
"SecurityGroups",
|
|
3407
|
-
"SubnetIds"
|
|
3408
|
-
]),
|
|
3406
|
+
"AWS::AmazonMQ::Broker": new Set(["MaintenanceWindowStartTime", "SubnetIds"]),
|
|
3409
3407
|
"AWS::EC2::Instance": new Set([
|
|
3410
3408
|
"PrivateIpAddress",
|
|
3411
3409
|
"CpuOptions",
|
|
@@ -3422,7 +3420,6 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3422
3420
|
"AWS::EC2::VPCEndpoint": new Set(["ServiceRegion", "DnsOptions"]),
|
|
3423
3421
|
"AWS::EC2::VPCPeeringConnection": new Set(["PeerRegion"]),
|
|
3424
3422
|
"AWS::EC2::VPCCidrBlock": new Set(["Ipv6CidrBlock", "Ipv6CidrBlockNetworkBorderGroup"]),
|
|
3425
|
-
"AWS::EC2::TransitGateway": new Set(["AssociationDefaultRouteTableId", "PropagationDefaultRouteTableId"]),
|
|
3426
3423
|
"AWS::Grafana::Workspace": new Set(["GrafanaVersion"]),
|
|
3427
3424
|
"AWS::Bedrock::AgentAlias": new Set(["RoutingConfiguration"]),
|
|
3428
3425
|
"AWS::AppSync::ApiKey": new Set(["Expires"]),
|
|
@@ -3430,16 +3427,8 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3430
3427
|
"AWS::StepFunctions::StateMachineVersion": new Set(["StateMachineRevisionId"]),
|
|
3431
3428
|
"AWS::StepFunctions::StateMachineAlias": new Set(["StateMachineArn"]),
|
|
3432
3429
|
"AWS::AutoScaling::ScheduledAction": new Set(["StartTime"]),
|
|
3433
|
-
"AWS::RedshiftServerless::Workgroup": new Set([
|
|
3434
|
-
|
|
3435
|
-
"SecurityGroupIds",
|
|
3436
|
-
"SubnetIds"
|
|
3437
|
-
]),
|
|
3438
|
-
"AWS::CloudFormation::Stack": new Set([
|
|
3439
|
-
"TemplateBody",
|
|
3440
|
-
"RoleARN",
|
|
3441
|
-
"Capabilities"
|
|
3442
|
-
])
|
|
3430
|
+
"AWS::RedshiftServerless::Workgroup": new Set(["ConfigParameters"]),
|
|
3431
|
+
"AWS::CloudFormation::Stack": new Set(["TemplateBody", "Capabilities"])
|
|
3443
3432
|
};
|
|
3444
3433
|
function isPhysicalIdSegment(value, physicalId) {
|
|
3445
3434
|
if (typeof value !== "string" || physicalId === void 0) return false;
|
|
@@ -4600,6 +4589,21 @@ function changedDefaultParamInfo(template, stackParams, stackName) {
|
|
|
4600
4589
|
const more = diverged.length > shown.length ? `, …(+${diverged.length - shown.length} more)` : "";
|
|
4601
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}`;
|
|
4602
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
|
+
}
|
|
4603
4607
|
function partitionForRegion(region) {
|
|
4604
4608
|
if (region.startsWith("us-gov-")) return {
|
|
4605
4609
|
partition: "aws-us-gov",
|
|
@@ -4774,7 +4778,10 @@ async function listStackResources(client, stackName) {
|
|
|
4774
4778
|
}
|
|
4775
4779
|
async function loadDesired(client, stackName, region, templateOverride, recoveryTemplate) {
|
|
4776
4780
|
const [tmplRes, stkRes, { physIds, typeOf: deployedTypeOf }] = await Promise.all([
|
|
4777
|
-
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
|
+
})),
|
|
4778
4785
|
client.send(new DescribeStacksCommand({ StackName: stackName })),
|
|
4779
4786
|
listStackResources(client, stackName)
|
|
4780
4787
|
]);
|
|
@@ -4803,6 +4810,8 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
4803
4810
|
if (noValueInfo) console.error(noValueInfo);
|
|
4804
4811
|
const changedDefaultInfo = changedDefaultParamInfo(template, stackParams, stackName);
|
|
4805
4812
|
if (changedDefaultInfo) console.error(changedDefaultInfo);
|
|
4813
|
+
const transformInfo = transformStackWarning(template, stackName);
|
|
4814
|
+
if (transformInfo) console.error(transformInfo);
|
|
4806
4815
|
}
|
|
4807
4816
|
const templateResourcesForTypeCheck = template.Resources ?? {};
|
|
4808
4817
|
const typeChanged = new Set(typeChangedResources(templateResourcesForTypeCheck, deployedTypeOf));
|
|
@@ -5492,8 +5501,27 @@ function guardDutyFeaturesAllAtDefault(features) {
|
|
|
5492
5501
|
const DEFAULT_SG_LIST_PATHS = {
|
|
5493
5502
|
"AWS::ElasticLoadBalancingV2::LoadBalancer": "SecurityGroups",
|
|
5494
5503
|
"AWS::EC2::NetworkInterface": "GroupSet",
|
|
5495
|
-
"AWS::Neptune::DBCluster": "VpcSecurityGroupIds"
|
|
5504
|
+
"AWS::Neptune::DBCluster": "VpcSecurityGroupIds",
|
|
5505
|
+
"AWS::AmazonMQ::Broker": "SecurityGroups",
|
|
5506
|
+
"AWS::RedshiftServerless::Workgroup": "SecurityGroupIds"
|
|
5496
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" };
|
|
5497
5525
|
/** #889 fold decision for an UNDECLARED default-SG list (ALB SecurityGroups / ENI GroupSet).
|
|
5498
5526
|
* Returns whether the value-independent fold should still apply for this live value:
|
|
5499
5527
|
* - `true` → FOLD (atDefault): the live list is a single VPC-default SG id, OR the prefetch is
|
|
@@ -6922,6 +6950,29 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6922
6950
|
});
|
|
6923
6951
|
continue;
|
|
6924
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
|
+
}
|
|
6925
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)) {
|
|
6926
6977
|
findings.push({
|
|
6927
6978
|
tier: "atDefault",
|
|
@@ -12293,8 +12344,11 @@ function liveModelMap(reads) {
|
|
|
12293
12344
|
const DEFAULT_SG_LIST_TYPES = new Set([
|
|
12294
12345
|
"AWS::ElasticLoadBalancingV2::LoadBalancer",
|
|
12295
12346
|
"AWS::EC2::NetworkInterface",
|
|
12296
|
-
"AWS::Neptune::DBCluster"
|
|
12347
|
+
"AWS::Neptune::DBCluster",
|
|
12348
|
+
"AWS::AmazonMQ::Broker",
|
|
12349
|
+
"AWS::RedshiftServerless::Workgroup"
|
|
12297
12350
|
]);
|
|
12351
|
+
const DEFAULT_SUBNET_LIST_TYPES = new Set(["AWS::RedshiftServerless::Workgroup"]);
|
|
12298
12352
|
const defaultSgIdsCache = /* @__PURE__ */ new Map();
|
|
12299
12353
|
async function fetchDefaultSgIds(region) {
|
|
12300
12354
|
const cached = defaultSgIdsCache.get(region);
|
|
@@ -12324,6 +12378,35 @@ async function fetchDefaultSgIds(region) {
|
|
|
12324
12378
|
defaultSgIdsCache.set(region, ids);
|
|
12325
12379
|
return ids;
|
|
12326
12380
|
}
|
|
12381
|
+
const defaultSubnetIdsCache = /* @__PURE__ */ new Map();
|
|
12382
|
+
async function fetchDefaultVpcSubnetIds(region) {
|
|
12383
|
+
const cached = defaultSubnetIdsCache.get(region);
|
|
12384
|
+
if (cached) return cached;
|
|
12385
|
+
const ids = /* @__PURE__ */ new Set();
|
|
12386
|
+
try {
|
|
12387
|
+
const c = new EC2Client({
|
|
12388
|
+
region,
|
|
12389
|
+
...READ_RETRY
|
|
12390
|
+
});
|
|
12391
|
+
let token;
|
|
12392
|
+
do {
|
|
12393
|
+
const r = await c.send(new DescribeSubnetsCommand({
|
|
12394
|
+
Filters: [{
|
|
12395
|
+
Name: "default-for-az",
|
|
12396
|
+
Values: ["true"]
|
|
12397
|
+
}],
|
|
12398
|
+
NextToken: token,
|
|
12399
|
+
MaxResults: 1e3
|
|
12400
|
+
}));
|
|
12401
|
+
for (const s of r.Subnets ?? []) if (s.SubnetId) ids.add(s.SubnetId);
|
|
12402
|
+
token = r.NextToken;
|
|
12403
|
+
} while (token);
|
|
12404
|
+
} catch {
|
|
12405
|
+
return ids;
|
|
12406
|
+
}
|
|
12407
|
+
defaultSubnetIdsCache.set(region, ids);
|
|
12408
|
+
return ids;
|
|
12409
|
+
}
|
|
12327
12410
|
const kmsDeniedWarned = /* @__PURE__ */ new Set();
|
|
12328
12411
|
const kmsTransientWarned = /* @__PURE__ */ new Set();
|
|
12329
12412
|
const POOL_SIZE = 6;
|
|
@@ -12894,12 +12977,15 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
12894
12977
|
}
|
|
12895
12978
|
let defaultSgIds = /* @__PURE__ */ new Set();
|
|
12896
12979
|
if (desired.resources.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
|
|
12980
|
+
let defaultSubnetIds = /* @__PURE__ */ new Set();
|
|
12981
|
+
if (desired.resources.some((r) => DEFAULT_SUBNET_LIST_TYPES.has(r.resourceType))) defaultSubnetIds = await fetchDefaultVpcSubnetIds(region);
|
|
12897
12982
|
const classifyOpts = {
|
|
12898
12983
|
accountId: desired.accountId,
|
|
12899
12984
|
region,
|
|
12900
12985
|
kmsAliasTargets,
|
|
12901
12986
|
stackTags: desired.stackTags ?? {},
|
|
12902
12987
|
defaultSgIds,
|
|
12988
|
+
defaultSubnetIds,
|
|
12903
12989
|
oaiCanonicalIds,
|
|
12904
12990
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
12905
12991
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|
|
@@ -12965,12 +13051,15 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
12965
13051
|
const oaiCanonicalIds = buildOaiCanonicalIds(desired);
|
|
12966
13052
|
let defaultSgIds = /* @__PURE__ */ new Set();
|
|
12967
13053
|
if (targets.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
|
|
13054
|
+
let defaultSubnetIds = /* @__PURE__ */ new Set();
|
|
13055
|
+
if (targets.some((r) => DEFAULT_SUBNET_LIST_TYPES.has(r.resourceType))) defaultSubnetIds = await fetchDefaultVpcSubnetIds(region);
|
|
12968
13056
|
const classifyOpts = {
|
|
12969
13057
|
accountId: desired.accountId,
|
|
12970
13058
|
region,
|
|
12971
13059
|
kmsAliasTargets,
|
|
12972
13060
|
stackTags: desired.stackTags ?? {},
|
|
12973
13061
|
defaultSgIds,
|
|
13062
|
+
defaultSubnetIds,
|
|
12974
13063
|
oaiCanonicalIds,
|
|
12975
13064
|
siblingSgRules: buildSiblingSgRules(desired),
|
|
12976
13065
|
siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),
|