cdk-real-drift 0.22.1 → 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 +107 -5
- 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";
|
|
@@ -2991,6 +2991,30 @@ const KNOWN_DEFAULT_ONE_OF_PATHS = {
|
|
|
2991
2991
|
};
|
|
2992
2992
|
const KNOWN_DEFAULT_PATHS = {
|
|
2993
2993
|
"AWS::Backup::RestoreTestingPlan": { "RecoveryPointSelection.SelectionWindowDays": 30 },
|
|
2994
|
+
"AWS::Budgets::Budget": {
|
|
2995
|
+
"Budget.CostTypes": {
|
|
2996
|
+
IncludeTax: true,
|
|
2997
|
+
IncludeSubscription: true,
|
|
2998
|
+
UseBlended: false,
|
|
2999
|
+
IncludeRefund: true,
|
|
3000
|
+
IncludeCredit: true,
|
|
3001
|
+
IncludeUpfront: true,
|
|
3002
|
+
IncludeRecurring: true,
|
|
3003
|
+
IncludeOtherSubscription: true,
|
|
3004
|
+
IncludeSupport: true,
|
|
3005
|
+
IncludeDiscount: true,
|
|
3006
|
+
UseAmortized: false
|
|
3007
|
+
},
|
|
3008
|
+
"Budget.CostTypes.IncludeTax": true,
|
|
3009
|
+
"Budget.CostTypes.IncludeSubscription": true,
|
|
3010
|
+
"Budget.CostTypes.IncludeRefund": true,
|
|
3011
|
+
"Budget.CostTypes.IncludeCredit": true,
|
|
3012
|
+
"Budget.CostTypes.IncludeUpfront": true,
|
|
3013
|
+
"Budget.CostTypes.IncludeRecurring": true,
|
|
3014
|
+
"Budget.CostTypes.IncludeOtherSubscription": true,
|
|
3015
|
+
"Budget.CostTypes.IncludeSupport": true,
|
|
3016
|
+
"Budget.CostTypes.IncludeDiscount": true
|
|
3017
|
+
},
|
|
2994
3018
|
"AWS::IoT::TopicRule": { "TopicRulePayload.AwsIotSqlVersion": "2015-10-08" },
|
|
2995
3019
|
"AWS::SageMaker::DataQualityJobDefinition": {
|
|
2996
3020
|
"DataQualityJobInput.BatchTransformInput.S3DataDistributionType": "FullyReplicated",
|
|
@@ -3706,6 +3730,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3706
3730
|
"AWS::StepFunctions::StateMachineAlias": new Set(["StateMachineArn"]),
|
|
3707
3731
|
"AWS::AutoScaling::ScheduledAction": new Set(["StartTime"]),
|
|
3708
3732
|
"AWS::CloudFormation::Stack": new Set(["TemplateBody", "Capabilities"]),
|
|
3733
|
+
"AWS::CloudFormation::StackSet": new Set(["TemplateBody"]),
|
|
3709
3734
|
"AWS::SageMaker::MonitoringSchedule": new Set([
|
|
3710
3735
|
"MonitoringScheduleStatus",
|
|
3711
3736
|
"LastMonitoringExecutionSummary",
|
|
@@ -6082,6 +6107,12 @@ const IDENTITY_KEYED_SUBSET_ARRAYS = {
|
|
|
6082
6107
|
} }
|
|
6083
6108
|
};
|
|
6084
6109
|
const VALUE_INDEPENDENT_KEYED_ELEMENTS = { "AWS::Cognito::UserPoolUser": { UserAttributes: new Set(["sub"]) } };
|
|
6110
|
+
const SLACK_ID_MIGRATION_PATHS = { "AWS::Chatbot::SlackChannelConfiguration": new Set(["SlackChannelId"]) };
|
|
6111
|
+
const SLACK_MIGRATION_PREFIXES = new Set(["G", "C"]);
|
|
6112
|
+
function isSlackIdMigrationEqual(a, b) {
|
|
6113
|
+
if (typeof a !== "string" || typeof b !== "string") return false;
|
|
6114
|
+
return a.length > 1 && b.length > 1 && SLACK_MIGRATION_PREFIXES.has(a[0] ?? "") && SLACK_MIGRATION_PREFIXES.has(b[0] ?? "") && a.slice(1) === b.slice(1);
|
|
6115
|
+
}
|
|
6085
6116
|
const NESTED_ARRAY_IDENTITY = {
|
|
6086
6117
|
"AWS::ApiGateway::Method": {
|
|
6087
6118
|
"Integration.IntegrationResponses": "StatusCode",
|
|
@@ -7621,6 +7652,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
7621
7652
|
if (VERSION_PREFIX_PATHS[resourceType]?.has(d.path) && isVersionPrefixMatch(d.stateValue, d.awsValue)) continue;
|
|
7622
7653
|
if (LATEST_SENTINEL_PATHS[resourceType]?.has(d.path) && isLatestSentinelMatch(d.stateValue, d.awsValue)) continue;
|
|
7623
7654
|
if (INTELLIGENT_TIERING_PATHS[resourceType]?.has(d.path) && isIntelligentTieringMatch(d.stateValue, d.awsValue)) continue;
|
|
7655
|
+
if (SLACK_ID_MIGRATION_PATHS[resourceType]?.has(d.path) && isSlackIdMigrationEqual(d.stateValue, d.awsValue)) continue;
|
|
7624
7656
|
if ((UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path) || UNORDERED_ARRAY_PROPS[resourceType]?.has(d.path.replace(/\.\d+(?=\.|$)/g, ".*")) || schema.unorderedScalarPaths?.includes(d.path)) && !ORDER_SIGNIFICANT_PATHS[resourceType]?.has(d.path) && isEqualUnorderedScalarSet(d.stateValue, d.awsValue)) continue;
|
|
7625
7657
|
if (isTrivialEmpty(d.stateValue) && d.path in knownDef && deepEqual(d.awsValue, knownDef[d.path]) && !(MEANINGFUL_WHEN_OFF[resourceType]?.[d.path]?.({
|
|
7626
7658
|
declared,
|
|
@@ -10973,6 +11005,14 @@ async function enumerateRdsClusterChildren(ctx) {
|
|
|
10973
11005
|
});
|
|
10974
11006
|
}
|
|
10975
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(/\.$/, "");
|
|
11010
|
+
const ACM_VALIDATION_TARGET = /\.acm-validations\.aws\.?$/i;
|
|
11011
|
+
const isAcmValidationRecord = (type, live) => {
|
|
11012
|
+
if (type !== "CNAME") return false;
|
|
11013
|
+
const values = live?.ResourceRecords;
|
|
11014
|
+
return Array.isArray(values) && values.length === 1 && typeof values[0] === "string" && ACM_VALIDATION_TARGET.test(values[0]);
|
|
11015
|
+
};
|
|
10976
11016
|
const route53RecordKey = (name, type, setIdentifier) => `${canonRoute53Name(name)}|${type.toUpperCase()}${setIdentifier !== void 0 ? `|${setIdentifier}` : ""}`;
|
|
10977
11017
|
const route53RecordSetIdentifier = (hostedZoneId, name, type, setIdentifier) => `${hostedZoneId}_${name}_${type.toUpperCase()}` + (setIdentifier !== void 0 ? `_${setIdentifier}` : "");
|
|
10978
11018
|
function diffRoute53HostedZoneChildren(input) {
|
|
@@ -10986,6 +11026,7 @@ function diffRoute53HostedZoneChildren(input) {
|
|
|
10986
11026
|
const name = canonRoute53Name(r.name);
|
|
10987
11027
|
if (type === "SOA") continue;
|
|
10988
11028
|
if (type === "NS" && apex !== void 0 && name === apex) continue;
|
|
11029
|
+
if (isAcmValidationRecord(type, r.live)) continue;
|
|
10989
11030
|
if (declared.has(route53RecordKey(r.name, r.type, r.setIdentifier))) continue;
|
|
10990
11031
|
const identifier = route53RecordSetIdentifier(hostedZoneId, r.name, type, r.setIdentifier);
|
|
10991
11032
|
added.push({
|
|
@@ -10995,7 +11036,9 @@ function diffRoute53HostedZoneChildren(input) {
|
|
|
10995
11036
|
live: r.live ?? {
|
|
10996
11037
|
Name: r.name,
|
|
10997
11038
|
Type: r.type
|
|
10998
|
-
}
|
|
11039
|
+
},
|
|
11040
|
+
siblingLookupId: route53RecordSetCfnPhysicalId(r.name),
|
|
11041
|
+
crossRegionSibling: true
|
|
10999
11042
|
});
|
|
11000
11043
|
}
|
|
11001
11044
|
return added;
|
|
@@ -11580,6 +11623,7 @@ const readBudget = async ({ physicalId, declared, accountId, region }) => {
|
|
|
11580
11623
|
...b.BudgetLimit !== void 0 && { BudgetLimit: b.BudgetLimit },
|
|
11581
11624
|
...b.PlannedBudgetLimits !== void 0 && { PlannedBudgetLimits: b.PlannedBudgetLimits },
|
|
11582
11625
|
...b.CostFilters !== void 0 && { CostFilters: b.CostFilters },
|
|
11626
|
+
...b.CostTypes !== void 0 && { CostTypes: b.CostTypes },
|
|
11583
11627
|
...aad && { AutoAdjustData: {
|
|
11584
11628
|
...aad.AutoAdjustType !== void 0 && { AutoAdjustType: aad.AutoAdjustType },
|
|
11585
11629
|
...aad.HistoricalOptions?.BudgetAdjustmentPeriod !== void 0 && { HistoricalOptions: { BudgetAdjustmentPeriod: aad.HistoricalOptions.BudgetAdjustmentPeriod } }
|
|
@@ -12235,7 +12279,6 @@ const alignTrailingDot = (live, declared) => {
|
|
|
12235
12279
|
if (live === void 0) return void 0;
|
|
12236
12280
|
return typeof declared === "string" && declared.endsWith(".") ? live.endsWith(".") ? live : `${live}.` : live.replace(/\.$/, "");
|
|
12237
12281
|
};
|
|
12238
|
-
const unescapeRoute53Name = (s) => s.replace(/\\(\d{3})/g, (_m, oct) => String.fromCharCode(Number.parseInt(oct, 8)));
|
|
12239
12282
|
const readRoute53RecordSet = async ({ physicalId, declared, region }) => {
|
|
12240
12283
|
const parts = physicalId.split("_");
|
|
12241
12284
|
const hasIdParts = parts.length >= 3;
|
|
@@ -13036,6 +13079,15 @@ const readSesConfigurationSetEventDestination = async ({ physicalId, declared, r
|
|
|
13036
13079
|
};
|
|
13037
13080
|
};
|
|
13038
13081
|
const ACM_DEFAULT_TRANSPARENCY = "ENABLED";
|
|
13082
|
+
const ACM_KEY_ALGORITHM_CANONICAL = {
|
|
13083
|
+
"RSA-1024": "RSA_1024",
|
|
13084
|
+
"RSA-2048": "RSA_2048",
|
|
13085
|
+
"RSA-3072": "RSA_3072",
|
|
13086
|
+
"RSA-4096": "RSA_4096",
|
|
13087
|
+
"EC-prime256v1": "EC_prime256v1",
|
|
13088
|
+
"EC-secp384r1": "EC_secp384r1",
|
|
13089
|
+
"EC-secp521r1": "EC_secp521r1"
|
|
13090
|
+
};
|
|
13039
13091
|
const readAcmCertificate = async ({ physicalId, declared, region }) => {
|
|
13040
13092
|
const arn = str$1(physicalId);
|
|
13041
13093
|
if (!arn || !arn.startsWith("arn:")) return void 0;
|
|
@@ -13047,7 +13099,8 @@ const readAcmCertificate = async ({ physicalId, declared, region }) => {
|
|
|
13047
13099
|
if (!cert) return void 0;
|
|
13048
13100
|
const model = {};
|
|
13049
13101
|
if (str$1(cert.DomainName)) model.DomainName = cert.DomainName;
|
|
13050
|
-
|
|
13102
|
+
const keyAlg = str$1(cert.KeyAlgorithm);
|
|
13103
|
+
if (keyAlg) model.KeyAlgorithm = ACM_KEY_ALGORITHM_CANONICAL[keyAlg] ?? keyAlg;
|
|
13051
13104
|
const declaredSans = Array.isArray(declared.SubjectAlternativeNames) ? declared.SubjectAlternativeNames.filter((s) => str$1(s) !== void 0) : [];
|
|
13052
13105
|
const declaresSans = declaredSans.length > 0;
|
|
13053
13106
|
let sans = (cert.SubjectAlternativeNames ?? []).filter((s) => str$1(s) !== void 0);
|
|
@@ -14535,6 +14588,53 @@ async function isManagedBySiblingStack(cfn, c, cache, accountId, region) {
|
|
|
14535
14588
|
}
|
|
14536
14589
|
return sawUnverified ? "unverified" : "notManaged";
|
|
14537
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
|
+
}
|
|
14538
14638
|
const SG_RULE_RESOURCE_SIDE = {
|
|
14539
14639
|
"AWS::EC2::SecurityGroupIngress": "ingress",
|
|
14540
14640
|
"AWS::EC2::SecurityGroupEgress": "egress"
|
|
@@ -15093,6 +15193,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15093
15193
|
}
|
|
15094
15194
|
const oaiCanonicalIds = buildOaiCanonicalIds(desired);
|
|
15095
15195
|
const siblingStackCache = /* @__PURE__ */ new Map();
|
|
15196
|
+
const crossRegionProbe = makeCrossRegionSiblingProbe(desired.accountId, region);
|
|
15096
15197
|
for (const r of desired.resources) {
|
|
15097
15198
|
const enumerate = CHILD_ENUMERATORS[r.resourceType];
|
|
15098
15199
|
if (!enumerate || !r.physicalId) continue;
|
|
@@ -15104,7 +15205,8 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
15104
15205
|
region
|
|
15105
15206
|
});
|
|
15106
15207
|
for (const c of children) {
|
|
15107
|
-
|
|
15208
|
+
let sibling = await isManagedBySiblingStack(cfn, c, siblingStackCache, desired.accountId, region);
|
|
15209
|
+
if (sibling === "notManaged" && c.crossRegionSibling) sibling = await crossRegionProbe.escalate(c);
|
|
15108
15210
|
if (sibling === "managed") continue;
|
|
15109
15211
|
if (sibling === "unverified") {
|
|
15110
15212
|
findings.push({
|