cdk-real-drift 0.12.76 → 0.12.78

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,9 +10,10 @@ 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, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
13
+ import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeInternetGatewaysCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, DescribeVpcsCommand, EC2Client, GetEbsEncryptionByDefaultCommand, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
14
+ import { DescribeServicesCommand, ECSClient, ListAccountSettingsCommand, ListServicesCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
14
15
  import { DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeOptionGroupOptionsCommand, RDSClient } from "@aws-sdk/client-rds";
15
- import { DescribeParametersCommand, GetParametersCommand, SSMClient } from "@aws-sdk/client-ssm";
16
+ import { DescribeParametersCommand, GetParametersCommand, GetServiceSettingCommand, SSMClient } from "@aws-sdk/client-ssm";
16
17
  import jsonata from "jsonata";
17
18
  import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
18
19
  import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, GetStagesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
@@ -21,7 +22,6 @@ import { AppSyncClient, DeleteApiKeyCommand, ListApiKeysCommand, ListDataSources
21
22
  import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand as GetStagesCommand$1, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
22
23
  import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
23
24
  import { CognitoIdentityProviderClient, ListGroupsCommand, ListIdentityProvidersCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
24
- import { DescribeServicesCommand, ECSClient, ListServicesCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
25
25
  import { DescribeMountTargetsCommand, EFSClient } from "@aws-sdk/client-efs";
26
26
  import { DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
27
27
  import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermissionCommand } from "@aws-sdk/client-eventbridge";
@@ -5506,7 +5506,9 @@ const MEANINGFUL_WHEN_OFF = {
5506
5506
  "AWS::Cognito::UserPoolClient": { EnableTokenRevocation: () => true },
5507
5507
  "AWS::CloudWatch::CompositeAlarm": { ActionsEnabled: () => true },
5508
5508
  "AWS::ApplicationInsights::Application": { CWEMonitorEnabled: () => true },
5509
- "AWS::GuardDuty::Detector": { DataSources: () => true }
5509
+ "AWS::GuardDuty::Detector": { DataSources: () => true },
5510
+ "AWS::Lambda::EventSourceMapping": { Enabled: () => true },
5511
+ "AWS::ElasticLoadBalancingV2::TargetGroup": { HealthCheckEnabled: ({ declared }) => declared["TargetType"] !== "lambda" }
5510
5512
  };
5511
5513
  const GUARDDUTY_DEFAULT_DISABLED_FEATURES = new Set(["AI_ANALYST"]);
5512
5514
  function guardDutyFeaturesAllAtDefault(features) {
@@ -5574,6 +5576,15 @@ function shouldFoldDefaultSgList(resourceType, key, liveValue, defaultSgIds) {
5574
5576
  if (!Array.isArray(liveValue)) return true;
5575
5577
  return liveValue.length === 1 && typeof liveValue[0] === "string" && defaultSgIds.has(liveValue[0]);
5576
5578
  }
5579
+ function accountDerivedDefault(resourceType, key, ad) {
5580
+ if (!ad) return void 0;
5581
+ if (resourceType === "AWS::ECS::Cluster" && key === "ClusterSettings" && ad.ecsContainerInsights !== void 0) return { value: [{
5582
+ Name: "containerInsights",
5583
+ Value: ad.ecsContainerInsights
5584
+ }] };
5585
+ if (resourceType === "AWS::SSM::Parameter" && key === "Tier" && ad.ssmParameterTier !== void 0) return { value: ad.ssmParameterTier };
5586
+ if (resourceType === "AWS::EC2::Volume" && key === "Encrypted" && ad.ebsEncryptionByDefault !== void 0) return { value: ad.ebsEncryptionByDefault };
5587
+ }
5577
5588
  const stripCognitoAttrPrefix = (id) => id.replace(/^(custom|dev):/, "");
5578
5589
  const IDENTITY_KEYED_SUBSET_ARRAYS = {
5579
5590
  "AWS::Cognito::UserPool": { Schema: {
@@ -6538,6 +6549,10 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6538
6549
  CreditSpecification: { CPUCredits: creditDefault }
6539
6550
  };
6540
6551
  }
6552
+ if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup" && declared["TargetType"] === "lambda") knownDef = {
6553
+ ...knownDef,
6554
+ HealthCheckEnabled: false
6555
+ };
6541
6556
  if (resourceType === "AWS::EC2::Volume") {
6542
6557
  const volumeType = declared["VolumeType"] ?? "gp2";
6543
6558
  const size = declared["Size"];
@@ -7055,6 +7070,17 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7055
7070
  }
7056
7071
  continue;
7057
7072
  }
7073
+ const acctDefault = accountDerivedDefault(resourceType, k, opts.accountDefaults);
7074
+ if (acctDefault !== void 0) {
7075
+ findings.push({
7076
+ tier: matchesKnownDefault(v, acctDefault.value) ? "atDefault" : "undeclared",
7077
+ logicalId,
7078
+ resourceType,
7079
+ path: k,
7080
+ actual: v
7081
+ });
7082
+ continue;
7083
+ }
7058
7084
  if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in schema.defaultPaths && matchesKnownDefault(v, schema.defaultPaths[k]) || k in knownDef && matchesKnownDefault(v, knownDef[k]) || KNOWN_DEFAULT_ONE_OF[resourceType]?.[k]?.some((d) => matchesKnownDefault(v, d)) || VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS[resourceType]?.has(k) && !isTrivialEmpty(v) && !(k in knownDef) || clbDefaultSslPoliciesAtDefault(resourceType, k, v)) {
7059
7085
  findings.push({
7060
7086
  tier: "atDefault",
@@ -12565,6 +12591,51 @@ async function fetchDefaultVpcSubnetIds(region) {
12565
12591
  defaultSubnetIdsCache.set(region, ids);
12566
12592
  return ids;
12567
12593
  }
12594
+ const ecsContainerInsightsCache = /* @__PURE__ */ new Map();
12595
+ async function fetchEcsContainerInsightsDefault(region) {
12596
+ if (ecsContainerInsightsCache.has(region)) return ecsContainerInsightsCache.get(region);
12597
+ try {
12598
+ const value = (await new ECSClient({
12599
+ region,
12600
+ ...READ_RETRY
12601
+ }).send(new ListAccountSettingsCommand({
12602
+ name: "containerInsights",
12603
+ effectiveSettings: true
12604
+ }))).settings?.find((s) => s.name === "containerInsights")?.value;
12605
+ ecsContainerInsightsCache.set(region, value);
12606
+ return value;
12607
+ } catch {
12608
+ return;
12609
+ }
12610
+ }
12611
+ const ssmParameterTierCache = /* @__PURE__ */ new Map();
12612
+ async function fetchSsmDefaultParameterTier(region) {
12613
+ if (ssmParameterTierCache.has(region)) return ssmParameterTierCache.get(region);
12614
+ try {
12615
+ const value = (await new SSMClient({
12616
+ region,
12617
+ ...READ_RETRY
12618
+ }).send(new GetServiceSettingCommand({ SettingId: "/ssm/parameter-store/default-parameter-tier" }))).ServiceSetting?.SettingValue;
12619
+ ssmParameterTierCache.set(region, value);
12620
+ return value;
12621
+ } catch {
12622
+ return;
12623
+ }
12624
+ }
12625
+ const ebsEncryptionByDefaultCache = /* @__PURE__ */ new Map();
12626
+ async function fetchEbsEncryptionByDefault(region) {
12627
+ if (ebsEncryptionByDefaultCache.has(region)) return ebsEncryptionByDefaultCache.get(region);
12628
+ try {
12629
+ const value = (await new EC2Client({
12630
+ region,
12631
+ ...READ_RETRY
12632
+ }).send(new GetEbsEncryptionByDefaultCommand({}))).EbsEncryptionByDefault;
12633
+ ebsEncryptionByDefaultCache.set(region, value);
12634
+ return value;
12635
+ } catch {
12636
+ return;
12637
+ }
12638
+ }
12568
12639
  const kmsDeniedWarned = /* @__PURE__ */ new Set();
12569
12640
  const kmsTransientWarned = /* @__PURE__ */ new Set();
12570
12641
  const POOL_SIZE = 6;
@@ -13142,6 +13213,19 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
13142
13213
  if (desired.resources.some((r) => DEFAULT_SG_LIST_TYPES.has(r.resourceType))) defaultSgIds = await fetchDefaultSgIds(region);
13143
13214
  let defaultSubnetIds = /* @__PURE__ */ new Set();
13144
13215
  if (desired.resources.some((r) => DEFAULT_SUBNET_LIST_TYPES.has(r.resourceType))) defaultSubnetIds = await fetchDefaultVpcSubnetIds(region);
13216
+ const accountDefaults = {};
13217
+ if (desired.resources.some((r) => r.resourceType === "AWS::ECS::Cluster")) {
13218
+ const v = await fetchEcsContainerInsightsDefault(region);
13219
+ if (v !== void 0) accountDefaults.ecsContainerInsights = v;
13220
+ }
13221
+ if (desired.resources.some((r) => r.resourceType === "AWS::SSM::Parameter")) {
13222
+ const v = await fetchSsmDefaultParameterTier(region);
13223
+ if (v !== void 0) accountDefaults.ssmParameterTier = v;
13224
+ }
13225
+ if (desired.resources.some((r) => r.resourceType === "AWS::EC2::Volume")) {
13226
+ const v = await fetchEbsEncryptionByDefault(region);
13227
+ if (v !== void 0) accountDefaults.ebsEncryptionByDefault = v;
13228
+ }
13145
13229
  const classifyOpts = {
13146
13230
  accountId: desired.accountId,
13147
13231
  region,
@@ -13149,6 +13233,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
13149
13233
  stackTags: desired.stackTags ?? {},
13150
13234
  defaultSgIds,
13151
13235
  defaultSubnetIds,
13236
+ accountDefaults,
13152
13237
  oaiCanonicalIds,
13153
13238
  siblingSgRules: buildSiblingSgRules(desired),
13154
13239
  siblingEventBusPolicies: buildSiblingEventBusPolicies(desired),