cdk-real-drift 0.23.7 → 0.24.0
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 +369 -4
- package/dist/cli.js.map +1 -1
- package/package.json +3 -1
package/dist/cli.js
CHANGED
|
@@ -14,11 +14,12 @@ import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, D
|
|
|
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";
|
|
17
|
-
import { DescribeParametersCommand, GetParametersCommand, GetServiceSettingCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
17
|
+
import { DescribeMaintenanceWindowTargetsCommand, DescribeMaintenanceWindowTasksCommand, DescribeParametersCommand, GetParametersCommand, GetServiceSettingCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
18
18
|
import jsonata from "jsonata";
|
|
19
19
|
import { KMSClient, ListAliasesCommand, ListGrantsCommand, RevokeGrantCommand } from "@aws-sdk/client-kms";
|
|
20
20
|
import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, GetStagesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
21
21
|
import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
|
|
22
|
+
import { ApplicationAutoScalingClient, DescribeScalingPoliciesCommand } from "@aws-sdk/client-application-auto-scaling";
|
|
22
23
|
import { AppSyncClient, DeleteApiKeyCommand, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
|
|
23
24
|
import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand as GetStagesCommand$1, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
|
|
24
25
|
import { AutoScalingClient, DescribeLifecycleHooksCommand, DescribeScheduledActionsCommand } from "@aws-sdk/client-auto-scaling";
|
|
@@ -28,7 +29,8 @@ import { DescribeMountTargetsCommand, EFSClient } from "@aws-sdk/client-efs";
|
|
|
28
29
|
import { DescribeListenerCertificatesCommand, DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
|
|
29
30
|
import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermissionCommand } from "@aws-sdk/client-eventbridge";
|
|
30
31
|
import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetSecurityConfigurationCommand, GetTableCommand, GetTablesCommand, GetTagsCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
|
|
31
|
-
import {
|
|
32
|
+
import { GuardDutyClient, ListFiltersCommand, ListIPSetsCommand, ListPublishingDestinationsCommand, ListThreatEntitySetsCommand, ListThreatIntelSetsCommand, ListTrustedEntitySetsCommand } from "@aws-sdk/client-guardduty";
|
|
33
|
+
import { AddPermissionCommand, GetFunctionCommand, GetPolicyCommand, LambdaClient, ListAliasesCommand as ListAliasesCommand$1, ListEventSourceMappingsCommand, ListFunctionUrlConfigsCommand, ListVersionsByFunctionCommand, RemovePermissionCommand } from "@aws-sdk/client-lambda";
|
|
32
34
|
import { DescribeDomainConfigCommand, DescribeDomainsCommand, ListDomainNamesCommand, OpenSearchClient, UpdateDomainConfigCommand } from "@aws-sdk/client-opensearch";
|
|
33
35
|
import { ChangeResourceRecordSetsCommand, ListHostedZonesByNameCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
|
|
34
36
|
import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, GetObjectCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
|
|
@@ -8442,7 +8444,10 @@ const CHILD_ENUMERATORS = {
|
|
|
8442
8444
|
"AWS::Route53::HostedZone": enumerateRoute53HostedZoneChildren,
|
|
8443
8445
|
"AWS::AutoScaling::AutoScalingGroup": enumerateAutoScalingGroupChildren,
|
|
8444
8446
|
"AWS::Glue::Database": enumerateGlueDatabaseChildren,
|
|
8445
|
-
"AWS::EC2::TransitGateway": enumerateTransitGatewayChildren
|
|
8447
|
+
"AWS::EC2::TransitGateway": enumerateTransitGatewayChildren,
|
|
8448
|
+
"AWS::GuardDuty::Detector": enumerateGuardDutyDetectorChildren,
|
|
8449
|
+
"AWS::SSM::MaintenanceWindow": enumerateMaintenanceWindowChildren,
|
|
8450
|
+
"AWS::ApplicationAutoScaling::ScalableTarget": enumerateScalableTargetChildren
|
|
8446
8451
|
};
|
|
8447
8452
|
function normalizeApiPath(p) {
|
|
8448
8453
|
let out = p.startsWith("/") ? p : `/${p}`;
|
|
@@ -11594,6 +11599,314 @@ async function enumerateTransitGatewayChildren(ctx) {
|
|
|
11594
11599
|
liveRouteTables
|
|
11595
11600
|
})];
|
|
11596
11601
|
}
|
|
11602
|
+
function diffGuardDutyDetectorChildren(input) {
|
|
11603
|
+
const d = input.detectorId;
|
|
11604
|
+
const added = [];
|
|
11605
|
+
const declaredFilters = new Set(input.declaredFilterNames);
|
|
11606
|
+
for (const name of input.liveFilterNames) {
|
|
11607
|
+
if (declaredFilters.has(name)) continue;
|
|
11608
|
+
added.push({
|
|
11609
|
+
resourceType: "AWS::GuardDuty::Filter",
|
|
11610
|
+
identifier: `${d}|${name}`,
|
|
11611
|
+
label: name,
|
|
11612
|
+
live: {
|
|
11613
|
+
DetectorId: d,
|
|
11614
|
+
Name: name
|
|
11615
|
+
},
|
|
11616
|
+
siblingLookupId: name
|
|
11617
|
+
});
|
|
11618
|
+
}
|
|
11619
|
+
const childFirstSet = (resourceType, declaredIds, liveIds) => {
|
|
11620
|
+
const declared = new Set(declaredIds);
|
|
11621
|
+
for (const id of liveIds) {
|
|
11622
|
+
if (declared.has(id)) continue;
|
|
11623
|
+
added.push({
|
|
11624
|
+
resourceType,
|
|
11625
|
+
identifier: `${id}|${d}`,
|
|
11626
|
+
label: id,
|
|
11627
|
+
live: {
|
|
11628
|
+
DetectorId: d,
|
|
11629
|
+
Id: id
|
|
11630
|
+
},
|
|
11631
|
+
siblingLookupId: id
|
|
11632
|
+
});
|
|
11633
|
+
}
|
|
11634
|
+
};
|
|
11635
|
+
childFirstSet("AWS::GuardDuty::IPSet", input.declaredIpSetIds, input.liveIpSetIds);
|
|
11636
|
+
childFirstSet("AWS::GuardDuty::ThreatIntelSet", input.declaredThreatIntelSetIds, input.liveThreatIntelSetIds);
|
|
11637
|
+
childFirstSet("AWS::GuardDuty::ThreatEntitySet", input.declaredThreatEntitySetIds, input.liveThreatEntitySetIds);
|
|
11638
|
+
childFirstSet("AWS::GuardDuty::TrustedEntitySet", input.declaredTrustedEntitySetIds, input.liveTrustedEntitySetIds);
|
|
11639
|
+
const declaredDests = new Set(input.declaredPublishingDestinationIds);
|
|
11640
|
+
for (const dest of input.livePublishingDestinations) {
|
|
11641
|
+
if (declaredDests.has(dest.id)) continue;
|
|
11642
|
+
added.push({
|
|
11643
|
+
resourceType: "AWS::GuardDuty::PublishingDestination",
|
|
11644
|
+
identifier: `${d}|${dest.id}`,
|
|
11645
|
+
label: dest.destinationType ? `${dest.id} (${dest.destinationType})` : dest.id,
|
|
11646
|
+
live: {
|
|
11647
|
+
DetectorId: d,
|
|
11648
|
+
Id: dest.id
|
|
11649
|
+
},
|
|
11650
|
+
siblingLookupId: dest.id
|
|
11651
|
+
});
|
|
11652
|
+
}
|
|
11653
|
+
return added;
|
|
11654
|
+
}
|
|
11655
|
+
async function pageGuardDutyIds(send) {
|
|
11656
|
+
const out = [];
|
|
11657
|
+
let token;
|
|
11658
|
+
do {
|
|
11659
|
+
const r = await send(token);
|
|
11660
|
+
out.push(...r.ids ?? []);
|
|
11661
|
+
token = r.nextToken;
|
|
11662
|
+
} while (token);
|
|
11663
|
+
return out;
|
|
11664
|
+
}
|
|
11665
|
+
async function enumerateGuardDutyDetectorChildren(ctx) {
|
|
11666
|
+
const { parent, desired, region } = ctx;
|
|
11667
|
+
const detectorId = parent.physicalId;
|
|
11668
|
+
if (!detectorId) return [];
|
|
11669
|
+
const declaredOf = (type, nameProp) => {
|
|
11670
|
+
const out = [];
|
|
11671
|
+
for (const r of desired.resources) {
|
|
11672
|
+
if (r.resourceType !== type) continue;
|
|
11673
|
+
const det = r.declared.DetectorId;
|
|
11674
|
+
if (typeof det === "string" && det.length > 0 && !parentRefMatches(det, detectorId)) continue;
|
|
11675
|
+
const name = nameProp && typeof r.declared[nameProp] === "string" ? r.declared[nameProp] : r.physicalId;
|
|
11676
|
+
if (name) out.push(name);
|
|
11677
|
+
}
|
|
11678
|
+
return out;
|
|
11679
|
+
};
|
|
11680
|
+
const client = new GuardDutyClient({
|
|
11681
|
+
region,
|
|
11682
|
+
...READ_RETRY
|
|
11683
|
+
});
|
|
11684
|
+
const liveFilterNames = await pageGuardDutyIds(async (t) => {
|
|
11685
|
+
const r = await client.send(new ListFiltersCommand({
|
|
11686
|
+
DetectorId: detectorId,
|
|
11687
|
+
NextToken: t
|
|
11688
|
+
}));
|
|
11689
|
+
return {
|
|
11690
|
+
ids: r.FilterNames,
|
|
11691
|
+
nextToken: r.NextToken
|
|
11692
|
+
};
|
|
11693
|
+
});
|
|
11694
|
+
const liveIpSetIds = await pageGuardDutyIds(async (t) => {
|
|
11695
|
+
const r = await client.send(new ListIPSetsCommand({
|
|
11696
|
+
DetectorId: detectorId,
|
|
11697
|
+
NextToken: t
|
|
11698
|
+
}));
|
|
11699
|
+
return {
|
|
11700
|
+
ids: r.IpSetIds,
|
|
11701
|
+
nextToken: r.NextToken
|
|
11702
|
+
};
|
|
11703
|
+
});
|
|
11704
|
+
const liveThreatIntelSetIds = await pageGuardDutyIds(async (t) => {
|
|
11705
|
+
const r = await client.send(new ListThreatIntelSetsCommand({
|
|
11706
|
+
DetectorId: detectorId,
|
|
11707
|
+
NextToken: t
|
|
11708
|
+
}));
|
|
11709
|
+
return {
|
|
11710
|
+
ids: r.ThreatIntelSetIds,
|
|
11711
|
+
nextToken: r.NextToken
|
|
11712
|
+
};
|
|
11713
|
+
});
|
|
11714
|
+
const liveThreatEntitySetIds = await pageGuardDutyIds(async (t) => {
|
|
11715
|
+
const r = await client.send(new ListThreatEntitySetsCommand({
|
|
11716
|
+
DetectorId: detectorId,
|
|
11717
|
+
NextToken: t
|
|
11718
|
+
}));
|
|
11719
|
+
return {
|
|
11720
|
+
ids: r.ThreatEntitySetIds,
|
|
11721
|
+
nextToken: r.NextToken
|
|
11722
|
+
};
|
|
11723
|
+
});
|
|
11724
|
+
const liveTrustedEntitySetIds = await pageGuardDutyIds(async (t) => {
|
|
11725
|
+
const r = await client.send(new ListTrustedEntitySetsCommand({
|
|
11726
|
+
DetectorId: detectorId,
|
|
11727
|
+
NextToken: t
|
|
11728
|
+
}));
|
|
11729
|
+
return {
|
|
11730
|
+
ids: r.TrustedEntitySetIds,
|
|
11731
|
+
nextToken: r.NextToken
|
|
11732
|
+
};
|
|
11733
|
+
});
|
|
11734
|
+
const liveDests = [];
|
|
11735
|
+
let destToken;
|
|
11736
|
+
do {
|
|
11737
|
+
const r = await client.send(new ListPublishingDestinationsCommand({
|
|
11738
|
+
DetectorId: detectorId,
|
|
11739
|
+
NextToken: destToken
|
|
11740
|
+
}));
|
|
11741
|
+
liveDests.push(...r.Destinations ?? []);
|
|
11742
|
+
destToken = r.NextToken;
|
|
11743
|
+
} while (destToken);
|
|
11744
|
+
return diffGuardDutyDetectorChildren({
|
|
11745
|
+
detectorId,
|
|
11746
|
+
declaredFilterNames: declaredOf("AWS::GuardDuty::Filter", "Name"),
|
|
11747
|
+
declaredIpSetIds: declaredOf("AWS::GuardDuty::IPSet"),
|
|
11748
|
+
declaredThreatIntelSetIds: declaredOf("AWS::GuardDuty::ThreatIntelSet"),
|
|
11749
|
+
declaredThreatEntitySetIds: declaredOf("AWS::GuardDuty::ThreatEntitySet"),
|
|
11750
|
+
declaredTrustedEntitySetIds: declaredOf("AWS::GuardDuty::TrustedEntitySet"),
|
|
11751
|
+
declaredPublishingDestinationIds: declaredOf("AWS::GuardDuty::PublishingDestination"),
|
|
11752
|
+
liveFilterNames,
|
|
11753
|
+
liveIpSetIds,
|
|
11754
|
+
liveThreatIntelSetIds,
|
|
11755
|
+
liveThreatEntitySetIds,
|
|
11756
|
+
liveTrustedEntitySetIds,
|
|
11757
|
+
livePublishingDestinations: liveDests.filter((x) => typeof x.DestinationId === "string").map((x) => ({
|
|
11758
|
+
id: x.DestinationId,
|
|
11759
|
+
destinationType: x.DestinationType
|
|
11760
|
+
}))
|
|
11761
|
+
});
|
|
11762
|
+
}
|
|
11763
|
+
function diffMaintenanceWindowChildren(input) {
|
|
11764
|
+
const w = input.windowId;
|
|
11765
|
+
const added = [];
|
|
11766
|
+
const declaredTargets = new Set(input.declaredTargetIds);
|
|
11767
|
+
for (const t of input.liveTargets) {
|
|
11768
|
+
if (declaredTargets.has(t.id)) continue;
|
|
11769
|
+
added.push({
|
|
11770
|
+
resourceType: "AWS::SSM::MaintenanceWindowTarget",
|
|
11771
|
+
identifier: `${w}|${t.id}`,
|
|
11772
|
+
label: t.label ?? t.id,
|
|
11773
|
+
live: {
|
|
11774
|
+
WindowId: w,
|
|
11775
|
+
Id: t.id
|
|
11776
|
+
},
|
|
11777
|
+
siblingLookupId: t.id
|
|
11778
|
+
});
|
|
11779
|
+
}
|
|
11780
|
+
const declaredTasks = new Set(input.declaredTaskIds);
|
|
11781
|
+
for (const t of input.liveTasks) {
|
|
11782
|
+
if (declaredTasks.has(t.id)) continue;
|
|
11783
|
+
added.push({
|
|
11784
|
+
resourceType: "AWS::SSM::MaintenanceWindowTask",
|
|
11785
|
+
identifier: `${w}|${t.id}`,
|
|
11786
|
+
label: t.label ?? t.id,
|
|
11787
|
+
live: {
|
|
11788
|
+
WindowId: w,
|
|
11789
|
+
Id: t.id
|
|
11790
|
+
},
|
|
11791
|
+
siblingLookupId: t.id
|
|
11792
|
+
});
|
|
11793
|
+
}
|
|
11794
|
+
return added;
|
|
11795
|
+
}
|
|
11796
|
+
async function enumerateMaintenanceWindowChildren(ctx) {
|
|
11797
|
+
const { parent, desired, region } = ctx;
|
|
11798
|
+
const windowId = parent.physicalId;
|
|
11799
|
+
if (!windowId) return [];
|
|
11800
|
+
const declaredIdsOf = (type) => {
|
|
11801
|
+
const out = [];
|
|
11802
|
+
for (const r of desired.resources) {
|
|
11803
|
+
if (r.resourceType !== type || !parentRefMatches(r.declared.WindowId, windowId)) continue;
|
|
11804
|
+
if (r.physicalId) out.push(r.physicalId);
|
|
11805
|
+
}
|
|
11806
|
+
return out;
|
|
11807
|
+
};
|
|
11808
|
+
const client = new SSMClient({
|
|
11809
|
+
region,
|
|
11810
|
+
...READ_RETRY
|
|
11811
|
+
});
|
|
11812
|
+
const liveTargets = [];
|
|
11813
|
+
let targetToken;
|
|
11814
|
+
do {
|
|
11815
|
+
const r = await client.send(new DescribeMaintenanceWindowTargetsCommand({
|
|
11816
|
+
WindowId: windowId,
|
|
11817
|
+
NextToken: targetToken
|
|
11818
|
+
}));
|
|
11819
|
+
liveTargets.push(...r.Targets ?? []);
|
|
11820
|
+
targetToken = r.NextToken;
|
|
11821
|
+
} while (targetToken);
|
|
11822
|
+
const liveTasks = [];
|
|
11823
|
+
let taskToken;
|
|
11824
|
+
do {
|
|
11825
|
+
const r = await client.send(new DescribeMaintenanceWindowTasksCommand({
|
|
11826
|
+
WindowId: windowId,
|
|
11827
|
+
NextToken: taskToken
|
|
11828
|
+
}));
|
|
11829
|
+
liveTasks.push(...r.Tasks ?? []);
|
|
11830
|
+
taskToken = r.NextToken;
|
|
11831
|
+
} while (taskToken);
|
|
11832
|
+
return diffMaintenanceWindowChildren({
|
|
11833
|
+
windowId,
|
|
11834
|
+
declaredTargetIds: declaredIdsOf("AWS::SSM::MaintenanceWindowTarget"),
|
|
11835
|
+
declaredTaskIds: declaredIdsOf("AWS::SSM::MaintenanceWindowTask"),
|
|
11836
|
+
liveTargets: liveTargets.filter((t) => typeof t.WindowTargetId === "string").map((t) => ({
|
|
11837
|
+
id: t.WindowTargetId,
|
|
11838
|
+
label: t.Name ?? t.WindowTargetId
|
|
11839
|
+
})),
|
|
11840
|
+
liveTasks: liveTasks.filter((t) => typeof t.WindowTaskId === "string").map((t) => ({
|
|
11841
|
+
id: t.WindowTaskId,
|
|
11842
|
+
label: t.TaskArn ? `${t.WindowTaskId} (${t.Type ?? "?"} ${t.TaskArn})` : t.WindowTaskId
|
|
11843
|
+
}))
|
|
11844
|
+
});
|
|
11845
|
+
}
|
|
11846
|
+
function diffScalableTargetChildren(input) {
|
|
11847
|
+
const declaredArns = new Set(input.declaredPolicyArns);
|
|
11848
|
+
const declaredNames = new Set(input.declaredPolicyNames);
|
|
11849
|
+
const added = [];
|
|
11850
|
+
for (const p of input.livePolicies) {
|
|
11851
|
+
if (declaredArns.has(p.arn)) continue;
|
|
11852
|
+
if (p.name !== void 0 && declaredNames.has(p.name)) continue;
|
|
11853
|
+
added.push({
|
|
11854
|
+
resourceType: "AWS::ApplicationAutoScaling::ScalingPolicy",
|
|
11855
|
+
identifier: `${p.arn}|${input.scalableDimension}`,
|
|
11856
|
+
label: p.name ?? p.arn,
|
|
11857
|
+
live: {
|
|
11858
|
+
PolicyName: p.name,
|
|
11859
|
+
ScalingTargetId: `${input.resourceId}|${input.scalableDimension}|${input.serviceNamespace}`
|
|
11860
|
+
},
|
|
11861
|
+
siblingLookupId: p.arn
|
|
11862
|
+
});
|
|
11863
|
+
}
|
|
11864
|
+
return added;
|
|
11865
|
+
}
|
|
11866
|
+
async function enumerateScalableTargetChildren(ctx) {
|
|
11867
|
+
const { parent, desired, region } = ctx;
|
|
11868
|
+
const ns = parent.declared.ServiceNamespace;
|
|
11869
|
+
const resourceId = parent.declared.ResourceId;
|
|
11870
|
+
const dimension = parent.declared.ScalableDimension;
|
|
11871
|
+
if (typeof ns !== "string" || typeof resourceId !== "string" || typeof dimension !== "string") return [];
|
|
11872
|
+
const declaredPolicyArns = [];
|
|
11873
|
+
const declaredPolicyNames = [];
|
|
11874
|
+
for (const r of desired.resources) {
|
|
11875
|
+
if (r.resourceType !== "AWS::ApplicationAutoScaling::ScalingPolicy") continue;
|
|
11876
|
+
const viaTargetId = r.declared.ScalingTargetId !== void 0 && parentRefMatches(r.declared.ScalingTargetId, parent.physicalId);
|
|
11877
|
+
const viaPair = r.declared.ResourceId === resourceId && r.declared.ScalableDimension === dimension;
|
|
11878
|
+
if (!viaTargetId && !viaPair) continue;
|
|
11879
|
+
if (r.physicalId) declaredPolicyArns.push(r.physicalId);
|
|
11880
|
+
if (typeof r.declared.PolicyName === "string") declaredPolicyNames.push(r.declared.PolicyName);
|
|
11881
|
+
}
|
|
11882
|
+
const client = new ApplicationAutoScalingClient({
|
|
11883
|
+
region,
|
|
11884
|
+
...READ_RETRY
|
|
11885
|
+
});
|
|
11886
|
+
const livePolicies = [];
|
|
11887
|
+
let token;
|
|
11888
|
+
do {
|
|
11889
|
+
const r = await client.send(new DescribeScalingPoliciesCommand({
|
|
11890
|
+
ServiceNamespace: ns,
|
|
11891
|
+
ResourceId: resourceId,
|
|
11892
|
+
ScalableDimension: dimension,
|
|
11893
|
+
NextToken: token
|
|
11894
|
+
}));
|
|
11895
|
+
livePolicies.push(...r.ScalingPolicies ?? []);
|
|
11896
|
+
token = r.NextToken;
|
|
11897
|
+
} while (token);
|
|
11898
|
+
return diffScalableTargetChildren({
|
|
11899
|
+
serviceNamespace: ns,
|
|
11900
|
+
resourceId,
|
|
11901
|
+
scalableDimension: dimension,
|
|
11902
|
+
declaredPolicyArns,
|
|
11903
|
+
declaredPolicyNames,
|
|
11904
|
+
livePolicies: livePolicies.filter((p) => typeof p.PolicyARN === "string").map((p) => ({
|
|
11905
|
+
arn: p.PolicyARN,
|
|
11906
|
+
name: p.PolicyName
|
|
11907
|
+
}))
|
|
11908
|
+
});
|
|
11909
|
+
}
|
|
11597
11910
|
|
|
11598
11911
|
//#endregion
|
|
11599
11912
|
//#region src/read/pem.ts
|
|
@@ -19348,7 +19661,59 @@ const writeBudget = async (ctx, ops) => {
|
|
|
19348
19661
|
NewBudget: newBudget
|
|
19349
19662
|
}));
|
|
19350
19663
|
};
|
|
19664
|
+
const LAMBDA_PERMISSION_PROJECTED_CONDITIONS = {
|
|
19665
|
+
ArnLike: new Set(["AWS:SourceArn"]),
|
|
19666
|
+
StringEquals: new Set([
|
|
19667
|
+
"AWS:SourceAccount",
|
|
19668
|
+
"aws:PrincipalOrgID",
|
|
19669
|
+
"lambda:FunctionUrlAuthType"
|
|
19670
|
+
])
|
|
19671
|
+
};
|
|
19672
|
+
const writeLambdaPermission = async (ctx, ops) => {
|
|
19673
|
+
const fn = str(ctx.declared["FunctionName"]);
|
|
19674
|
+
if (!fn) throw new Error("cannot resolve FunctionName for Lambda Permission revert");
|
|
19675
|
+
const sid = str(ctx.physicalId);
|
|
19676
|
+
if (!sid) throw new Error("cannot resolve the Lambda Permission StatementId for revert");
|
|
19677
|
+
const c = new LambdaClient({
|
|
19678
|
+
region: ctx.region,
|
|
19679
|
+
...CLIENT_TIMEOUTS
|
|
19680
|
+
});
|
|
19681
|
+
let liveStmt;
|
|
19682
|
+
try {
|
|
19683
|
+
const raw = (await c.send(new GetPolicyCommand({ FunctionName: fn }))).Policy;
|
|
19684
|
+
liveStmt = (JSON.parse(raw ?? "{}").Statement ?? []).find((s) => s["Sid"] === sid);
|
|
19685
|
+
} catch (e) {
|
|
19686
|
+
if (e.name !== "ResourceNotFoundException") throw e;
|
|
19687
|
+
}
|
|
19688
|
+
const liveCond = liveStmt?.["Condition"];
|
|
19689
|
+
if (liveCond !== void 0 && liveCond !== null && typeof liveCond === "object") for (const [condOp, kv] of Object.entries(liveCond)) {
|
|
19690
|
+
const projected = LAMBDA_PERMISSION_PROJECTED_CONDITIONS[condOp];
|
|
19691
|
+
const keys = kv !== null && typeof kv === "object" ? Object.keys(kv) : [];
|
|
19692
|
+
const unprojected = projected ? keys.filter((k) => !projected.has(k)) : keys;
|
|
19693
|
+
if (unprojected.length > 0) throw new Error(`Lambda Permission ${sid} carries a condition the reader does not project (${condOp}: ${unprojected.join(", ")}) — a rebuild would silently drop it; update the permission manually`);
|
|
19694
|
+
}
|
|
19695
|
+
const desired = await desiredModel("AWS::Lambda::Permission", ctx, ops);
|
|
19696
|
+
const action = str(desired["Action"]);
|
|
19697
|
+
const principal = str(desired["Principal"]);
|
|
19698
|
+
if (!action || !principal) throw new Error("cannot resolve Action/Principal for Lambda Permission revert");
|
|
19699
|
+
if (liveStmt) await c.send(new RemovePermissionCommand({
|
|
19700
|
+
FunctionName: fn,
|
|
19701
|
+
StatementId: sid
|
|
19702
|
+
}));
|
|
19703
|
+
await c.send(new AddPermissionCommand({
|
|
19704
|
+
FunctionName: fn,
|
|
19705
|
+
StatementId: sid,
|
|
19706
|
+
Action: action,
|
|
19707
|
+
Principal: principal,
|
|
19708
|
+
SourceArn: str(desired["SourceArn"]),
|
|
19709
|
+
SourceAccount: str(desired["SourceAccount"]),
|
|
19710
|
+
PrincipalOrgID: str(desired["PrincipalOrgID"]),
|
|
19711
|
+
FunctionUrlAuthType: str(desired["FunctionUrlAuthType"])
|
|
19712
|
+
}));
|
|
19713
|
+
};
|
|
19714
|
+
const SDK_REBUILD_WRITER_TYPES = new Set(["AWS::Lambda::Permission"]);
|
|
19351
19715
|
const SDK_WRITERS = {
|
|
19716
|
+
"AWS::Lambda::Permission": writeLambdaPermission,
|
|
19352
19717
|
"AWS::Budgets::Budget": writeBudget,
|
|
19353
19718
|
"AWS::ApiGatewayV2::Stage": writeApiGatewayV2Stage,
|
|
19354
19719
|
"AWS::ElasticBeanstalk::Application": writeElasticBeanstalkApplication,
|
|
@@ -20060,7 +20425,7 @@ function buildRevertPlan(findings, baseline, opts = {}) {
|
|
|
20060
20425
|
continue;
|
|
20061
20426
|
}
|
|
20062
20427
|
const schema = opts.schemas?.get(f.resourceType);
|
|
20063
|
-
if (schema && isUnderCreateOnly(f.path, schema.createOnlyPaths)) {
|
|
20428
|
+
if (schema && isUnderCreateOnly(f.path, schema.createOnlyPaths) && !SDK_REBUILD_WRITER_TYPES.has(f.resourceType)) {
|
|
20064
20429
|
notRevertable.push({
|
|
20065
20430
|
displayId,
|
|
20066
20431
|
resourceType: f.resourceType,
|