cdk-real-drift 0.2.29 → 0.2.31

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
@@ -5,7 +5,7 @@ import { dirname, join, resolve } from "node:path";
5
5
  import { YAMLSeq, isSeq, parse, parseDocument } from "yaml";
6
6
  import { CloudControlClient, DeleteResourceCommand, GetResourceCommand, GetResourceRequestStatusCommand, UpdateResourceCommand } from "@aws-sdk/client-cloudcontrol";
7
7
  import { BaseCredentials, CdkAppMultiContext, NonInteractiveIoHost, Toolkit } from "@aws-cdk/toolkit-lib";
8
- import { CloudFormationClient, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
8
+ import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
9
9
  import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
10
10
  import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
11
11
  import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
@@ -1532,7 +1532,11 @@ const KNOWN_DEFAULTS = {
1532
1532
  "AWS::AutoScaling::AutoScalingGroup": {
1533
1533
  Cooldown: "300",
1534
1534
  HealthCheckType: "EC2",
1535
- HealthCheckGracePeriod: 0
1535
+ HealthCheckGracePeriod: 0,
1536
+ TerminationPolicies: ["Default"],
1537
+ AvailabilityZoneDistribution: { CapacityDistributionStrategy: "balanced-best-effort" },
1538
+ InstanceLifecyclePolicy: { RetentionTriggers: { TerminateHookAbandon: "terminate" } },
1539
+ CapacityReservationSpecification: { CapacityReservationPreference: "default" }
1536
1540
  },
1537
1541
  "AWS::AutoScaling::WarmPool": { MinSize: 0 },
1538
1542
  "AWS::DocDB::DBCluster": {
@@ -1943,7 +1947,8 @@ const GENERATED_PATHS = {
1943
1947
  const CONTEXT_DEFAULTS = { "AWS::EC2::VPCEndpointService": { SupportedRegions: "regionList" } };
1944
1948
  const CONTEXT_ARN_DEFAULTS = {
1945
1949
  "AWS::ResourceExplorer2::View": { Scope: "arn:{partition}:iam::{accountId}:root" },
1946
- "AWS::KinesisVideo::Stream": { KmsKeyId: "arn:{partition}:kms:{region}:{accountId}:alias/aws/kinesisvideo" }
1950
+ "AWS::KinesisVideo::Stream": { KmsKeyId: "arn:{partition}:kms:{region}:{accountId}:alias/aws/kinesisvideo" },
1951
+ "AWS::AutoScaling::AutoScalingGroup": { ServiceLinkedRoleARN: "arn:{partition}:iam::{accountId}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling" }
1947
1952
  };
1948
1953
  const ENGINE_DEFAULTS = {
1949
1954
  "AWS::RDS::DBInstance": {
@@ -2003,7 +2008,8 @@ const GENERATED_LOGICALID_PREFIX_PATHS = {
2003
2008
  "AWS::Cognito::UserPoolClient": new Set(["ClientName"]),
2004
2009
  "AWS::Cognito::IdentityPool": new Set(["IdentityPoolName"]),
2005
2010
  "AWS::Cognito::UserPool": new Set(["UserPoolName"]),
2006
- "AWS::Batch::JobDefinition": new Set(["JobDefinitionName"])
2011
+ "AWS::Batch::JobDefinition": new Set(["JobDefinitionName"]),
2012
+ "AWS::EC2::LaunchTemplate": new Set(["LaunchTemplateName"])
2007
2013
  };
2008
2014
  const CFN_LOGICALID_RANDOM = /[-_][0-9A-Za-z]{12,}$/;
2009
2015
  function isLogicalIdPrefixedGeneratedName(value, logicalId) {
@@ -2016,7 +2022,8 @@ const GENERATED_NESTED_PATHS = {
2016
2022
  "AWS::OpenSearchService::Domain": new Set(["EncryptionAtRestOptions.KmsKeyId"]),
2017
2023
  "AWS::ApiGateway::Stage": new Set(["CanarySetting.DeploymentId"]),
2018
2024
  "AWS::DynamoDB::Table": new Set(["SSESpecification.KMSMasterKeyId"]),
2019
- "AWS::DynamoDB::GlobalTable": new Set(["Replicas.*.SSESpecification.KMSMasterKeyId"])
2025
+ "AWS::DynamoDB::GlobalTable": new Set(["Replicas.*.SSESpecification.KMSMasterKeyId"]),
2026
+ "AWS::AutoScaling::AutoScalingGroup": new Set(["LaunchTemplate.LaunchTemplateName"])
2020
2027
  };
2021
2028
  const EB_OPTION_DEFAULTS = {
2022
2029
  "aws:autoscaling:asg|Availability Zones": "Any",
@@ -2141,6 +2148,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
2141
2148
  "AWS::ElasticBeanstalk::ConfigurationTemplate": new Set(["PlatformArn"]),
2142
2149
  "AWS::ElasticBeanstalk::Environment": new Set(["PlatformArn"]),
2143
2150
  "AWS::ElasticLoadBalancing::LoadBalancer": new Set(["AvailabilityZones", "Policies"]),
2151
+ "AWS::AutoScaling::AutoScalingGroup": new Set(["AvailabilityZones", "AvailabilityZoneIds"]),
2144
2152
  "AWS::ApiGateway::Authorizer": new Set(["AuthType"]),
2145
2153
  "AWS::RDS::DBCluster": new Set([
2146
2154
  "KmsKeyId",
@@ -8214,6 +8222,20 @@ async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
8214
8222
  };
8215
8223
  }
8216
8224
  }
8225
+ async function isManagedBySiblingStack(cfn, c, cache) {
8226
+ const physicalId = c.identifier;
8227
+ if (physicalId.includes("|")) return false;
8228
+ const cached = cache.get(physicalId);
8229
+ if (cached !== void 0) return cached;
8230
+ let managed = false;
8231
+ try {
8232
+ managed = ((await cfn.send(new DescribeStackResourcesCommand({ PhysicalResourceId: physicalId }))).StackResources ?? []).some((r) => r.PhysicalResourceId === physicalId && r.ResourceType === c.resourceType);
8233
+ } catch {
8234
+ managed = false;
8235
+ }
8236
+ cache.set(physicalId, managed);
8237
+ return managed;
8238
+ }
8217
8239
  const SG_RULE_RESOURCE_SIDE = {
8218
8240
  "AWS::EC2::SecurityGroupIngress": "ingress",
8219
8241
  "AWS::EC2::SecurityGroupEgress": "egress"
@@ -8336,6 +8358,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
8336
8358
  for (const r of desired.resources) if (r.declaredRaw) r.declared = resolveProperties(r.declaredRaw, desired.ctx);
8337
8359
  }
8338
8360
  const oaiCanonicalIds = buildOaiCanonicalIds(desired);
8361
+ const siblingStackCache = /* @__PURE__ */ new Map();
8339
8362
  for (const r of desired.resources) {
8340
8363
  const enumerate = CHILD_ENUMERATORS[r.resourceType];
8341
8364
  if (!enumerate || !r.physicalId) continue;
@@ -8347,6 +8370,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
8347
8370
  region
8348
8371
  });
8349
8372
  for (const c of children) {
8373
+ if (await isManagedBySiblingStack(cfn, c, siblingStackCache)) continue;
8350
8374
  const read = await readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds);
8351
8375
  findings.push(addedFinding(r, c, read));
8352
8376
  }