cdk-real-drift 0.23.4 → 0.23.5

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
@@ -1923,10 +1923,16 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1923
1923
  const gaListenerPort = typeof listenerArn === "string" && opts.siblingListenerPorts?.[listenerArn] !== void 0 ? { [listenerArn]: opts.siblingListenerPorts[listenerArn] } : void 0;
1924
1924
  const dmsClass = resource.resourceType === "AWS::DMS::ReplicationInstance" ? resource.declared?.ReplicationInstanceClass : void 0;
1925
1925
  const dmsStorageDefault = typeof dmsClass === "string" && opts.accountDefaults?.dmsAllocatedStorageDefaults?.[dmsClass] !== void 0 ? { dmsAllocatedStorageDefaults: { [dmsClass]: opts.accountDefaults.dmsAllocatedStorageDefaults[dmsClass] } } : void 0;
1926
+ const ebsEncDefault = resource.resourceType === "AWS::EC2::Volume" && opts.accountDefaults?.ebsEncryptionByDefault !== void 0 ? { ebsEncryptionByDefault: opts.accountDefaults.ebsEncryptionByDefault } : void 0;
1926
1927
  const cvpnVpcMap = opts.siblingClientVpnEndpointVpcs;
1927
1928
  const cvpnVpcKey = resource.resourceType !== "AWS::EC2::ClientVpnEndpoint" || cvpnVpcMap === void 0 ? void 0 : resource.logicalId in cvpnVpcMap ? resource.logicalId : resource.physicalId !== void 0 && resource.physicalId in cvpnVpcMap ? resource.physicalId : void 0;
1928
1929
  const cfCdMap = opts.siblingCloudFrontCdPolicyIds;
1929
1930
  const cfCdKey = resource.resourceType !== "AWS::CloudFront::Distribution" || cfCdMap === void 0 ? void 0 : resource.logicalId in cfCdMap ? resource.logicalId : resource.physicalId !== void 0 && resource.physicalId in cfCdMap ? resource.physicalId : void 0;
1931
+ const rdsSrcMap = opts.siblingRdsSourceModels;
1932
+ const rdsSrcKey = resource.resourceType === "AWS::RDS::DBInstance" && rdsSrcMap !== void 0 ? (() => {
1933
+ const srcId = resource.declared?.["SourceDBInstanceIdentifier"];
1934
+ return typeof srcId === "string" && srcId in rdsSrcMap ? srcId : void 0;
1935
+ })() : void 0;
1930
1936
  return sanitizeAccountId({
1931
1937
  corpusVersion: 1,
1932
1938
  resource: {
@@ -1965,9 +1971,13 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1965
1971
  ...echoModel && resource.physicalId ? { clusterEchoModel: { [resource.physicalId]: echoModel } } : {},
1966
1972
  ...rdsOptCatalog && resource.physicalId ? { rdsOptionSettingDefaults: { [resource.physicalId]: rdsOptCatalog } } : {},
1967
1973
  ...gaListenerPort ? { siblingListenerPorts: gaListenerPort } : {},
1968
- ...dmsStorageDefault ? { accountDefaults: dmsStorageDefault } : {},
1974
+ ...dmsStorageDefault || ebsEncDefault ? { accountDefaults: {
1975
+ ...dmsStorageDefault ?? {},
1976
+ ...ebsEncDefault ?? {}
1977
+ } } : {},
1969
1978
  ...cvpnVpcKey !== void 0 && cvpnVpcMap !== void 0 ? { siblingClientVpnEndpointVpcs: { [cvpnVpcKey]: cvpnVpcMap[cvpnVpcKey] ?? null } } : {},
1970
- ...cfCdKey !== void 0 && cfCdMap !== void 0 ? { siblingCloudFrontCdPolicyIds: { [cfCdKey]: cfCdMap[cfCdKey] ?? null } } : {}
1979
+ ...cfCdKey !== void 0 && cfCdMap !== void 0 ? { siblingCloudFrontCdPolicyIds: { [cfCdKey]: cfCdMap[cfCdKey] ?? null } } : {},
1980
+ ...rdsSrcKey !== void 0 && rdsSrcMap !== void 0 && rdsSrcMap[rdsSrcKey] ? { siblingRdsSourceModels: { [rdsSrcKey]: rdsSrcMap[rdsSrcKey] } } : {}
1971
1981
  },
1972
1982
  expected: findings
1973
1983
  }, opts.accountId);
@@ -2761,6 +2771,7 @@ const KNOWN_DEFAULTS = {
2761
2771
  InstanceLifecyclePolicy: { RetentionTriggers: { TerminateHookAbandon: "terminate" } },
2762
2772
  CapacityReservationSpecification: { CapacityReservationPreference: "default" }
2763
2773
  },
2774
+ "AWS::EC2::Volume": { VolumeType: "gp2" },
2764
2775
  "AWS::AutoScaling::WarmPool": { MinSize: 0 },
2765
2776
  "AWS::AutoScaling::ScheduledAction": { EndTime: "null" },
2766
2777
  "AWS::DocDB::DBCluster": {
@@ -2970,7 +2981,8 @@ const KNOWN_DEFAULTS = {
2970
2981
  WriteUnitsPerSecond: 4e3
2971
2982
  },
2972
2983
  EncryptionSpecification: { EncryptionType: "AWS_OWNED_KMS_KEY" },
2973
- CdcSpecification: { Status: "DISABLED" }
2984
+ CdcSpecification: { Status: "DISABLED" },
2985
+ DefaultTimeToLive: 0
2974
2986
  },
2975
2987
  "AWS::EMRServerless::Application": {
2976
2988
  Architecture: "X86_64",
@@ -3004,6 +3016,21 @@ const KNOWN_DEFAULT_ONE_OF_PATHS = {
3004
3016
  "AWS::OpenSearchService::Domain": { "EBSOptions.VolumeType": ["gp3", "gp2"] }
3005
3017
  };
3006
3018
  const KNOWN_DEFAULT_PATHS = {
3019
+ "AWS::AutoScaling::AutoScalingGroup": { "MixedInstancesPolicy.InstancesDistribution": {
3020
+ OnDemandAllocationStrategy: "prioritized",
3021
+ OnDemandBaseCapacity: 0,
3022
+ OnDemandPercentageAboveBaseCapacity: 100,
3023
+ SpotAllocationStrategy: "lowest-price",
3024
+ SpotInstancePools: 2
3025
+ } },
3026
+ "AWS::ElasticLoadBalancingV2::Listener": { "MutualAuthentication.AdvertiseTrustStoreCaNames": "off" },
3027
+ "AWS::GuardDuty::Detector": {
3028
+ "DataSources.S3Logs": { Enable: true },
3029
+ "DataSources.Kubernetes": { AuditLogs: { Enable: true } },
3030
+ "DataSources.Kubernetes.AuditLogs": { Enable: true },
3031
+ "DataSources.MalwareProtection": { ScanEc2InstanceWithFindings: { EbsVolumes: true } },
3032
+ "DataSources.MalwareProtection.ScanEc2InstanceWithFindings": { EbsVolumes: true }
3033
+ },
3007
3034
  "AWS::Backup::RestoreTestingPlan": { "RecoveryPointSelection.SelectionWindowDays": 30 },
3008
3035
  "AWS::Budgets::Budget": {
3009
3036
  "Budget.CostTypes": {
@@ -3111,6 +3138,7 @@ const KNOWN_DEFAULT_PATHS = {
3111
3138
  "AdminCreateUserConfig.UnusedAccountValidityDays": 7,
3112
3139
  "Policies.SignInPolicy": { AllowedFirstAuthFactors: ["PASSWORD"] },
3113
3140
  "Policies.PasswordPolicy.TemporaryPasswordValidityDays": 7,
3141
+ "Policies.PasswordPolicy.MinimumLength": 8,
3114
3142
  "Schema.*.AttributeDataType": "String",
3115
3143
  "Schema.*.StringAttributeConstraints": {
3116
3144
  MinLength: "0",
@@ -3473,7 +3501,7 @@ const GENERATED_NESTED_PATHS = {
3473
3501
  "AWS::ApiGateway::Stage": new Set(["CanarySetting.DeploymentId"]),
3474
3502
  "AWS::DynamoDB::Table": new Set(["SSESpecification.KMSMasterKeyId"]),
3475
3503
  "AWS::DynamoDB::GlobalTable": new Set(["Replicas.*.SSESpecification.KMSMasterKeyId"]),
3476
- "AWS::AutoScaling::AutoScalingGroup": new Set(["LaunchTemplate.LaunchTemplateName"]),
3504
+ "AWS::AutoScaling::AutoScalingGroup": new Set(["LaunchTemplate.LaunchTemplateName", "MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.LaunchTemplateName"]),
3477
3505
  "AWS::MSK::Cluster": new Set(["EncryptionInfo.EncryptionAtRest", "BrokerNodeGroupInfo.SecurityGroups"]),
3478
3506
  "AWS::ElasticBeanstalk::Application": new Set(["ResourceLifecycleConfig.ServiceRole"])
3479
3507
  };
@@ -3700,7 +3728,8 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
3700
3728
  "AWS::ElastiCache::CacheCluster": new Set([
3701
3729
  "PreferredMaintenanceWindow",
3702
3730
  "SnapshotWindow",
3703
- "PreferredAvailabilityZones"
3731
+ "PreferredAvailabilityZones",
3732
+ "EngineVersion"
3704
3733
  ]),
3705
3734
  "AWS::ElastiCache::ReplicationGroup": new Set([
3706
3735
  "PreferredMaintenanceWindow",
@@ -6034,6 +6063,13 @@ const MEANINGFUL_WHEN_OFF_NESTED = {
6034
6063
  },
6035
6064
  "AWS::EKS::Cluster": { "ResourcesVpcConfig.EndpointPublicAccess": () => true },
6036
6065
  "AWS::Budgets::Budget": { "Budget.CostTypes": () => true },
6066
+ "AWS::GuardDuty::Detector": {
6067
+ "DataSources.S3Logs": () => true,
6068
+ "DataSources.Kubernetes": () => true,
6069
+ "DataSources.Kubernetes.AuditLogs": () => true,
6070
+ "DataSources.MalwareProtection": () => true,
6071
+ "DataSources.MalwareProtection.ScanEc2InstanceWithFindings": () => true
6072
+ },
6037
6073
  "AWS::ECS::Service": { "DeploymentConfiguration.DeploymentCircuitBreaker.ResetOnHealthyTask": ({ declared, live }) => {
6038
6074
  const enabled = (v) => typeof v === "object" && v !== null && v["DeploymentCircuitBreaker"]?.["Enable"] === true;
6039
6075
  return enabled(declared["DeploymentConfiguration"]) || enabled(live["DeploymentConfiguration"]);
@@ -6077,7 +6113,8 @@ const DEFAULT_SG_LIST_PATHS = {
6077
6113
  "AWS::DAX::Cluster": "SecurityGroupIds",
6078
6114
  "AWS::DMS::ReplicationInstance": "VpcSecurityGroupIds",
6079
6115
  "AWS::EC2::ClientVpnEndpoint": "SecurityGroupIds",
6080
- "AWS::VpcLattice::ResourceGateway": "SecurityGroupIds"
6116
+ "AWS::VpcLattice::ResourceGateway": "SecurityGroupIds",
6117
+ "AWS::EC2::VPCEndpoint": "SecurityGroupIds"
6081
6118
  };
6082
6119
  /** #1269 fold decision for an UNDECLARED default-SUBNET list (RedshiftServerless Workgroup
6083
6120
  * SubnetIds). Unlike the SG gate (which folds only a SINGLE default SG), a workgroup placed into
@@ -7073,6 +7110,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7073
7110
  ClusterMode: declared["ClusterMode"],
7074
7111
  Engine: declared["Engine"]
7075
7112
  } : void 0;
7113
+ const rdsReplicaSourceId = resourceType === "AWS::RDS::DBInstance" && typeof declared["SourceDBInstanceIdentifier"] === "string" && declared["SourceDBInstanceIdentifier"] !== "" ? declared["SourceDBInstanceIdentifier"] : void 0;
7076
7114
  deepStripPaths(declared, schema.writeOnlyPaths);
7077
7115
  if (sfnDefinitionSubstitutions !== void 0 && typeof declared["DefinitionString"] === "string") declared["DefinitionString"] = applyDefinitionSubstitutions(declared["DefinitionString"], sfnDefinitionSubstitutions);
7078
7116
  if (resourceType === "AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation" && typeof physicalId === "string") {
@@ -7112,6 +7150,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7112
7150
  HealthCheckTimeoutSeconds: 6,
7113
7151
  Matcher: { HttpCode: "200-399" }
7114
7152
  } : {},
7153
+ ...protocol === "GENEVE" ? {
7154
+ HealthCheckProtocol: "TCP",
7155
+ HealthCheckPort: "80"
7156
+ } : {},
7157
+ ...protocol === "HTTPS" ? { HealthCheckProtocol: "HTTPS" } : {},
7115
7158
  ...protocolVersion === "GRPC" ? { Matcher: { GrpcCode: "12" } } : {}
7116
7159
  };
7117
7160
  }
@@ -7263,6 +7306,45 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7263
7306
  })
7264
7307
  };
7265
7308
  }
7309
+ if (resourceType === "AWS::Cassandra::Table") {
7310
+ const pt = declared["BillingMode"]?.["ProvisionedThroughput"];
7311
+ const rcu = pt?.["ReadCapacityUnits"];
7312
+ const wcu = pt?.["WriteCapacityUnits"];
7313
+ if (typeof rcu === "number" && typeof wcu === "number") knownDef = {
7314
+ ...knownDef,
7315
+ WarmThroughput: {
7316
+ ReadUnitsPerSecond: rcu,
7317
+ WriteUnitsPerSecond: wcu
7318
+ }
7319
+ };
7320
+ }
7321
+ if (resourceType === "AWS::RDS::DBInstance" && rdsReplicaSourceId !== void 0) {
7322
+ knownDef = {
7323
+ ...knownDef,
7324
+ BackupRetentionPeriod: 0
7325
+ };
7326
+ const src = opts.siblingRdsSourceModels?.[rdsReplicaSourceId];
7327
+ if (src) {
7328
+ const inherit = {};
7329
+ for (const k of [
7330
+ "Engine",
7331
+ "AllocatedStorage",
7332
+ "MasterUsername"
7333
+ ]) if (src[k] !== void 0) inherit[k] = src[k];
7334
+ knownDef = {
7335
+ ...knownDef,
7336
+ ...inherit
7337
+ };
7338
+ }
7339
+ }
7340
+ if (resourceType === "AWS::Route53::HealthCheck") {
7341
+ const hcType = declared["HealthCheckConfig"]?.["Type"];
7342
+ const defaultPort = hcType === "HTTP" || hcType === "HTTP_STR_MATCH" ? 80 : hcType === "HTTPS" || hcType === "HTTPS_STR_MATCH" ? 443 : void 0;
7343
+ if (defaultPort !== void 0) knownDefPaths = {
7344
+ ...knownDefPaths,
7345
+ "HealthCheckConfig.Port": defaultPort
7346
+ };
7347
+ }
7266
7348
  if (resourceType === "AWS::ApiGateway::RestApi") {
7267
7349
  const types = declared["EndpointConfiguration"]?.["Types"];
7268
7350
  if (Array.isArray(types) && types.includes("PRIVATE")) {
@@ -14369,7 +14451,8 @@ const DEFAULT_SG_LIST_TYPES = new Set([
14369
14451
  "AWS::DAX::Cluster",
14370
14452
  "AWS::DMS::ReplicationInstance",
14371
14453
  "AWS::EC2::ClientVpnEndpoint",
14372
- "AWS::VpcLattice::ResourceGateway"
14454
+ "AWS::VpcLattice::ResourceGateway",
14455
+ "AWS::EC2::VPCEndpoint"
14373
14456
  ]);
14374
14457
  const DEFAULT_SUBNET_LIST_TYPES = new Set(["AWS::RedshiftServerless::Workgroup"]);
14375
14458
  const defaultSgIdsCache = /* @__PURE__ */ new Map();
@@ -14976,6 +15059,17 @@ function buildClientVpnEndpointSiblingVpcs(desired) {
14976
15059
  }
14977
15060
  return out;
14978
15061
  }
15062
+ function buildRdsReplicaSourceModels(desired, liveByLogical) {
15063
+ const out = {};
15064
+ for (const r of desired.resources) {
15065
+ if (r.resourceType !== "AWS::RDS::DBInstance") continue;
15066
+ const live = liveByLogical?.get(r.logicalId);
15067
+ if (!live) continue;
15068
+ const id = live["DBInstanceIdentifier"] ?? r.physicalId;
15069
+ if (typeof id === "string" && id !== "") out[id] = live;
15070
+ }
15071
+ return out;
15072
+ }
14979
15073
  function buildCloudFrontStagingDistCdPolicyIds(desired, liveByLogical) {
14980
15074
  const refLogicalId = (ref) => {
14981
15075
  if (ref && typeof ref === "object") {
@@ -15442,6 +15536,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
15442
15536
  scalableTargetBands: buildScalableTargetBands(desired),
15443
15537
  siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
15444
15538
  siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
15539
+ siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, liveModelMap(reads)),
15445
15540
  rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
15446
15541
  };
15447
15542
  const corpusDir = process.env[CORPUS_DIR_ENV];
@@ -15520,6 +15615,7 @@ async function regatherTouched(gathered, touched, region) {
15520
15615
  scalableTargetBands: buildScalableTargetBands(desired),
15521
15616
  siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
15522
15617
  siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
15618
+ siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, liveModelMap(reads)),
15523
15619
  rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
15524
15620
  };
15525
15621
  const fresh = [];
@@ -19534,6 +19630,8 @@ const REVERT_SET_DEFAULT_PATHS = new Set([
19534
19630
  "AWS::RUM::AppMonitor\0CustomEvents",
19535
19631
  "AWS::RUM::AppMonitor\0AppMonitorConfiguration",
19536
19632
  "AWS::GuardDuty::Filter\0Action",
19633
+ "AWS::GuardDuty::ThreatEntitySet\0ExpectedBucketOwner",
19634
+ "AWS::GuardDuty::TrustedEntitySet\0ExpectedBucketOwner",
19537
19635
  "AWS::ServiceCatalog::TagOption\0Active",
19538
19636
  "AWS::VpcLattice::ResourceConfiguration\0AllowAssociationToSharableServiceNetwork",
19539
19637
  "AWS::Backup::RestoreTestingPlan\0StartWindowHours",
@@ -19968,7 +20066,7 @@ function buildRevertPlan(findings, baseline, opts = {}) {
19968
20066
  desired: [...f.desired, ...sib]
19969
20067
  };
19970
20068
  }
19971
- const op = revertOp(toRevert, recorded);
20069
+ const op = revertOp(toRevert, recorded, opts.identity);
19972
20070
  const key = `${f.logicalId} ${kind}${propScoped ? ` ${f.path}` : ""}`;
19973
20071
  const item = itemsByLogical.get(key) ?? {
19974
20072
  logicalId: f.logicalId,
@@ -20009,7 +20107,16 @@ function coerceDeclaredScalar(desired, live) {
20009
20107
  }
20010
20108
  return desired;
20011
20109
  }
20012
- function revertOp(f, recorded) {
20110
+ function contextArnDefaultFor(resourceType, path, identity) {
20111
+ const template = CONTEXT_ARN_DEFAULTS[resourceType]?.[path];
20112
+ if (template === void 0) return void 0;
20113
+ const { accountId, region } = identity ?? {};
20114
+ if (accountId === void 0 || accountId === "" || region === void 0 || region === "") return;
20115
+ const partition = partitionForRegion(region).partition;
20116
+ const substitute = (t) => t.replace("{partition}", partition).replace("{region}", region).replace("{accountId}", accountId);
20117
+ return Array.isArray(template) ? template.map(substitute) : substitute(template);
20118
+ }
20119
+ function revertOp(f, recorded, identity) {
20013
20120
  const pointer = toPointer(f.path);
20014
20121
  if (f.tier === "declared") return {
20015
20122
  op: "add",
@@ -20034,7 +20141,7 @@ function revertOp(f, recorded) {
20034
20141
  human: `${f.path} -> baseline value`
20035
20142
  };
20036
20143
  const setDefaultKey = `${f.resourceType}\0${f.path}`;
20037
- const knownDefault = KNOWN_DEFAULTS[f.resourceType]?.[f.path] ?? REVERT_SET_DEFAULT_VALUES[setDefaultKey];
20144
+ const knownDefault = KNOWN_DEFAULTS[f.resourceType]?.[f.path] ?? REVERT_SET_DEFAULT_VALUES[setDefaultKey] ?? contextArnDefaultFor(f.resourceType, f.path, identity);
20038
20145
  if (knownDefault !== void 0 && REVERT_SET_DEFAULT_PATHS.has(setDefaultKey)) return {
20039
20146
  op: "add",
20040
20147
  path: pointer,
@@ -21068,7 +21175,11 @@ async function revertStack(p) {
21068
21175
  siblingSgRules: buildSiblingSgRules(gathered.desired),
21069
21176
  stackName,
21070
21177
  liveByLogical: gathered.liveByLogical,
21071
- maskReadGapKeys: maskReadGapKeysOf(reconciled)
21178
+ maskReadGapKeys: maskReadGapKeysOf(reconciled),
21179
+ identity: {
21180
+ accountId: gathered.desired.accountId,
21181
+ region
21182
+ }
21072
21183
  });
21073
21184
  if (plan.items.length === 0 && plan.notRevertable.length === 0) {
21074
21185
  out(style.clean(`${stackName} (${region}): no drift to revert.`));