cdk-real-drift 0.22.2 → 0.22.4
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 +3 -1
- package/dist/cli.js +72 -10
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -870,7 +870,9 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
|
|
|
870
870
|
`iam:GetUserPolicy`, `iam:GetGroupPolicy`, `iam:GetPolicy`, `iam:GetPolicyVersion`,
|
|
871
871
|
`lambda:GetPolicy`, `budgets:ViewBudget`, `ec2:DescribeAddresses`,
|
|
872
872
|
`ec2:DescribeLaunchTemplateVersions`, `ec2:DescribeNetworkAcls`,
|
|
873
|
-
`route53:ListResourceRecordSets`,
|
|
873
|
+
`route53:ListResourceRecordSets`, `route53:ListHostedZonesByName` (resolves a
|
|
874
|
+
RecordSet declared via `HostedZoneName` instead of `HostedZoneId` to its zone
|
|
875
|
+
id),
|
|
874
876
|
`ses:DescribeReceiptRuleSet`, `ses:DescribeReceiptRule`, `ses:ListReceiptFilters`
|
|
875
877
|
(the SES inbound receipt-rule family — `ReceiptRuleSet` / `ReceiptRule` /
|
|
876
878
|
`ReceiptFilter` — has no Cloud Control handlers),
|
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";
|
|
@@ -30,7 +30,7 @@ import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermis
|
|
|
30
30
|
import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetSecurityConfigurationCommand, GetTableCommand, GetTablesCommand, GetTagsCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
|
|
31
31
|
import { GetFunctionCommand, GetPolicyCommand, LambdaClient, ListAliasesCommand as ListAliasesCommand$1, ListEventSourceMappingsCommand, ListFunctionUrlConfigsCommand, ListVersionsByFunctionCommand } from "@aws-sdk/client-lambda";
|
|
32
32
|
import { DescribeDomainConfigCommand, DescribeDomainsCommand, ListDomainNamesCommand, OpenSearchClient, UpdateDomainConfigCommand } from "@aws-sdk/client-opensearch";
|
|
33
|
-
import { ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
|
|
33
|
+
import { ChangeResourceRecordSetsCommand, ListHostedZonesByNameCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
|
|
34
34
|
import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, GetObjectCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
|
|
35
35
|
import { DeleteResourcePolicyCommand, GetResourcePolicyCommand, SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
|
|
36
36
|
import { GetTopicAttributesCommand, ListSubscriptionsByTopicCommand, SNSClient, SetTopicAttributesCommand } from "@aws-sdk/client-sns";
|
|
@@ -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,18 +12279,27 @@ 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
|
|
12282
|
+
const canonZone = (s) => unescapeRoute53Name(s).replace(/\.$/, "").toLowerCase();
|
|
12283
|
+
const resolveHostedZoneIdByName = async (c, zoneName) => {
|
|
12284
|
+
const target = canonZone(zoneName);
|
|
12285
|
+
const matches = ((await c.send(new ListHostedZonesByNameCommand({ DNSName: zoneName }))).HostedZones ?? []).filter((z) => !!z.Name && canonZone(z.Name) === target);
|
|
12286
|
+
return (matches.length === 1 ? matches[0] : void 0)?.Id?.replace(/^\/hostedzone\//, "");
|
|
12287
|
+
};
|
|
12279
12288
|
const readRoute53RecordSet = async ({ physicalId, declared, region }) => {
|
|
12280
12289
|
const parts = physicalId.split("_");
|
|
12281
12290
|
const hasIdParts = parts.length >= 3;
|
|
12282
|
-
const hostedZoneId = str$1(declared.HostedZoneId) ?? (hasIdParts ? parts[0] : void 0);
|
|
12283
|
-
const name = str$1(declared.Name) ?? (hasIdParts ? parts[1] : void 0);
|
|
12284
|
-
const type = str$1(declared.Type) ?? (hasIdParts ? parts[parts.length - 1] : void 0);
|
|
12285
|
-
if (!hostedZoneId || !name || !type) return void 0;
|
|
12286
12291
|
const c = new Route53Client({
|
|
12287
12292
|
region,
|
|
12288
12293
|
...READ_RETRY
|
|
12289
12294
|
});
|
|
12295
|
+
const declaredZoneId = str$1(declared.HostedZoneId);
|
|
12296
|
+
let hostedZoneId = declaredZoneId ?? (hasIdParts ? parts[0] : void 0);
|
|
12297
|
+
const name = str$1(declared.Name) ?? (hasIdParts ? parts[1] : void 0);
|
|
12298
|
+
const type = str$1(declared.Type) ?? (hasIdParts ? parts[parts.length - 1] : void 0);
|
|
12299
|
+
const zoneName = str$1(declared.HostedZoneName);
|
|
12300
|
+
const byName = !declaredZoneId && !!zoneName;
|
|
12301
|
+
if (!hostedZoneId && zoneName) hostedZoneId = await resolveHostedZoneIdByName(c, zoneName);
|
|
12302
|
+
if (!hostedZoneId || !name || !type) return void 0;
|
|
12290
12303
|
const canon = (s) => unescapeRoute53Name(s).replace(/\.$/, "").toLowerCase();
|
|
12291
12304
|
const declSetId = str$1(declared.SetIdentifier);
|
|
12292
12305
|
const isOurNameType = (x) => x.Type === type && !!x.Name && canon(x.Name) === canon(name);
|
|
@@ -12317,7 +12330,7 @@ const readRoute53RecordSet = async ({ physicalId, declared, region }) => {
|
|
|
12317
12330
|
const model = {
|
|
12318
12331
|
Name: alignTrailingDot(rec.Name === void 0 ? void 0 : unescapeRoute53Name(rec.Name), declared.Name),
|
|
12319
12332
|
Type: rec.Type,
|
|
12320
|
-
HostedZoneId: hostedZoneId
|
|
12333
|
+
...byName ? { HostedZoneName: zoneName } : { HostedZoneId: hostedZoneId }
|
|
12321
12334
|
};
|
|
12322
12335
|
if (rec.TTL !== void 0) model.TTL = String(rec.TTL);
|
|
12323
12336
|
const records = rec.ResourceRecords?.map((rr) => rr.Value).filter((v) => !!v);
|
|
@@ -14585,6 +14598,53 @@ async function isManagedBySiblingStack(cfn, c, cache, accountId, region) {
|
|
|
14585
14598
|
}
|
|
14586
14599
|
return sawUnverified ? "unverified" : "notManaged";
|
|
14587
14600
|
}
|
|
14601
|
+
async function resolveCrossRegionSibling(regions, probeInRegion) {
|
|
14602
|
+
let sawUnverified = false;
|
|
14603
|
+
for (const region of regions) {
|
|
14604
|
+
const r = await probeInRegion(region);
|
|
14605
|
+
if (r === "managed") return "managed";
|
|
14606
|
+
if (r === "unverified") sawUnverified = true;
|
|
14607
|
+
}
|
|
14608
|
+
return sawUnverified ? "unverified" : "notManaged";
|
|
14609
|
+
}
|
|
14610
|
+
function makeCrossRegionSiblingProbe(accountId, runRegion, deps) {
|
|
14611
|
+
let regionsPromise;
|
|
14612
|
+
const cfnClients = /* @__PURE__ */ new Map();
|
|
14613
|
+
const caches = /* @__PURE__ */ new Map();
|
|
14614
|
+
const fetchEnabledRegions = deps?.enabledRegions ?? (async () => {
|
|
14615
|
+
try {
|
|
14616
|
+
return ((await new EC2Client({
|
|
14617
|
+
region: runRegion,
|
|
14618
|
+
...READ_RETRY
|
|
14619
|
+
}).send(new DescribeRegionsCommand({ AllRegions: false }))).Regions ?? []).map((r) => r.RegionName).filter((n) => typeof n === "string" && n !== "" && n !== runRegion);
|
|
14620
|
+
} catch {
|
|
14621
|
+
return;
|
|
14622
|
+
}
|
|
14623
|
+
});
|
|
14624
|
+
const enabledRegions = () => regionsPromise ??= fetchEnabledRegions();
|
|
14625
|
+
const probeInRegion = deps?.probeInRegion ?? ((c, region) => {
|
|
14626
|
+
let client = cfnClients.get(region);
|
|
14627
|
+
if (!client) {
|
|
14628
|
+
client = new CloudFormationClient({
|
|
14629
|
+
region,
|
|
14630
|
+
...READ_RETRY
|
|
14631
|
+
});
|
|
14632
|
+
cfnClients.set(region, client);
|
|
14633
|
+
}
|
|
14634
|
+
let cache = caches.get(region);
|
|
14635
|
+
if (!cache) {
|
|
14636
|
+
cache = /* @__PURE__ */ new Map();
|
|
14637
|
+
caches.set(region, cache);
|
|
14638
|
+
}
|
|
14639
|
+
const physicalId = c.siblingLookupId ?? c.identifier;
|
|
14640
|
+
return probeSiblingPhysicalId(client, c, physicalId, cache, accountId, region);
|
|
14641
|
+
});
|
|
14642
|
+
return { async escalate(c) {
|
|
14643
|
+
const regions = await enabledRegions();
|
|
14644
|
+
if (regions === void 0) return "unverified";
|
|
14645
|
+
return resolveCrossRegionSibling(regions, (region) => probeInRegion(c, region));
|
|
14646
|
+
} };
|
|
14647
|
+
}
|
|
14588
14648
|
const SG_RULE_RESOURCE_SIDE = {
|
|
14589
14649
|
"AWS::EC2::SecurityGroupIngress": "ingress",
|
|
14590
14650
|
"AWS::EC2::SecurityGroupEgress": "egress"
|
|
@@ -15143,6 +15203,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15143
15203
|
}
|
|
15144
15204
|
const oaiCanonicalIds = buildOaiCanonicalIds(desired);
|
|
15145
15205
|
const siblingStackCache = /* @__PURE__ */ new Map();
|
|
15206
|
+
const crossRegionProbe = makeCrossRegionSiblingProbe(desired.accountId, region);
|
|
15146
15207
|
for (const r of desired.resources) {
|
|
15147
15208
|
const enumerate = CHILD_ENUMERATORS[r.resourceType];
|
|
15148
15209
|
if (!enumerate || !r.physicalId) continue;
|
|
@@ -15154,7 +15215,8 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15154
15215
|
region
|
|
15155
15216
|
});
|
|
15156
15217
|
for (const c of children) {
|
|
15157
|
-
|
|
15218
|
+
let sibling = await isManagedBySiblingStack(cfn, c, siblingStackCache, desired.accountId, region);
|
|
15219
|
+
if (sibling === "notManaged" && c.crossRegionSibling) sibling = await crossRegionProbe.escalate(c);
|
|
15158
15220
|
if (sibling === "managed") continue;
|
|
15159
15221
|
if (sibling === "unverified") {
|
|
15160
15222
|
findings.push({
|