cdk-real-drift 0.22.2 → 0.22.3
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 +56 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { CloudControlClient, DeleteResourceCommand, GetResourceCommand, GetResou
|
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
11
|
import { BaseCredentials, CdkAppMultiContext, NonInteractiveIoHost, StackSelectionStrategy, Toolkit } from "@aws-cdk/toolkit-lib";
|
|
12
12
|
import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
|
|
13
|
-
import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeFlowLogsCommand, DescribeInternetGatewaysCommand, DescribeLaunchTemplateVersionsCommand, DescribeNatGatewaysCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeTransitGatewayAttachmentsCommand, DescribeTransitGatewayRouteTablesCommand, DescribeVpcEndpointsCommand, DescribeVpcsCommand, EC2Client, GetDefaultCreditSpecificationCommand, GetEbsEncryptionByDefaultCommand, GetInstanceMetadataDefaultsCommand, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
13
|
+
import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeFlowLogsCommand, DescribeInternetGatewaysCommand, DescribeLaunchTemplateVersionsCommand, DescribeNatGatewaysCommand, DescribeNetworkAclsCommand, DescribeRegionsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeTransitGatewayAttachmentsCommand, DescribeTransitGatewayRouteTablesCommand, DescribeVpcEndpointsCommand, DescribeVpcsCommand, EC2Client, GetDefaultCreditSpecificationCommand, GetEbsEncryptionByDefaultCommand, GetInstanceMetadataDefaultsCommand, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
14
14
|
import { DescribeServicesCommand, ECSClient, ListAccountSettingsCommand, ListServicesCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
|
|
15
15
|
import { DescribeCertificatesCommand, DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeOptionGroupOptionsCommand, RDSClient } from "@aws-sdk/client-rds";
|
|
16
16
|
import { DatabaseMigrationServiceClient, DescribeEndpointsCommand, DescribeOrderableReplicationInstancesCommand, DescribeReplicationInstancesCommand, DescribeReplicationSubnetGroupsCommand, DescribeReplicationTasksCommand, ListTagsForResourceCommand } from "@aws-sdk/client-database-migration-service";
|
|
@@ -11005,6 +11005,8 @@ async function enumerateRdsClusterChildren(ctx) {
|
|
|
11005
11005
|
});
|
|
11006
11006
|
}
|
|
11007
11007
|
const canonRoute53Name = (s) => s.replace(/\.$/, "").toLowerCase();
|
|
11008
|
+
const unescapeRoute53Name = (s) => s.replace(/\\(\d{3})/g, (_m, oct) => String.fromCharCode(Number.parseInt(oct, 8)));
|
|
11009
|
+
const route53RecordSetCfnPhysicalId = (liveName) => unescapeRoute53Name(liveName).replace(/\.$/, "");
|
|
11008
11010
|
const ACM_VALIDATION_TARGET = /\.acm-validations\.aws\.?$/i;
|
|
11009
11011
|
const isAcmValidationRecord = (type, live) => {
|
|
11010
11012
|
if (type !== "CNAME") return false;
|
|
@@ -11034,7 +11036,9 @@ function diffRoute53HostedZoneChildren(input) {
|
|
|
11034
11036
|
live: r.live ?? {
|
|
11035
11037
|
Name: r.name,
|
|
11036
11038
|
Type: r.type
|
|
11037
|
-
}
|
|
11039
|
+
},
|
|
11040
|
+
siblingLookupId: route53RecordSetCfnPhysicalId(r.name),
|
|
11041
|
+
crossRegionSibling: true
|
|
11038
11042
|
});
|
|
11039
11043
|
}
|
|
11040
11044
|
return added;
|
|
@@ -12275,7 +12279,6 @@ const alignTrailingDot = (live, declared) => {
|
|
|
12275
12279
|
if (live === void 0) return void 0;
|
|
12276
12280
|
return typeof declared === "string" && declared.endsWith(".") ? live.endsWith(".") ? live : `${live}.` : live.replace(/\.$/, "");
|
|
12277
12281
|
};
|
|
12278
|
-
const unescapeRoute53Name = (s) => s.replace(/\\(\d{3})/g, (_m, oct) => String.fromCharCode(Number.parseInt(oct, 8)));
|
|
12279
12282
|
const readRoute53RecordSet = async ({ physicalId, declared, region }) => {
|
|
12280
12283
|
const parts = physicalId.split("_");
|
|
12281
12284
|
const hasIdParts = parts.length >= 3;
|
|
@@ -14585,6 +14588,53 @@ async function isManagedBySiblingStack(cfn, c, cache, accountId, region) {
|
|
|
14585
14588
|
}
|
|
14586
14589
|
return sawUnverified ? "unverified" : "notManaged";
|
|
14587
14590
|
}
|
|
14591
|
+
async function resolveCrossRegionSibling(regions, probeInRegion) {
|
|
14592
|
+
let sawUnverified = false;
|
|
14593
|
+
for (const region of regions) {
|
|
14594
|
+
const r = await probeInRegion(region);
|
|
14595
|
+
if (r === "managed") return "managed";
|
|
14596
|
+
if (r === "unverified") sawUnverified = true;
|
|
14597
|
+
}
|
|
14598
|
+
return sawUnverified ? "unverified" : "notManaged";
|
|
14599
|
+
}
|
|
14600
|
+
function makeCrossRegionSiblingProbe(accountId, runRegion, deps) {
|
|
14601
|
+
let regionsPromise;
|
|
14602
|
+
const cfnClients = /* @__PURE__ */ new Map();
|
|
14603
|
+
const caches = /* @__PURE__ */ new Map();
|
|
14604
|
+
const fetchEnabledRegions = deps?.enabledRegions ?? (async () => {
|
|
14605
|
+
try {
|
|
14606
|
+
return ((await new EC2Client({
|
|
14607
|
+
region: runRegion,
|
|
14608
|
+
...READ_RETRY
|
|
14609
|
+
}).send(new DescribeRegionsCommand({ AllRegions: false }))).Regions ?? []).map((r) => r.RegionName).filter((n) => typeof n === "string" && n !== "" && n !== runRegion);
|
|
14610
|
+
} catch {
|
|
14611
|
+
return;
|
|
14612
|
+
}
|
|
14613
|
+
});
|
|
14614
|
+
const enabledRegions = () => regionsPromise ??= fetchEnabledRegions();
|
|
14615
|
+
const probeInRegion = deps?.probeInRegion ?? ((c, region) => {
|
|
14616
|
+
let client = cfnClients.get(region);
|
|
14617
|
+
if (!client) {
|
|
14618
|
+
client = new CloudFormationClient({
|
|
14619
|
+
region,
|
|
14620
|
+
...READ_RETRY
|
|
14621
|
+
});
|
|
14622
|
+
cfnClients.set(region, client);
|
|
14623
|
+
}
|
|
14624
|
+
let cache = caches.get(region);
|
|
14625
|
+
if (!cache) {
|
|
14626
|
+
cache = /* @__PURE__ */ new Map();
|
|
14627
|
+
caches.set(region, cache);
|
|
14628
|
+
}
|
|
14629
|
+
const physicalId = c.siblingLookupId ?? c.identifier;
|
|
14630
|
+
return probeSiblingPhysicalId(client, c, physicalId, cache, accountId, region);
|
|
14631
|
+
});
|
|
14632
|
+
return { async escalate(c) {
|
|
14633
|
+
const regions = await enabledRegions();
|
|
14634
|
+
if (regions === void 0) return "unverified";
|
|
14635
|
+
return resolveCrossRegionSibling(regions, (region) => probeInRegion(c, region));
|
|
14636
|
+
} };
|
|
14637
|
+
}
|
|
14588
14638
|
const SG_RULE_RESOURCE_SIDE = {
|
|
14589
14639
|
"AWS::EC2::SecurityGroupIngress": "ingress",
|
|
14590
14640
|
"AWS::EC2::SecurityGroupEgress": "egress"
|
|
@@ -15143,6 +15193,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15143
15193
|
}
|
|
15144
15194
|
const oaiCanonicalIds = buildOaiCanonicalIds(desired);
|
|
15145
15195
|
const siblingStackCache = /* @__PURE__ */ new Map();
|
|
15196
|
+
const crossRegionProbe = makeCrossRegionSiblingProbe(desired.accountId, region);
|
|
15146
15197
|
for (const r of desired.resources) {
|
|
15147
15198
|
const enumerate = CHILD_ENUMERATORS[r.resourceType];
|
|
15148
15199
|
if (!enumerate || !r.physicalId) continue;
|
|
@@ -15154,7 +15205,8 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15154
15205
|
region
|
|
15155
15206
|
});
|
|
15156
15207
|
for (const c of children) {
|
|
15157
|
-
|
|
15208
|
+
let sibling = await isManagedBySiblingStack(cfn, c, siblingStackCache, desired.accountId, region);
|
|
15209
|
+
if (sibling === "notManaged" && c.crossRegionSibling) sibling = await crossRegionProbe.escalate(c);
|
|
15158
15210
|
if (sibling === "managed") continue;
|
|
15159
15211
|
if (sibling === "unverified") {
|
|
15160
15212
|
findings.push({
|