cdk-real-drift 0.12.83 → 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";
@@ -6571,6 +6571,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6571
6571
  ...knownDef,
6572
6572
  CreditSpecification: { CPUCredits: creditDefault }
6573
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
+ };
6574
6582
  }
6575
6583
  if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup" && declared["TargetType"] === "lambda") knownDef = {
6576
6584
  ...knownDef,
@@ -12710,6 +12718,26 @@ async function fetchRdsDefaultCaIdentifier(region) {
12710
12718
  return;
12711
12719
  }
12712
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
+ }
12713
12741
  const kmsDeniedWarned = /* @__PURE__ */ new Set();
12714
12742
  const kmsTransientWarned = /* @__PURE__ */ new Set();
12715
12743
  const POOL_SIZE = 6;
@@ -13315,6 +13343,10 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
13315
13343
  }
13316
13344
  if (Object.keys(map).length > 0) accountDefaults.ec2FamilyCreditDefaults = map;
13317
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
+ }
13318
13350
  if (desired.resources.some((r) => r.resourceType === "AWS::RDS::DBInstance" || r.resourceType === "AWS::DocDB::DBInstance")) {
13319
13351
  const v = await fetchRdsDefaultCaIdentifier(region);
13320
13352
  if (v !== void 0) accountDefaults.rdsDefaultCaIdentifier = v;