cdk-real-drift 0.13.13 → 0.14.1
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 +413 -10
- package/dist/cli.js.map +1 -1
- package/package.json +2 -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, DescribeInternetGatewaysCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, DescribeVpcsCommand, EC2Client, GetDefaultCreditSpecificationCommand, GetEbsEncryptionByDefaultCommand, GetInstanceMetadataDefaultsCommand, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
|
|
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";
|
|
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 { DescribeParametersCommand, GetParametersCommand, GetServiceSettingCommand, SSMClient } from "@aws-sdk/client-ssm";
|
|
@@ -20,11 +20,13 @@ import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, Ge
|
|
|
20
20
|
import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
|
|
21
21
|
import { AppSyncClient, DeleteApiKeyCommand, ListApiKeysCommand, ListDataSourcesCommand, ListFunctionsCommand, ListResolversCommand, ListTypesCommand } from "@aws-sdk/client-appsync";
|
|
22
22
|
import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand as GetStagesCommand$1, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
|
|
23
|
+
import { AutoScalingClient, DescribeLifecycleHooksCommand, DescribeScheduledActionsCommand } from "@aws-sdk/client-auto-scaling";
|
|
23
24
|
import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
|
|
24
|
-
import { CognitoIdentityProviderClient, ListGroupsCommand, ListIdentityProvidersCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
|
|
25
|
+
import { CognitoIdentityProviderClient, DescribeUserPoolCommand, ListGroupsCommand, ListIdentityProvidersCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
|
|
25
26
|
import { DescribeMountTargetsCommand, EFSClient } from "@aws-sdk/client-efs";
|
|
26
27
|
import { DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
|
|
27
28
|
import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermissionCommand } from "@aws-sdk/client-eventbridge";
|
|
29
|
+
import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetSecurityConfigurationCommand, GetTableCommand, GetTablesCommand, GetTagsCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
|
|
28
30
|
import { GetFunctionCommand, GetPolicyCommand, LambdaClient, ListAliasesCommand as ListAliasesCommand$1, ListEventSourceMappingsCommand, ListFunctionUrlConfigsCommand, ListVersionsByFunctionCommand } from "@aws-sdk/client-lambda";
|
|
29
31
|
import { DescribeDomainConfigCommand, DescribeDomainsCommand, ListDomainNamesCommand, OpenSearchClient, UpdateDomainConfigCommand } from "@aws-sdk/client-opensearch";
|
|
30
32
|
import { ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand, Route53Client } from "@aws-sdk/client-route-53";
|
|
@@ -39,7 +41,6 @@ import { CognitoSyncClient, GetCognitoEventsCommand, SetCognitoEventsCommand } f
|
|
|
39
41
|
import { BatchGetProjectsCommand, BatchGetReportGroupsCommand, CodeBuildClient, UpdateReportGroupCommand } from "@aws-sdk/client-codebuild";
|
|
40
42
|
import { DescribeDBClustersCommand as DescribeDBClustersCommand$1, DescribeDBInstancesCommand as DescribeDBInstancesCommand$1, DocDBClient, ListTagsForResourceCommand, ModifyDBClusterCommand, ModifyDBInstanceCommand } from "@aws-sdk/client-docdb";
|
|
41
43
|
import { DAXClient, DescribeClustersCommand, DescribeParameterGroupsCommand, DescribeParametersCommand as DescribeParametersCommand$1, DescribeSubnetGroupsCommand, ListTagsCommand, UpdateClusterCommand, UpdateParameterGroupCommand } from "@aws-sdk/client-dax";
|
|
42
|
-
import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetSecurityConfigurationCommand, GetTableCommand, GetTagsCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
|
|
43
44
|
import { AttachGroupPolicyCommand, AttachRolePolicyCommand, AttachUserPolicyCommand, CreatePolicyVersionCommand, DeletePolicyVersionCommand, DeleteRolePolicyCommand, DetachGroupPolicyCommand, DetachRolePolicyCommand, DetachUserPolicyCommand, GetGroupPolicyCommand, GetPolicyCommand as GetPolicyCommand$1, GetPolicyVersionCommand, GetRolePolicyCommand, GetUserPolicyCommand, IAMClient, ListAccessKeysCommand, ListEntitiesForPolicyCommand, ListPolicyVersionsCommand, PutGroupPolicyCommand, PutRolePolicyCommand, PutUserPolicyCommand } from "@aws-sdk/client-iam";
|
|
44
45
|
import { DescribeCacheClustersCommand, DescribeCacheParameterGroupsCommand, DescribeCacheParametersCommand, DescribeReplicationGroupsCommand, DescribeUsersCommand, ElastiCacheClient, ListTagsForResourceCommand as ListTagsForResourceCommand$1, ModifyCacheParameterGroupCommand, ResetCacheParameterGroupCommand } from "@aws-sdk/client-elasticache";
|
|
45
46
|
import { DescribeParameterGroupsCommand as DescribeParameterGroupsCommand$1, DescribeParametersCommand as DescribeParametersCommand$2, DescribeUsersCommand as DescribeUsersCommand$1, MemoryDBClient, ResetParameterGroupCommand, UpdateParameterGroupCommand as UpdateParameterGroupCommand$1 } from "@aws-sdk/client-memorydb";
|
|
@@ -2603,7 +2604,16 @@ const KNOWN_DEFAULTS = {
|
|
|
2603
2604
|
PublicIpv4Pool: "amazon",
|
|
2604
2605
|
Domain: "vpc"
|
|
2605
2606
|
},
|
|
2606
|
-
"AWS::EC2::TransitGateway": {
|
|
2607
|
+
"AWS::EC2::TransitGateway": {
|
|
2608
|
+
SecurityGroupReferencingSupport: "disable",
|
|
2609
|
+
AmazonSideAsn: 64512,
|
|
2610
|
+
AutoAcceptSharedAttachments: "disable",
|
|
2611
|
+
DefaultRouteTableAssociation: "enable",
|
|
2612
|
+
DefaultRouteTablePropagation: "enable",
|
|
2613
|
+
DnsSupport: "enable",
|
|
2614
|
+
VpnEcmpSupport: "enable",
|
|
2615
|
+
MulticastSupport: "disable"
|
|
2616
|
+
},
|
|
2607
2617
|
"AWS::EC2::FlowLog": {
|
|
2608
2618
|
MaxAggregationInterval: 600,
|
|
2609
2619
|
LogFormat: "${version} ${account-id} ${interface-id} ${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${packets} ${bytes} ${start} ${end} ${action} ${log-status}"
|
|
@@ -3462,7 +3472,11 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3462
3472
|
"AWS::ElasticBeanstalk::ConfigurationTemplate": new Set(["PlatformArn"]),
|
|
3463
3473
|
"AWS::ElasticBeanstalk::Environment": new Set(["PlatformArn"]),
|
|
3464
3474
|
"AWS::ElasticLoadBalancing::LoadBalancer": new Set(["AvailabilityZones"]),
|
|
3465
|
-
"AWS::AutoScaling::AutoScalingGroup": new Set([
|
|
3475
|
+
"AWS::AutoScaling::AutoScalingGroup": new Set([
|
|
3476
|
+
"AvailabilityZones",
|
|
3477
|
+
"AvailabilityZoneIds",
|
|
3478
|
+
"LifecycleHookSpecificationList"
|
|
3479
|
+
]),
|
|
3466
3480
|
"AWS::ApiGateway::Authorizer": new Set(["AuthType"]),
|
|
3467
3481
|
"AWS::DMS::Endpoint": new Set(["KmsKeyId"]),
|
|
3468
3482
|
"AWS::DAX::Cluster": new Set(["PreferredMaintenanceWindow"]),
|
|
@@ -3564,7 +3578,10 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3564
3578
|
"FailureReason"
|
|
3565
3579
|
])
|
|
3566
3580
|
};
|
|
3567
|
-
const VALUE_INDEPENDENT_DEFAULT_NESTED_PATHS = {
|
|
3581
|
+
const VALUE_INDEPENDENT_DEFAULT_NESTED_PATHS = {
|
|
3582
|
+
"AWS::Batch::ComputeEnvironment": new Set(["ComputeResources.DesiredvCpus"]),
|
|
3583
|
+
"AWS::AutoScaling::AutoScalingGroup": new Set(["Tags.*.ResourceId", "Tags.*.ResourceType"])
|
|
3584
|
+
};
|
|
3568
3585
|
function isPhysicalIdSegment(value, physicalId) {
|
|
3569
3586
|
if (typeof value !== "string" || physicalId === void 0) return false;
|
|
3570
3587
|
if (value === physicalId) return true;
|
|
@@ -7841,7 +7858,10 @@ const CHILD_ENUMERATORS = {
|
|
|
7841
7858
|
"AWS::AppConfig::Application": enumerateAppConfigApplicationChildren,
|
|
7842
7859
|
"AWS::EFS::FileSystem": enumerateEfsFileSystemChildren,
|
|
7843
7860
|
"AWS::RDS::DBCluster": enumerateRdsClusterChildren,
|
|
7844
|
-
"AWS::Route53::HostedZone": enumerateRoute53HostedZoneChildren
|
|
7861
|
+
"AWS::Route53::HostedZone": enumerateRoute53HostedZoneChildren,
|
|
7862
|
+
"AWS::AutoScaling::AutoScalingGroup": enumerateAutoScalingGroupChildren,
|
|
7863
|
+
"AWS::Glue::Database": enumerateGlueDatabaseChildren,
|
|
7864
|
+
"AWS::EC2::TransitGateway": enumerateTransitGatewayChildren
|
|
7845
7865
|
};
|
|
7846
7866
|
function normalizeApiPath(p) {
|
|
7847
7867
|
let out = p.startsWith("/") ? p : `/${p}`;
|
|
@@ -9221,6 +9241,24 @@ async function pageUserPoolIdentityProviders(client, userPoolId) {
|
|
|
9221
9241
|
} while (next);
|
|
9222
9242
|
return out;
|
|
9223
9243
|
}
|
|
9244
|
+
function diffUserPoolDomainChildren(input) {
|
|
9245
|
+
const { userPoolId, declaredDomains, liveDomains } = input;
|
|
9246
|
+
const declared = new Set(declaredDomains);
|
|
9247
|
+
const added = [];
|
|
9248
|
+
for (const d of liveDomains) {
|
|
9249
|
+
if (declared.has(d.domain)) continue;
|
|
9250
|
+
added.push({
|
|
9251
|
+
resourceType: "AWS::Cognito::UserPoolDomain",
|
|
9252
|
+
identifier: `${userPoolId}|${d.domain}`,
|
|
9253
|
+
label: `${d.domain} (hosted UI domain)`,
|
|
9254
|
+
live: {
|
|
9255
|
+
Domain: d.domain,
|
|
9256
|
+
UserPoolId: userPoolId
|
|
9257
|
+
}
|
|
9258
|
+
});
|
|
9259
|
+
}
|
|
9260
|
+
return added;
|
|
9261
|
+
}
|
|
9224
9262
|
async function openSearchDomainTargetsPool(region, userPoolId) {
|
|
9225
9263
|
try {
|
|
9226
9264
|
const os = new OpenSearchClient({
|
|
@@ -9246,6 +9284,7 @@ async function enumerateUserPoolChildren(ctx) {
|
|
|
9246
9284
|
const declaredGroupNames = [];
|
|
9247
9285
|
const declaredResourceServerIdentifiers = [];
|
|
9248
9286
|
const declaredProviderNames = [];
|
|
9287
|
+
const declaredDomains = [];
|
|
9249
9288
|
for (const r of desired.resources) if (r.resourceType === "AWS::Cognito::UserPoolClient" && parentRefMatches(r.declared.UserPoolId, userPoolId) && r.physicalId) declaredClientIds.push(r.physicalId);
|
|
9250
9289
|
else if (r.resourceType === "AWS::Cognito::UserPoolGroup" && parentRefMatches(r.declared.UserPoolId, userPoolId)) {
|
|
9251
9290
|
const name = typeof r.declared.GroupName === "string" ? r.declared.GroupName : r.physicalId;
|
|
@@ -9256,6 +9295,9 @@ async function enumerateUserPoolChildren(ctx) {
|
|
|
9256
9295
|
} else if (r.resourceType === "AWS::Cognito::UserPoolIdentityProvider" && parentRefMatches(r.declared.UserPoolId, userPoolId)) {
|
|
9257
9296
|
const providerName = typeof r.declared.ProviderName === "string" ? r.declared.ProviderName : r.physicalId;
|
|
9258
9297
|
if (providerName) declaredProviderNames.push(providerName);
|
|
9298
|
+
} else if (r.resourceType === "AWS::Cognito::UserPoolDomain" && parentRefMatches(r.declared.UserPoolId, userPoolId)) {
|
|
9299
|
+
const domain = typeof r.declared.Domain === "string" ? r.declared.Domain : r.physicalId;
|
|
9300
|
+
if (domain) declaredDomains.push(domain);
|
|
9259
9301
|
}
|
|
9260
9302
|
const client = new CognitoIdentityProviderClient({
|
|
9261
9303
|
region,
|
|
@@ -9299,11 +9341,26 @@ async function enumerateUserPoolChildren(ctx) {
|
|
|
9299
9341
|
label: p.ProviderName
|
|
9300
9342
|
}))
|
|
9301
9343
|
});
|
|
9344
|
+
const describeRes = await client.send(new DescribeUserPoolCommand({ UserPoolId: userPoolId }));
|
|
9345
|
+
const liveDomains = [];
|
|
9346
|
+
const prefixDomain = describeRes.UserPool?.Domain;
|
|
9347
|
+
if (typeof prefixDomain === "string" && prefixDomain.length > 0) liveDomains.push({ domain: prefixDomain });
|
|
9348
|
+
const customDomain = describeRes.UserPool?.CustomDomain;
|
|
9349
|
+
if (typeof customDomain === "string" && customDomain.length > 0) liveDomains.push({
|
|
9350
|
+
domain: customDomain,
|
|
9351
|
+
custom: true
|
|
9352
|
+
});
|
|
9353
|
+
const domainAdded = diffUserPoolDomainChildren({
|
|
9354
|
+
userPoolId,
|
|
9355
|
+
declaredDomains,
|
|
9356
|
+
liveDomains
|
|
9357
|
+
});
|
|
9302
9358
|
return [
|
|
9303
9359
|
...clientAdded,
|
|
9304
9360
|
...groupAdded,
|
|
9305
9361
|
...resourceServerAdded,
|
|
9306
|
-
...idpAdded
|
|
9362
|
+
...idpAdded,
|
|
9363
|
+
...domainAdded
|
|
9307
9364
|
];
|
|
9308
9365
|
}
|
|
9309
9366
|
function diffGraphQLApiChildren(input) {
|
|
@@ -9844,6 +9901,40 @@ function diffVpcSecurityGroupChildren(input) {
|
|
|
9844
9901
|
}
|
|
9845
9902
|
return added;
|
|
9846
9903
|
}
|
|
9904
|
+
const NAT_GATEWAY_GONE_STATES = new Set([
|
|
9905
|
+
"deleted",
|
|
9906
|
+
"deleting",
|
|
9907
|
+
"failed"
|
|
9908
|
+
]);
|
|
9909
|
+
function diffVpcNatGatewayChildren(input) {
|
|
9910
|
+
const declared = new Set(input.declaredNatGatewayIds);
|
|
9911
|
+
const added = [];
|
|
9912
|
+
for (const n of input.liveNatGateways) {
|
|
9913
|
+
if (n.state !== void 0 && NAT_GATEWAY_GONE_STATES.has(n.state)) continue;
|
|
9914
|
+
if (declared.has(n.id)) continue;
|
|
9915
|
+
added.push({
|
|
9916
|
+
resourceType: "AWS::EC2::NatGateway",
|
|
9917
|
+
identifier: n.id,
|
|
9918
|
+
label: n.label ?? n.id,
|
|
9919
|
+
live: { NatGatewayId: n.id }
|
|
9920
|
+
});
|
|
9921
|
+
}
|
|
9922
|
+
return added;
|
|
9923
|
+
}
|
|
9924
|
+
function diffVpcFlowLogChildren(input) {
|
|
9925
|
+
const declared = new Set(input.declaredFlowLogIds);
|
|
9926
|
+
const added = [];
|
|
9927
|
+
for (const f of input.liveFlowLogs) {
|
|
9928
|
+
if (declared.has(f.id)) continue;
|
|
9929
|
+
added.push({
|
|
9930
|
+
resourceType: "AWS::EC2::FlowLog",
|
|
9931
|
+
identifier: f.id,
|
|
9932
|
+
label: f.label ?? f.id,
|
|
9933
|
+
live: { Id: f.id }
|
|
9934
|
+
});
|
|
9935
|
+
}
|
|
9936
|
+
return added;
|
|
9937
|
+
}
|
|
9847
9938
|
async function pageSecurityGroups(client, vpcId) {
|
|
9848
9939
|
const out = [];
|
|
9849
9940
|
let next;
|
|
@@ -9944,6 +10035,38 @@ async function pageInternetGateways(client, vpcId) {
|
|
|
9944
10035
|
} while (next);
|
|
9945
10036
|
return out;
|
|
9946
10037
|
}
|
|
10038
|
+
async function pageNatGateways(client, vpcId) {
|
|
10039
|
+
const out = [];
|
|
10040
|
+
let next;
|
|
10041
|
+
do {
|
|
10042
|
+
const res = await client.send(new DescribeNatGatewaysCommand({
|
|
10043
|
+
Filter: [{
|
|
10044
|
+
Name: "vpc-id",
|
|
10045
|
+
Values: [vpcId]
|
|
10046
|
+
}],
|
|
10047
|
+
NextToken: next
|
|
10048
|
+
}));
|
|
10049
|
+
out.push(...res.NatGateways ?? []);
|
|
10050
|
+
next = res.NextToken;
|
|
10051
|
+
} while (next);
|
|
10052
|
+
return out;
|
|
10053
|
+
}
|
|
10054
|
+
async function pageFlowLogs(client, vpcId) {
|
|
10055
|
+
const out = [];
|
|
10056
|
+
let next;
|
|
10057
|
+
do {
|
|
10058
|
+
const res = await client.send(new DescribeFlowLogsCommand({
|
|
10059
|
+
Filter: [{
|
|
10060
|
+
Name: "resource-id",
|
|
10061
|
+
Values: [vpcId]
|
|
10062
|
+
}],
|
|
10063
|
+
NextToken: next
|
|
10064
|
+
}));
|
|
10065
|
+
out.push(...res.FlowLogs ?? []);
|
|
10066
|
+
next = res.NextToken;
|
|
10067
|
+
} while (next);
|
|
10068
|
+
return out;
|
|
10069
|
+
}
|
|
9947
10070
|
async function describeVpc(client, vpcId) {
|
|
9948
10071
|
return (await client.send(new DescribeVpcsCommand({ VpcIds: [vpcId] }))).Vpcs?.[0];
|
|
9949
10072
|
}
|
|
@@ -9964,6 +10087,13 @@ async function enumerateVpcChildren(ctx) {
|
|
|
9964
10087
|
else if (r.resourceType === "AWS::EC2::NetworkAcl") declaredNaclIds.push(r.physicalId);
|
|
9965
10088
|
else if (r.resourceType === "AWS::EC2::SecurityGroup") declaredSecurityGroupIds.push(r.physicalId);
|
|
9966
10089
|
}
|
|
10090
|
+
const declaredNatGatewayIds = [];
|
|
10091
|
+
const declaredFlowLogIds = [];
|
|
10092
|
+
for (const r of desired.resources) {
|
|
10093
|
+
if (!r.physicalId) continue;
|
|
10094
|
+
if (r.resourceType === "AWS::EC2::NatGateway") declaredNatGatewayIds.push(r.physicalId);
|
|
10095
|
+
else if (r.resourceType === "AWS::EC2::FlowLog" && parentRefMatches(r.declared.ResourceId, vpcId)) declaredFlowLogIds.push(r.physicalId);
|
|
10096
|
+
}
|
|
9967
10097
|
const declaredAssociationIds = [];
|
|
9968
10098
|
let hasDeclaredIgwAttachment = false;
|
|
9969
10099
|
const declaredCidrs = [];
|
|
@@ -10023,6 +10153,15 @@ async function enumerateVpcChildren(ctx) {
|
|
|
10023
10153
|
id: g.GroupId,
|
|
10024
10154
|
label: g.GroupName ?? g.GroupId
|
|
10025
10155
|
}));
|
|
10156
|
+
const liveNatGateways = (await pageNatGateways(client, vpcId)).filter((n) => typeof n.NatGatewayId === "string").map((n) => ({
|
|
10157
|
+
id: n.NatGatewayId,
|
|
10158
|
+
state: n.State,
|
|
10159
|
+
label: n.SubnetId ? `${n.NatGatewayId} (${n.SubnetId})` : n.NatGatewayId
|
|
10160
|
+
}));
|
|
10161
|
+
const liveFlowLogs = (await pageFlowLogs(client, vpcId)).filter((f) => typeof f.FlowLogId === "string").map((f) => ({
|
|
10162
|
+
id: f.FlowLogId,
|
|
10163
|
+
label: f.LogDestination ?? f.LogGroupName ?? f.FlowLogId
|
|
10164
|
+
}));
|
|
10026
10165
|
return [
|
|
10027
10166
|
...diffVpcChildren({
|
|
10028
10167
|
declaredSubnetIds,
|
|
@@ -10057,6 +10196,14 @@ async function enumerateVpcChildren(ctx) {
|
|
|
10057
10196
|
...diffVpcSecurityGroupChildren({
|
|
10058
10197
|
declaredSecurityGroupIds,
|
|
10059
10198
|
liveSecurityGroups
|
|
10199
|
+
}),
|
|
10200
|
+
...diffVpcNatGatewayChildren({
|
|
10201
|
+
declaredNatGatewayIds,
|
|
10202
|
+
liveNatGateways
|
|
10203
|
+
}),
|
|
10204
|
+
...diffVpcFlowLogChildren({
|
|
10205
|
+
declaredFlowLogIds,
|
|
10206
|
+
liveFlowLogs
|
|
10060
10207
|
})
|
|
10061
10208
|
];
|
|
10062
10209
|
}
|
|
@@ -10609,6 +10756,252 @@ async function enumerateRoute53HostedZoneChildren(ctx) {
|
|
|
10609
10756
|
})
|
|
10610
10757
|
});
|
|
10611
10758
|
}
|
|
10759
|
+
function diffAsgScheduledActionChildren(input) {
|
|
10760
|
+
const { asgName, declaredActionNames, liveActions } = input;
|
|
10761
|
+
const declared = new Set(declaredActionNames);
|
|
10762
|
+
const added = [];
|
|
10763
|
+
for (const a of liveActions) {
|
|
10764
|
+
if (declared.has(a.name)) continue;
|
|
10765
|
+
added.push({
|
|
10766
|
+
resourceType: "AWS::AutoScaling::ScheduledAction",
|
|
10767
|
+
identifier: `${a.name}|${asgName}`,
|
|
10768
|
+
label: a.label ?? a.name,
|
|
10769
|
+
live: {
|
|
10770
|
+
ScheduledActionName: a.name,
|
|
10771
|
+
AutoScalingGroupName: asgName
|
|
10772
|
+
}
|
|
10773
|
+
});
|
|
10774
|
+
}
|
|
10775
|
+
return added;
|
|
10776
|
+
}
|
|
10777
|
+
function diffAsgLifecycleHookChildren(input) {
|
|
10778
|
+
const { asgName, declaredHookNames, liveHooks } = input;
|
|
10779
|
+
const declared = new Set(declaredHookNames);
|
|
10780
|
+
const added = [];
|
|
10781
|
+
for (const h of liveHooks) {
|
|
10782
|
+
if (declared.has(h.name)) continue;
|
|
10783
|
+
added.push({
|
|
10784
|
+
resourceType: "AWS::AutoScaling::LifecycleHook",
|
|
10785
|
+
identifier: `${asgName}|${h.name}`,
|
|
10786
|
+
label: h.label ?? h.name,
|
|
10787
|
+
live: {
|
|
10788
|
+
LifecycleHookName: h.name,
|
|
10789
|
+
AutoScalingGroupName: asgName
|
|
10790
|
+
}
|
|
10791
|
+
});
|
|
10792
|
+
}
|
|
10793
|
+
return added;
|
|
10794
|
+
}
|
|
10795
|
+
async function pageScheduledActions(client, asgName) {
|
|
10796
|
+
const out = [];
|
|
10797
|
+
let next;
|
|
10798
|
+
do {
|
|
10799
|
+
const res = await client.send(new DescribeScheduledActionsCommand({
|
|
10800
|
+
AutoScalingGroupName: asgName,
|
|
10801
|
+
NextToken: next
|
|
10802
|
+
}));
|
|
10803
|
+
out.push(...res.ScheduledUpdateGroupActions ?? []);
|
|
10804
|
+
next = res.NextToken;
|
|
10805
|
+
} while (next);
|
|
10806
|
+
return out;
|
|
10807
|
+
}
|
|
10808
|
+
async function describeLifecycleHooks(client, asgName) {
|
|
10809
|
+
return (await client.send(new DescribeLifecycleHooksCommand({ AutoScalingGroupName: asgName }))).LifecycleHooks ?? [];
|
|
10810
|
+
}
|
|
10811
|
+
async function enumerateAutoScalingGroupChildren(ctx) {
|
|
10812
|
+
const { parent, desired, region } = ctx;
|
|
10813
|
+
const asgName = parent.physicalId;
|
|
10814
|
+
if (!asgName) return [];
|
|
10815
|
+
const declaredActionNames = [];
|
|
10816
|
+
const declaredHookNames = [];
|
|
10817
|
+
for (const r of desired.resources) if (r.resourceType === "AWS::AutoScaling::ScheduledAction" && parentRefMatches(r.declared.AutoScalingGroupName, asgName) && r.physicalId) declaredActionNames.push(r.physicalId);
|
|
10818
|
+
else if (r.resourceType === "AWS::AutoScaling::LifecycleHook" && parentRefMatches(r.declared.AutoScalingGroupName, asgName)) {
|
|
10819
|
+
const name = typeof r.declared.LifecycleHookName === "string" ? r.declared.LifecycleHookName : r.physicalId;
|
|
10820
|
+
if (name) declaredHookNames.push(name);
|
|
10821
|
+
}
|
|
10822
|
+
const client = new AutoScalingClient({
|
|
10823
|
+
region,
|
|
10824
|
+
...READ_RETRY
|
|
10825
|
+
});
|
|
10826
|
+
const liveActions = (await pageScheduledActions(client, asgName)).filter((a) => typeof a.ScheduledActionName === "string").map((a) => ({
|
|
10827
|
+
name: a.ScheduledActionName,
|
|
10828
|
+
label: a.Recurrence ? `${a.ScheduledActionName} (${a.Recurrence})` : a.ScheduledActionName
|
|
10829
|
+
}));
|
|
10830
|
+
const liveHooks = (await describeLifecycleHooks(client, asgName)).filter((h) => typeof h.LifecycleHookName === "string").map((h) => ({
|
|
10831
|
+
name: h.LifecycleHookName,
|
|
10832
|
+
label: h.LifecycleTransition ? `${h.LifecycleHookName} (${h.LifecycleTransition})` : h.LifecycleHookName
|
|
10833
|
+
}));
|
|
10834
|
+
return [...diffAsgScheduledActionChildren({
|
|
10835
|
+
asgName,
|
|
10836
|
+
declaredActionNames,
|
|
10837
|
+
liveActions
|
|
10838
|
+
}), ...diffAsgLifecycleHookChildren({
|
|
10839
|
+
asgName,
|
|
10840
|
+
declaredHookNames,
|
|
10841
|
+
liveHooks
|
|
10842
|
+
})];
|
|
10843
|
+
}
|
|
10844
|
+
function diffGlueDatabaseChildren(input) {
|
|
10845
|
+
const { databaseName, declaredTableNames, liveTables } = input;
|
|
10846
|
+
const declared = new Set(declaredTableNames);
|
|
10847
|
+
const added = [];
|
|
10848
|
+
for (const t of liveTables) {
|
|
10849
|
+
if (declared.has(t.name)) continue;
|
|
10850
|
+
added.push({
|
|
10851
|
+
resourceType: "AWS::Glue::Table",
|
|
10852
|
+
identifier: `${databaseName}|${t.name}`,
|
|
10853
|
+
label: t.label ?? t.name,
|
|
10854
|
+
live: {
|
|
10855
|
+
DatabaseName: databaseName,
|
|
10856
|
+
TableInput: { Name: t.name }
|
|
10857
|
+
}
|
|
10858
|
+
});
|
|
10859
|
+
}
|
|
10860
|
+
return added;
|
|
10861
|
+
}
|
|
10862
|
+
async function pageGlueTables(client, databaseName, catalogId) {
|
|
10863
|
+
const out = [];
|
|
10864
|
+
let next;
|
|
10865
|
+
do {
|
|
10866
|
+
const res = await client.send(new GetTablesCommand({
|
|
10867
|
+
DatabaseName: databaseName,
|
|
10868
|
+
NextToken: next,
|
|
10869
|
+
...catalogId !== void 0 && { CatalogId: catalogId }
|
|
10870
|
+
}));
|
|
10871
|
+
out.push(...res.TableList ?? []);
|
|
10872
|
+
next = res.NextToken;
|
|
10873
|
+
} while (next);
|
|
10874
|
+
return out;
|
|
10875
|
+
}
|
|
10876
|
+
async function enumerateGlueDatabaseChildren(ctx) {
|
|
10877
|
+
const { parent, desired, region } = ctx;
|
|
10878
|
+
const databaseName = parent.physicalId;
|
|
10879
|
+
if (!databaseName) return [];
|
|
10880
|
+
const declaredTableNames = [];
|
|
10881
|
+
for (const r of desired.resources) {
|
|
10882
|
+
if (r.resourceType !== "AWS::Glue::Table" || !parentRefMatches(r.declared.DatabaseName, databaseName)) continue;
|
|
10883
|
+
const tableInput = r.declared.TableInput;
|
|
10884
|
+
const name = typeof tableInput?.Name === "string" ? tableInput.Name : r.physicalId?.split("|").pop();
|
|
10885
|
+
if (name) declaredTableNames.push(name);
|
|
10886
|
+
}
|
|
10887
|
+
const catalogId = typeof parent.declared.CatalogId === "string" ? parent.declared.CatalogId : void 0;
|
|
10888
|
+
return diffGlueDatabaseChildren({
|
|
10889
|
+
databaseName,
|
|
10890
|
+
declaredTableNames,
|
|
10891
|
+
liveTables: (await pageGlueTables(new GlueClient({
|
|
10892
|
+
region,
|
|
10893
|
+
...READ_RETRY
|
|
10894
|
+
}), databaseName, catalogId)).filter((t) => typeof t.Name === "string").map((t) => ({
|
|
10895
|
+
name: t.Name,
|
|
10896
|
+
label: t.TableType ? `${t.Name} (${t.TableType})` : t.Name
|
|
10897
|
+
}))
|
|
10898
|
+
});
|
|
10899
|
+
}
|
|
10900
|
+
const TGW_GONE_STATES = new Set([
|
|
10901
|
+
"deleted",
|
|
10902
|
+
"deleting",
|
|
10903
|
+
"failed"
|
|
10904
|
+
]);
|
|
10905
|
+
function diffTransitGatewayAttachmentChildren(input) {
|
|
10906
|
+
const declared = new Set(input.declaredAttachmentIds);
|
|
10907
|
+
const added = [];
|
|
10908
|
+
for (const a of input.liveAttachments) {
|
|
10909
|
+
if (a.resourceType !== "vpc") continue;
|
|
10910
|
+
if (a.state !== void 0 && TGW_GONE_STATES.has(a.state)) continue;
|
|
10911
|
+
if (declared.has(a.id)) continue;
|
|
10912
|
+
added.push({
|
|
10913
|
+
resourceType: "AWS::EC2::TransitGatewayAttachment",
|
|
10914
|
+
identifier: a.id,
|
|
10915
|
+
label: a.label ?? a.id,
|
|
10916
|
+
live: { Id: a.id }
|
|
10917
|
+
});
|
|
10918
|
+
}
|
|
10919
|
+
return added;
|
|
10920
|
+
}
|
|
10921
|
+
function diffTransitGatewayRouteTableChildren(input) {
|
|
10922
|
+
const declared = new Set(input.declaredRouteTableIds);
|
|
10923
|
+
const added = [];
|
|
10924
|
+
for (const rt of input.liveRouteTables) {
|
|
10925
|
+
if (rt.isDefaultAssociation === true || rt.isDefaultPropagation === true) continue;
|
|
10926
|
+
if (rt.state !== void 0 && TGW_GONE_STATES.has(rt.state)) continue;
|
|
10927
|
+
if (declared.has(rt.id)) continue;
|
|
10928
|
+
added.push({
|
|
10929
|
+
resourceType: "AWS::EC2::TransitGatewayRouteTable",
|
|
10930
|
+
identifier: rt.id,
|
|
10931
|
+
label: rt.label ?? rt.id,
|
|
10932
|
+
live: { TransitGatewayRouteTableId: rt.id }
|
|
10933
|
+
});
|
|
10934
|
+
}
|
|
10935
|
+
return added;
|
|
10936
|
+
}
|
|
10937
|
+
async function pageTransitGatewayAttachments(client, tgwId) {
|
|
10938
|
+
const out = [];
|
|
10939
|
+
let next;
|
|
10940
|
+
do {
|
|
10941
|
+
const res = await client.send(new DescribeTransitGatewayAttachmentsCommand({
|
|
10942
|
+
Filters: [{
|
|
10943
|
+
Name: "transit-gateway-id",
|
|
10944
|
+
Values: [tgwId]
|
|
10945
|
+
}],
|
|
10946
|
+
NextToken: next
|
|
10947
|
+
}));
|
|
10948
|
+
out.push(...res.TransitGatewayAttachments ?? []);
|
|
10949
|
+
next = res.NextToken;
|
|
10950
|
+
} while (next);
|
|
10951
|
+
return out;
|
|
10952
|
+
}
|
|
10953
|
+
async function pageTransitGatewayRouteTables(client, tgwId) {
|
|
10954
|
+
const out = [];
|
|
10955
|
+
let next;
|
|
10956
|
+
do {
|
|
10957
|
+
const res = await client.send(new DescribeTransitGatewayRouteTablesCommand({
|
|
10958
|
+
Filters: [{
|
|
10959
|
+
Name: "transit-gateway-id",
|
|
10960
|
+
Values: [tgwId]
|
|
10961
|
+
}],
|
|
10962
|
+
NextToken: next
|
|
10963
|
+
}));
|
|
10964
|
+
out.push(...res.TransitGatewayRouteTables ?? []);
|
|
10965
|
+
next = res.NextToken;
|
|
10966
|
+
} while (next);
|
|
10967
|
+
return out;
|
|
10968
|
+
}
|
|
10969
|
+
async function enumerateTransitGatewayChildren(ctx) {
|
|
10970
|
+
const { parent, desired, region } = ctx;
|
|
10971
|
+
const tgwId = parent.physicalId;
|
|
10972
|
+
if (!tgwId) return [];
|
|
10973
|
+
const declaredAttachmentIds = [];
|
|
10974
|
+
const declaredRouteTableIds = [];
|
|
10975
|
+
for (const r of desired.resources) {
|
|
10976
|
+
if (!parentRefMatches(r.declared.TransitGatewayId, tgwId) || !r.physicalId) continue;
|
|
10977
|
+
if (r.resourceType === "AWS::EC2::TransitGatewayAttachment" || r.resourceType === "AWS::EC2::TransitGatewayVpcAttachment") declaredAttachmentIds.push(r.physicalId);
|
|
10978
|
+
else if (r.resourceType === "AWS::EC2::TransitGatewayRouteTable") declaredRouteTableIds.push(r.physicalId);
|
|
10979
|
+
}
|
|
10980
|
+
const client = new EC2Client({
|
|
10981
|
+
region,
|
|
10982
|
+
...READ_RETRY
|
|
10983
|
+
});
|
|
10984
|
+
const liveAttachments = (await pageTransitGatewayAttachments(client, tgwId)).filter((a) => typeof a.TransitGatewayAttachmentId === "string").map((a) => ({
|
|
10985
|
+
id: a.TransitGatewayAttachmentId,
|
|
10986
|
+
resourceType: a.ResourceType,
|
|
10987
|
+
state: a.State,
|
|
10988
|
+
label: a.ResourceId ? `${a.TransitGatewayAttachmentId} (${a.ResourceType ?? "?"} ${a.ResourceId})` : a.TransitGatewayAttachmentId
|
|
10989
|
+
}));
|
|
10990
|
+
const liveRouteTables = (await pageTransitGatewayRouteTables(client, tgwId)).filter((rt) => typeof rt.TransitGatewayRouteTableId === "string").map((rt) => ({
|
|
10991
|
+
id: rt.TransitGatewayRouteTableId,
|
|
10992
|
+
isDefaultAssociation: rt.DefaultAssociationRouteTable,
|
|
10993
|
+
isDefaultPropagation: rt.DefaultPropagationRouteTable,
|
|
10994
|
+
state: rt.State,
|
|
10995
|
+
label: rt.TransitGatewayRouteTableId
|
|
10996
|
+
}));
|
|
10997
|
+
return [...diffTransitGatewayAttachmentChildren({
|
|
10998
|
+
declaredAttachmentIds,
|
|
10999
|
+
liveAttachments
|
|
11000
|
+
}), ...diffTransitGatewayRouteTableChildren({
|
|
11001
|
+
declaredRouteTableIds,
|
|
11002
|
+
liveRouteTables
|
|
11003
|
+
})];
|
|
11004
|
+
}
|
|
10612
11005
|
|
|
10613
11006
|
//#endregion
|
|
10614
11007
|
//#region src/read/pem.ts
|
|
@@ -13558,7 +13951,7 @@ const CC_GET_UNSUPPORTED_ADDED_TYPES = new Set([
|
|
|
13558
13951
|
"AWS::SNS::TopicPolicy",
|
|
13559
13952
|
"AWS::KMS::Grant"
|
|
13560
13953
|
]);
|
|
13561
|
-
async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
|
|
13954
|
+
async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds, region, accountId) {
|
|
13562
13955
|
const normalizeWith = async (raw) => {
|
|
13563
13956
|
let schema = schemas.get(c.resourceType);
|
|
13564
13957
|
if (!schema) {
|
|
@@ -13582,6 +13975,16 @@ async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
|
|
|
13582
13975
|
}));
|
|
13583
13976
|
return normalizeWith(JSON.parse(g.ResourceDescription?.Properties ?? "{}"));
|
|
13584
13977
|
} catch {
|
|
13978
|
+
const override = SDK_OVERRIDES[c.resourceType];
|
|
13979
|
+
if (override && region !== void 0 && accountId !== void 0) try {
|
|
13980
|
+
const raw = await override({
|
|
13981
|
+
physicalId: c.identifier,
|
|
13982
|
+
declared: c.live,
|
|
13983
|
+
region,
|
|
13984
|
+
accountId
|
|
13985
|
+
});
|
|
13986
|
+
if (raw !== void 0) return normalizeWith(raw);
|
|
13987
|
+
} catch {}
|
|
13585
13988
|
return {
|
|
13586
13989
|
model: c.live,
|
|
13587
13990
|
ok: false
|
|
@@ -14189,7 +14592,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
|
|
|
14189
14592
|
});
|
|
14190
14593
|
continue;
|
|
14191
14594
|
}
|
|
14192
|
-
const read = await readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds);
|
|
14595
|
+
const read = await readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds, region, desired.accountId);
|
|
14193
14596
|
findings.push(addedFinding(r, c, read));
|
|
14194
14597
|
}
|
|
14195
14598
|
} catch (e) {
|