cdk-real-drift 0.13.12 → 0.14.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 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": { SecurityGroupReferencingSupport: "disable" },
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(["AvailabilityZones", "AvailabilityZoneIds"]),
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 = { "AWS::Batch::ComputeEnvironment": new Set(["ComputeResources.DesiredvCpus"]) };
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;
@@ -3695,7 +3712,10 @@ const ELB_ATTRIBUTE_DEFAULTS = {
3695
3712
  "zonal_shift.config.enabled": "false",
3696
3713
  "ipv6.deny_all_igw_traffic": "false"
3697
3714
  },
3698
- "AWS::ElasticLoadBalancingV2::Listener": { "routing.http.response.server.enabled": "true" },
3715
+ "AWS::ElasticLoadBalancingV2::Listener": {
3716
+ "routing.http.response.server.enabled": "true",
3717
+ "tcp.idle_timeout.seconds": "350"
3718
+ },
3699
3719
  "AWS::ElasticLoadBalancingV2::TargetGroup": {
3700
3720
  "deregistration_delay.timeout_seconds": "300",
3701
3721
  "lambda.multi_value_headers.enabled": "false",
@@ -3717,6 +3737,34 @@ const ELB_ATTRIBUTE_DEFAULTS_BY_LB_TYPE = {
3717
3737
  network: { "load_balancing.cross_zone.enabled": "false" },
3718
3738
  gateway: { "load_balancing.cross_zone.enabled": "false" }
3719
3739
  };
3740
+ const ELB_TG_ATTRIBUTE_DEFAULTS_BY_PROTOCOL = {
3741
+ GENEVE: {
3742
+ "stickiness.type": "source_ip_dest_ip_proto",
3743
+ "target_failover.on_deregistration": "no_rebalance",
3744
+ "target_failover.on_unhealthy": "no_rebalance"
3745
+ },
3746
+ TCP: {
3747
+ "stickiness.type": "source_ip",
3748
+ "deregistration_delay.connection_termination.enabled": "false",
3749
+ "proxy_protocol_v2.enabled": "false"
3750
+ },
3751
+ TLS: {
3752
+ "stickiness.type": "source_ip",
3753
+ "deregistration_delay.connection_termination.enabled": "false",
3754
+ "proxy_protocol_v2.enabled": "false"
3755
+ },
3756
+ UDP: {
3757
+ "stickiness.type": "source_ip",
3758
+ "deregistration_delay.connection_termination.enabled": "false",
3759
+ "proxy_protocol_v2.enabled": "false"
3760
+ },
3761
+ TCP_UDP: {
3762
+ "stickiness.type": "source_ip",
3763
+ "deregistration_delay.connection_termination.enabled": "false",
3764
+ "proxy_protocol_v2.enabled": "false"
3765
+ }
3766
+ };
3767
+ const ELB_TG_ATTRIBUTE_DEFAULTS_BY_TARGET_TYPE = { alb: { "preserve_client_ip.enabled": "true" } };
3720
3768
  const SENTINEL_UNPARSEABLE = Symbol("unparseable");
3721
3769
  function deepCompareUnordered(a, b) {
3722
3770
  if (a === b) return true;
@@ -5637,6 +5685,26 @@ function hasPathUnsafeKey(o) {
5637
5685
 
5638
5686
  //#endregion
5639
5687
  //#region src/diff/classify.ts
5688
+ function elbAttributeDefaultsFor(resourceType, declared, live) {
5689
+ const shared = ELB_ATTRIBUTE_DEFAULTS[resourceType] ?? {};
5690
+ if (resourceType === "AWS::ElasticLoadBalancingV2::LoadBalancer") {
5691
+ const lbType = String(live.Type ?? declared.Type ?? "application");
5692
+ return {
5693
+ ...shared,
5694
+ ...ELB_ATTRIBUTE_DEFAULTS_BY_LB_TYPE[lbType] ?? {}
5695
+ };
5696
+ }
5697
+ if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup") {
5698
+ const protocol = declared.Protocol ?? live.Protocol;
5699
+ const targetType = declared.TargetType ?? live.TargetType;
5700
+ return {
5701
+ ...shared,
5702
+ ...typeof protocol === "string" ? ELB_TG_ATTRIBUTE_DEFAULTS_BY_PROTOCOL[protocol] ?? {} : {},
5703
+ ...typeof targetType === "string" ? ELB_TG_ATTRIBUTE_DEFAULTS_BY_TARGET_TYPE[targetType] ?? {} : {}
5704
+ };
5705
+ }
5706
+ return shared;
5707
+ }
5640
5708
  const ELB_ATTRIBUTE_BAGS = {
5641
5709
  "AWS::ElasticLoadBalancingV2::LoadBalancer": "LoadBalancerAttributes",
5642
5710
  "AWS::ElasticLoadBalancingV2::TargetGroup": "TargetGroupAttributes",
@@ -6005,6 +6073,16 @@ function alignCompositeKeySubset(declared, live, spec) {
6005
6073
  });
6006
6074
  }
6007
6075
  const isNestedObject = (x) => x !== null && typeof x === "object" && !Array.isArray(x);
6076
+ function nicZeroGroupSetEquals(declaredNics, liveSgIds) {
6077
+ if (!Array.isArray(declaredNics)) return false;
6078
+ const nic0 = declaredNics.find((n) => n !== null && typeof n === "object" && (n.DeviceIndex === "0" || n.DeviceIndex === 0));
6079
+ if (nic0 === void 0) return false;
6080
+ const groupSet = nic0.GroupSet;
6081
+ if (!Array.isArray(groupSet) || groupSet.length !== liveSgIds.length) return false;
6082
+ if (!groupSet.every((g) => typeof g === "string") || !liveSgIds.every((g) => typeof g === "string")) return false;
6083
+ const live = new Set(liveSgIds);
6084
+ return groupSet.length === live.size && groupSet.every((g) => live.has(g));
6085
+ }
6008
6086
  const DDB_TABLE_TYPES = new Set(["AWS::DynamoDB::Table", "AWS::DynamoDB::GlobalTable"]);
6009
6087
  function capacityUnit(x) {
6010
6088
  if (typeof x === "number") return x;
@@ -6651,12 +6729,17 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6651
6729
  if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup") {
6652
6730
  const targetType = declaredIn?.["TargetType"];
6653
6731
  const protocolVersion = declaredIn?.["ProtocolVersion"] ?? live["ProtocolVersion"];
6732
+ const protocol = declaredIn?.["Protocol"] ?? live["Protocol"];
6654
6733
  knownDef = {
6655
6734
  ...knownDef,
6656
6735
  HealthyThresholdCount: 5,
6657
- HealthCheckIntervalSeconds: targetType === "lambda" ? 35 : 30,
6736
+ HealthCheckIntervalSeconds: targetType === "lambda" ? 35 : protocol === "GENEVE" ? 10 : 30,
6658
6737
  HealthCheckPath: protocolVersion === "GRPC" ? "/AWS.ALB/healthcheck" : "/",
6659
6738
  ...targetType === "lambda" ? { HealthCheckTimeoutSeconds: 30 } : {},
6739
+ ...targetType === "alb" ? {
6740
+ HealthCheckTimeoutSeconds: 6,
6741
+ Matcher: { HttpCode: "200-399" }
6742
+ } : {},
6660
6743
  ...protocolVersion === "GRPC" ? { Matcher: { GrpcCode: "12" } } : {}
6661
6744
  };
6662
6745
  }
@@ -7095,11 +7178,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7095
7178
  });
7096
7179
  }
7097
7180
  const declaredKeys = new Set(v.filter(isKeyValueEntry).map((e) => e.Key));
7098
- const lbType = resourceType === "AWS::ElasticLoadBalancingV2::LoadBalancer" ? String(live.Type ?? declared.Type ?? "application") : void 0;
7099
- const attrDefaults = {
7100
- ...ELB_ATTRIBUTE_DEFAULTS[resourceType] ?? {},
7101
- ...lbType === void 0 ? {} : ELB_ATTRIBUTE_DEFAULTS_BY_LB_TYPE[lbType] ?? {}
7102
- };
7181
+ const attrDefaults = elbAttributeDefaultsFor(resourceType, declared, live);
7103
7182
  for (const lEl of liveBag) {
7104
7183
  if (!isKeyValueEntry(lEl)) continue;
7105
7184
  const key = lEl.Key;
@@ -7296,11 +7375,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7296
7375
  for (const [k, v] of Object.entries(live)) {
7297
7376
  if (k in declared) continue;
7298
7377
  if (k === ELB_ATTRIBUTE_BAGS[resourceType] && Array.isArray(v)) {
7299
- const lbType = resourceType === "AWS::ElasticLoadBalancingV2::LoadBalancer" ? String(live.Type ?? declared.Type ?? "application") : void 0;
7300
- const attrDefaults = {
7301
- ...ELB_ATTRIBUTE_DEFAULTS[resourceType] ?? {},
7302
- ...lbType === void 0 ? {} : ELB_ATTRIBUTE_DEFAULTS_BY_LB_TYPE[lbType] ?? {}
7303
- };
7378
+ const attrDefaults = elbAttributeDefaultsFor(resourceType, declared, live);
7304
7379
  for (const lEl of v) {
7305
7380
  if (!isKeyValueEntry(lEl)) continue;
7306
7381
  const key = lEl.Key;
@@ -7328,6 +7403,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7328
7403
  });
7329
7404
  continue;
7330
7405
  }
7406
+ if (resourceType === "AWS::EC2::Instance" && k === "SecurityGroupIds" && Array.isArray(v) && nicZeroGroupSetEquals(declared.NetworkInterfaces, v)) {
7407
+ findings.push({
7408
+ tier: "atDefault",
7409
+ logicalId,
7410
+ resourceType,
7411
+ path: k,
7412
+ actual: v
7413
+ });
7414
+ continue;
7415
+ }
7331
7416
  if (DEFAULT_SG_LIST_PATHS[resourceType] === k && !isTrivialEmpty(v)) {
7332
7417
  findings.push({
7333
7418
  tier: shouldFoldDefaultSgList(resourceType, k, v, opts.defaultSgIds) ? "atDefault" : "undeclared",
@@ -7773,7 +7858,10 @@ const CHILD_ENUMERATORS = {
7773
7858
  "AWS::AppConfig::Application": enumerateAppConfigApplicationChildren,
7774
7859
  "AWS::EFS::FileSystem": enumerateEfsFileSystemChildren,
7775
7860
  "AWS::RDS::DBCluster": enumerateRdsClusterChildren,
7776
- "AWS::Route53::HostedZone": enumerateRoute53HostedZoneChildren
7861
+ "AWS::Route53::HostedZone": enumerateRoute53HostedZoneChildren,
7862
+ "AWS::AutoScaling::AutoScalingGroup": enumerateAutoScalingGroupChildren,
7863
+ "AWS::Glue::Database": enumerateGlueDatabaseChildren,
7864
+ "AWS::EC2::TransitGateway": enumerateTransitGatewayChildren
7777
7865
  };
7778
7866
  function normalizeApiPath(p) {
7779
7867
  let out = p.startsWith("/") ? p : `/${p}`;
@@ -9153,6 +9241,24 @@ async function pageUserPoolIdentityProviders(client, userPoolId) {
9153
9241
  } while (next);
9154
9242
  return out;
9155
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
+ }
9156
9262
  async function openSearchDomainTargetsPool(region, userPoolId) {
9157
9263
  try {
9158
9264
  const os = new OpenSearchClient({
@@ -9178,6 +9284,7 @@ async function enumerateUserPoolChildren(ctx) {
9178
9284
  const declaredGroupNames = [];
9179
9285
  const declaredResourceServerIdentifiers = [];
9180
9286
  const declaredProviderNames = [];
9287
+ const declaredDomains = [];
9181
9288
  for (const r of desired.resources) if (r.resourceType === "AWS::Cognito::UserPoolClient" && parentRefMatches(r.declared.UserPoolId, userPoolId) && r.physicalId) declaredClientIds.push(r.physicalId);
9182
9289
  else if (r.resourceType === "AWS::Cognito::UserPoolGroup" && parentRefMatches(r.declared.UserPoolId, userPoolId)) {
9183
9290
  const name = typeof r.declared.GroupName === "string" ? r.declared.GroupName : r.physicalId;
@@ -9188,6 +9295,9 @@ async function enumerateUserPoolChildren(ctx) {
9188
9295
  } else if (r.resourceType === "AWS::Cognito::UserPoolIdentityProvider" && parentRefMatches(r.declared.UserPoolId, userPoolId)) {
9189
9296
  const providerName = typeof r.declared.ProviderName === "string" ? r.declared.ProviderName : r.physicalId;
9190
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);
9191
9301
  }
9192
9302
  const client = new CognitoIdentityProviderClient({
9193
9303
  region,
@@ -9231,11 +9341,26 @@ async function enumerateUserPoolChildren(ctx) {
9231
9341
  label: p.ProviderName
9232
9342
  }))
9233
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
+ });
9234
9358
  return [
9235
9359
  ...clientAdded,
9236
9360
  ...groupAdded,
9237
9361
  ...resourceServerAdded,
9238
- ...idpAdded
9362
+ ...idpAdded,
9363
+ ...domainAdded
9239
9364
  ];
9240
9365
  }
9241
9366
  function diffGraphQLApiChildren(input) {
@@ -9639,6 +9764,7 @@ async function enumerateListenerChildren(ctx) {
9639
9764
  const { parent, desired, region } = ctx;
9640
9765
  const listenerArn = parent.physicalId;
9641
9766
  if (!listenerArn) return [];
9767
+ if (listenerArn.includes(":listener/gwy/")) return [];
9642
9768
  const declaredRuleArns = [];
9643
9769
  for (const r of desired.resources) if (r.resourceType === "AWS::ElasticLoadBalancingV2::ListenerRule" && parentRefMatches(r.declared.ListenerArn, listenerArn) && r.physicalId) declaredRuleArns.push(r.physicalId);
9644
9770
  return diffListenerChildren({
@@ -9775,6 +9901,40 @@ function diffVpcSecurityGroupChildren(input) {
9775
9901
  }
9776
9902
  return added;
9777
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
+ }
9778
9938
  async function pageSecurityGroups(client, vpcId) {
9779
9939
  const out = [];
9780
9940
  let next;
@@ -9807,6 +9967,10 @@ async function pageSubnets(client, vpcId) {
9807
9967
  } while (next);
9808
9968
  return out;
9809
9969
  }
9970
+ const SERVICE_MANAGED_VPCE_TAG_KEYS = new Set(["AWSMSKManaged"]);
9971
+ function isServiceManagedVpcEndpoint(e) {
9972
+ return (e.Tags ?? []).some((t) => typeof t.Key === "string" && SERVICE_MANAGED_VPCE_TAG_KEYS.has(t.Key));
9973
+ }
9810
9974
  async function pageVpcEndpoints(client, vpcId) {
9811
9975
  const out = [];
9812
9976
  let next;
@@ -9871,6 +10035,38 @@ async function pageInternetGateways(client, vpcId) {
9871
10035
  } while (next);
9872
10036
  return out;
9873
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
+ }
9874
10070
  async function describeVpc(client, vpcId) {
9875
10071
  return (await client.send(new DescribeVpcsCommand({ VpcIds: [vpcId] }))).Vpcs?.[0];
9876
10072
  }
@@ -9891,6 +10087,13 @@ async function enumerateVpcChildren(ctx) {
9891
10087
  else if (r.resourceType === "AWS::EC2::NetworkAcl") declaredNaclIds.push(r.physicalId);
9892
10088
  else if (r.resourceType === "AWS::EC2::SecurityGroup") declaredSecurityGroupIds.push(r.physicalId);
9893
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
+ }
9894
10097
  const declaredAssociationIds = [];
9895
10098
  let hasDeclaredIgwAttachment = false;
9896
10099
  const declaredCidrs = [];
@@ -9909,7 +10112,7 @@ async function enumerateVpcChildren(ctx) {
9909
10112
  id: s.SubnetId,
9910
10113
  label: s.CidrBlock ? `${s.CidrBlock}` : s.SubnetId
9911
10114
  }));
9912
- const liveEndpoints = (await pageVpcEndpoints(client, vpcId)).filter((e) => typeof e.VpcEndpointId === "string").map((e) => ({
10115
+ const liveEndpoints = (await pageVpcEndpoints(client, vpcId)).filter((e) => typeof e.VpcEndpointId === "string").filter((e) => !isServiceManagedVpcEndpoint(e)).map((e) => ({
9913
10116
  id: e.VpcEndpointId,
9914
10117
  label: e.ServiceName ?? e.VpcEndpointId
9915
10118
  }));
@@ -9950,6 +10153,15 @@ async function enumerateVpcChildren(ctx) {
9950
10153
  id: g.GroupId,
9951
10154
  label: g.GroupName ?? g.GroupId
9952
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
+ }));
9953
10165
  return [
9954
10166
  ...diffVpcChildren({
9955
10167
  declaredSubnetIds,
@@ -9984,6 +10196,14 @@ async function enumerateVpcChildren(ctx) {
9984
10196
  ...diffVpcSecurityGroupChildren({
9985
10197
  declaredSecurityGroupIds,
9986
10198
  liveSecurityGroups
10199
+ }),
10200
+ ...diffVpcNatGatewayChildren({
10201
+ declaredNatGatewayIds,
10202
+ liveNatGateways
10203
+ }),
10204
+ ...diffVpcFlowLogChildren({
10205
+ declaredFlowLogIds,
10206
+ liveFlowLogs
9987
10207
  })
9988
10208
  ];
9989
10209
  }
@@ -10536,6 +10756,252 @@ async function enumerateRoute53HostedZoneChildren(ctx) {
10536
10756
  })
10537
10757
  });
10538
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
+ }
10539
11005
 
10540
11006
  //#endregion
10541
11007
  //#region src/read/pem.ts
@@ -17826,6 +18292,7 @@ const REVERT_SET_DEFAULT_PATHS = new Set([
17826
18292
  "AWS::EC2::NetworkInterface\0SourceDestCheck",
17827
18293
  "AWS::EC2::Instance\0SourceDestCheck",
17828
18294
  "AWS::EC2::Instance\0InstanceInitiatedShutdownBehavior",
18295
+ "AWS::EC2::Instance\0MetadataOptions",
17829
18296
  "AWS::EC2::ClientVpnEndpoint\0VpnPort",
17830
18297
  "AWS::EC2::ClientVpnEndpoint\0DisconnectOnSessionTimeout",
17831
18298
  "AWS::EC2::ClientVpnEndpoint\0SessionTimeoutHours",