cdk-real-drift 0.12.82 → 0.12.84

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, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
13
+ import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeInternetGatewaysCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSecurityGroupsCommand, DescribeSubnetsCommand, 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";
@@ -2263,7 +2263,8 @@ const KNOWN_DEFAULTS = {
2263
2263
  UnhealthyThresholdCount: 2,
2264
2264
  ProtocolVersion: "HTTP1",
2265
2265
  IpAddressType: "ipv4",
2266
- Matcher: { HttpCode: "200" }
2266
+ Matcher: { HttpCode: "200" },
2267
+ TargetType: "instance"
2267
2268
  },
2268
2269
  "AWS::ElasticLoadBalancingV2::LoadBalancer": {
2269
2270
  IpAddressType: "ipv4",
@@ -3581,6 +3582,7 @@ const ELB_ATTRIBUTE_DEFAULTS = {
3581
3582
  "load_balancing.algorithm.type": "round_robin",
3582
3583
  "load_balancing.cross_zone.enabled": "use_load_balancer_configuration",
3583
3584
  "slow_start.duration_seconds": "0",
3585
+ "stickiness.enabled": "false",
3584
3586
  "stickiness.app_cookie.duration_seconds": "86400",
3585
3587
  "stickiness.lb_cookie.duration_seconds": "86400",
3586
3588
  "stickiness.type": "lb_cookie",
@@ -3653,6 +3655,17 @@ const CASE_INSENSITIVE_PATHS = {
3653
3655
  "AWS::EMRServerless::Application": new Set(["Type"]),
3654
3656
  "AWS::RDS::DBInstance": new Set(["DBInstanceIdentifier"]),
3655
3657
  "AWS::RDS::DBCluster": new Set(["DBClusterIdentifier"]),
3658
+ "AWS::ElastiCache::SubnetGroup": new Set(["CacheSubnetGroupName"]),
3659
+ "AWS::ElastiCache::ReplicationGroup": new Set(["ReplicationGroupId"]),
3660
+ "AWS::ElastiCache::CacheCluster": new Set(["ClusterName"]),
3661
+ "AWS::DocDB::DBCluster": new Set(["DBClusterIdentifier"]),
3662
+ "AWS::DocDB::DBInstance": new Set(["DBInstanceIdentifier"]),
3663
+ "AWS::DocDB::DBSubnetGroup": new Set(["DBSubnetGroupName"]),
3664
+ "AWS::Neptune::DBCluster": new Set(["DBClusterIdentifier"]),
3665
+ "AWS::Neptune::DBInstance": new Set(["DBInstanceIdentifier"]),
3666
+ "AWS::Neptune::DBSubnetGroup": new Set(["DBSubnetGroupName"]),
3667
+ "AWS::DMS::ReplicationInstance": new Set(["ReplicationInstanceIdentifier"]),
3668
+ "AWS::DMS::ReplicationSubnetGroup": new Set(["ReplicationSubnetGroupIdentifier"]),
3656
3669
  "AWS::DMS::Endpoint": new Set(["EndpointType"]),
3657
3670
  "AWS::WAFv2::LoggingConfiguration": new Set(["RedactedFields.*.SingleHeader.Name"]),
3658
3671
  "AWS::ElasticLoadBalancing::LoadBalancer": new Set(["Listeners.*.Protocol", "Listeners.*.InstanceProtocol"]),
@@ -6340,6 +6353,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6340
6353
  const sfnDefinitionSubstitutions = resourceType === "AWS::StepFunctions::StateMachine" && isNestedObject(declared["DefinitionSubstitutions"]) ? declared["DefinitionSubstitutions"] : void 0;
6341
6354
  deepStripPaths(declared, schema.writeOnlyPaths);
6342
6355
  if (sfnDefinitionSubstitutions !== void 0 && typeof declared["DefinitionString"] === "string") declared["DefinitionString"] = applyDefinitionSubstitutions(declared["DefinitionString"], sfnDefinitionSubstitutions);
6356
+ if (resourceType === "AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation" && typeof physicalId === "string") {
6357
+ const [appArn, attrArn] = physicalId.split("|");
6358
+ const derivedIds = {
6359
+ Application: appArn?.split("/").pop(),
6360
+ AttributeGroup: attrArn?.split("/").pop()
6361
+ };
6362
+ for (const [key, id] of Object.entries(derivedIds)) if (id && typeof declared[key] === "string" && declared[key] !== id && live[key] === id) declared[key] = id;
6363
+ }
6343
6364
  const sibling = resource.siblingPolicyNames;
6344
6365
  if (sibling !== void 0 && sibling !== "unresolved" && Array.isArray(live.Policies)) {
6345
6366
  const names = new Set(sibling);
@@ -6550,6 +6571,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6550
6571
  ...knownDef,
6551
6572
  CreditSpecification: { CPUCredits: creditDefault }
6552
6573
  };
6574
+ const imds = opts.accountDefaults?.instanceMetadataDefaults;
6575
+ if (imds !== void 0 && isNestedObject(knownDef.MetadataOptions)) knownDef = {
6576
+ ...knownDef,
6577
+ MetadataOptions: {
6578
+ ...knownDef.MetadataOptions,
6579
+ ...imds
6580
+ }
6581
+ };
6553
6582
  }
6554
6583
  if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup" && declared["TargetType"] === "lambda") knownDef = {
6555
6584
  ...knownDef,
@@ -7093,6 +7122,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7093
7122
  });
7094
7123
  continue;
7095
7124
  }
7125
+ if (resourceType === "AWS::EC2::Subnet" && (k === "AvailabilityZone" || k === "AvailabilityZoneId") && !("AvailabilityZone" in declared) && !("AvailabilityZoneId" in declared)) {
7126
+ findings.push({
7127
+ tier: "atDefault",
7128
+ logicalId,
7129
+ resourceType,
7130
+ path: k,
7131
+ actual: v
7132
+ });
7133
+ continue;
7134
+ }
7096
7135
  const ctxKind = CONTEXT_DEFAULTS[resourceType]?.[k];
7097
7136
  if (ctxKind !== void 0 && opts.region !== void 0) {
7098
7137
  if (deepEqual(v, ctxKind === "region" ? opts.region : [opts.region])) {
@@ -10493,8 +10532,8 @@ const readCodeBuildReportGroup = async ({ physicalId, region }) => {
10493
10532
  const readEc2NetworkAclEntry = async ({ declared, region }) => {
10494
10533
  const naclId = str$1(declared.NetworkAclId);
10495
10534
  const ruleNumber = declared.RuleNumber;
10496
- const egress = declared.Egress;
10497
- if (!naclId || typeof ruleNumber !== "number" || typeof egress !== "boolean") return void 0;
10535
+ const egress = typeof declared.Egress === "boolean" ? declared.Egress : false;
10536
+ if (!naclId || typeof ruleNumber !== "number") return void 0;
10498
10537
  const nacl = (await new EC2Client({
10499
10538
  region,
10500
10539
  ...READ_RETRY
@@ -12679,6 +12718,26 @@ async function fetchRdsDefaultCaIdentifier(region) {
12679
12718
  return;
12680
12719
  }
12681
12720
  }
12721
+ const instanceMetadataDefaultsCache = /* @__PURE__ */ new Map();
12722
+ async function fetchInstanceMetadataDefaults(region) {
12723
+ if (instanceMetadataDefaultsCache.has(region)) return instanceMetadataDefaultsCache.get(region);
12724
+ try {
12725
+ const al = (await new EC2Client({
12726
+ region,
12727
+ ...READ_RETRY
12728
+ }).send(new GetInstanceMetadataDefaultsCommand({}))).AccountLevel;
12729
+ const out = {};
12730
+ if (al?.HttpTokens != null) out.HttpTokens = al.HttpTokens;
12731
+ if (al?.HttpPutResponseHopLimit != null) out.HttpPutResponseHopLimit = al.HttpPutResponseHopLimit;
12732
+ if (al?.HttpEndpoint != null) out.HttpEndpoint = al.HttpEndpoint;
12733
+ if (al?.InstanceMetadataTags != null) out.InstanceMetadataTags = al.InstanceMetadataTags;
12734
+ const value = Object.keys(out).length > 0 ? out : void 0;
12735
+ instanceMetadataDefaultsCache.set(region, value);
12736
+ return value;
12737
+ } catch {
12738
+ return;
12739
+ }
12740
+ }
12682
12741
  const kmsDeniedWarned = /* @__PURE__ */ new Set();
12683
12742
  const kmsTransientWarned = /* @__PURE__ */ new Set();
12684
12743
  const POOL_SIZE = 6;
@@ -13284,6 +13343,10 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
13284
13343
  }
13285
13344
  if (Object.keys(map).length > 0) accountDefaults.ec2FamilyCreditDefaults = map;
13286
13345
  }
13346
+ if (desired.resources.some((r) => r.resourceType === "AWS::EC2::Instance")) {
13347
+ const v = await fetchInstanceMetadataDefaults(region);
13348
+ if (v !== void 0) accountDefaults.instanceMetadataDefaults = v;
13349
+ }
13287
13350
  if (desired.resources.some((r) => r.resourceType === "AWS::RDS::DBInstance" || r.resourceType === "AWS::DocDB::DBInstance")) {
13288
13351
  const v = await fetchRdsDefaultCaIdentifier(region);
13289
13352
  if (v !== void 0) accountDefaults.rdsDefaultCaIdentifier = v;