cdk-real-drift 0.23.5 → 0.23.7

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
@@ -3179,6 +3179,14 @@ const KNOWN_DEFAULT_PATHS = {
3179
3179
  "TableInput.Retention": 0,
3180
3180
  "TableInput.StorageDescriptor.NumberOfBuckets": 0
3181
3181
  },
3182
+ "AWS::AppRunner::Service": {
3183
+ "NetworkConfiguration.IngressConfiguration": { IsPubliclyAccessible: true },
3184
+ "NetworkConfiguration.IpAddressType": "IPV4"
3185
+ },
3186
+ "AWS::ImageBuilder::ImagePipeline": {
3187
+ "ImageTestsConfiguration.ImageTestsEnabled": true,
3188
+ "ImageTestsConfiguration.TimeoutMinutes": 720
3189
+ },
3182
3190
  "AWS::Route53::HealthCheck": {
3183
3191
  "HealthCheckConfig.EnableSNI": true,
3184
3192
  "HealthCheckConfig.RequestInterval": 30,
@@ -4047,16 +4055,39 @@ const CASE_INSENSITIVE_PATHS = {
4047
4055
  "AWS::Batch::ComputeEnvironment": new Set(["Type"]),
4048
4056
  "AWS::Batch::JobDefinition": new Set(["Type"]),
4049
4057
  "AWS::EMRServerless::Application": new Set(["Type"]),
4050
- "AWS::RDS::DBInstance": new Set(["DBInstanceIdentifier"]),
4051
- "AWS::RDS::DBCluster": new Set(["DBClusterIdentifier"]),
4058
+ "AWS::RDS::DBInstance": new Set([
4059
+ "DBInstanceIdentifier",
4060
+ "DBParameterGroupName",
4061
+ "DBSubnetGroupName",
4062
+ "OptionGroupName",
4063
+ "DBClusterIdentifier"
4064
+ ]),
4065
+ "AWS::RDS::DBCluster": new Set([
4066
+ "DBClusterIdentifier",
4067
+ "DBClusterParameterGroupName",
4068
+ "DBSubnetGroupName"
4069
+ ]),
4052
4070
  "AWS::ElastiCache::SubnetGroup": new Set(["CacheSubnetGroupName"]),
4053
- "AWS::ElastiCache::ReplicationGroup": new Set(["ReplicationGroupId"]),
4054
- "AWS::ElastiCache::CacheCluster": new Set(["ClusterName"]),
4055
- "AWS::DocDB::DBCluster": new Set(["DBClusterIdentifier"]),
4056
- "AWS::DocDB::DBInstance": new Set(["DBInstanceIdentifier"]),
4071
+ "AWS::ElastiCache::ReplicationGroup": new Set(["ReplicationGroupId", "CacheSubnetGroupName"]),
4072
+ "AWS::ElastiCache::CacheCluster": new Set(["ClusterName", "CacheSubnetGroupName"]),
4073
+ "AWS::DocDB::DBCluster": new Set([
4074
+ "DBClusterIdentifier",
4075
+ "DBSubnetGroupName",
4076
+ "DBClusterParameterGroupName"
4077
+ ]),
4078
+ "AWS::DocDB::DBInstance": new Set(["DBInstanceIdentifier", "DBClusterIdentifier"]),
4057
4079
  "AWS::DocDB::DBSubnetGroup": new Set(["DBSubnetGroupName"]),
4058
- "AWS::Neptune::DBCluster": new Set(["DBClusterIdentifier"]),
4059
- "AWS::Neptune::DBInstance": new Set(["DBInstanceIdentifier"]),
4080
+ "AWS::Neptune::DBCluster": new Set([
4081
+ "DBClusterIdentifier",
4082
+ "DBSubnetGroupName",
4083
+ "DBClusterParameterGroupName"
4084
+ ]),
4085
+ "AWS::Neptune::DBInstance": new Set([
4086
+ "DBInstanceIdentifier",
4087
+ "DBClusterIdentifier",
4088
+ "DBParameterGroupName",
4089
+ "DBSubnetGroupName"
4090
+ ]),
4060
4091
  "AWS::Neptune::DBSubnetGroup": new Set(["DBSubnetGroupName"]),
4061
4092
  "AWS::RDS::DBParameterGroup": new Set(["DBParameterGroupName"]),
4062
4093
  "AWS::RDS::DBClusterParameterGroup": new Set(["DBClusterParameterGroupName"]),
@@ -4066,8 +4097,12 @@ const CASE_INSENSITIVE_PATHS = {
4066
4097
  "AWS::Neptune::DBClusterParameterGroup": new Set(["Name"]),
4067
4098
  "AWS::DocDB::DBClusterParameterGroup": new Set(["Name"]),
4068
4099
  "AWS::Redshift::ClusterParameterGroup": new Set(["ParameterGroupName"]),
4069
- "AWS::Redshift::Cluster": new Set(["ClusterIdentifier"]),
4070
- "AWS::DMS::ReplicationInstance": new Set(["ReplicationInstanceIdentifier"]),
4100
+ "AWS::Redshift::Cluster": new Set([
4101
+ "ClusterIdentifier",
4102
+ "ClusterParameterGroupName",
4103
+ "ClusterSubnetGroupName"
4104
+ ]),
4105
+ "AWS::DMS::ReplicationInstance": new Set(["ReplicationInstanceIdentifier", "ReplicationSubnetGroupIdentifier"]),
4071
4106
  "AWS::DMS::ReplicationSubnetGroup": new Set(["ReplicationSubnetGroupIdentifier"]),
4072
4107
  "AWS::DAX::ParameterGroup": new Set(["ParameterGroupName"]),
4073
4108
  "AWS::DAX::SubnetGroup": new Set(["SubnetGroupName"]),
@@ -4557,6 +4592,7 @@ function alignNameValueSubset(declared, live, spec) {
4557
4592
  return live.filter((e) => !dm.has(e[spec.nameField]));
4558
4593
  }
4559
4594
  const UNORDERED_ARRAY_PROPS = {
4595
+ "AWS::Route53::CidrCollection": new Set(["Locations.*.CidrList"]),
4560
4596
  "AWS::CloudFront::Distribution": new Set(["DistributionConfig.Restrictions.GeoRestriction.Locations"]),
4561
4597
  "AWS::Cognito::UserPool": new Set(["EnabledMfas"]),
4562
4598
  "AWS::ECS::Cluster": new Set(["CapacityProviders"]),
@@ -5470,6 +5506,23 @@ function isLogGroupArnWildcardMatch(desired, actual) {
5470
5506
  return stripLogGroupWildcard(desired) === stripLogGroupWildcard(actual);
5471
5507
  }
5472
5508
 
5509
+ //#endregion
5510
+ //#region src/normalize/derived-defaults.ts
5511
+ function route53HealthCheckDerivedPort(hcType) {
5512
+ return hcType === "HTTP" || hcType === "HTTP_STR_MATCH" ? 80 : hcType === "HTTPS" || hcType === "HTTPS_STR_MATCH" ? 443 : void 0;
5513
+ }
5514
+ function elbTargetGroupDerivedHealthCheckProtocol(protocol, targetType) {
5515
+ if (protocol === "GENEVE") return "TCP";
5516
+ if (protocol === "HTTPS") return "HTTPS";
5517
+ if ((protocol === "TCP" || protocol === "TLS" || protocol === "UDP" || protocol === "TCP_UDP") && targetType !== "alb") return "TCP";
5518
+ }
5519
+ function elbTargetGroupDerivedHealthCheckPort(protocol) {
5520
+ return protocol === "GENEVE" ? "80" : void 0;
5521
+ }
5522
+ function rdsReplicaDerivedBackupRetention(sourceDbInstanceIdentifier) {
5523
+ return sourceDbInstanceIdentifier !== void 0 ? 0 : void 0;
5524
+ }
5525
+
5473
5526
  //#endregion
5474
5527
  //#region src/read/kms-aliases.ts
5475
5528
  const cache$1 = /* @__PURE__ */ new Map();
@@ -6070,6 +6123,12 @@ const MEANINGFUL_WHEN_OFF_NESTED = {
6070
6123
  "DataSources.MalwareProtection": () => true,
6071
6124
  "DataSources.MalwareProtection.ScanEc2InstanceWithFindings": () => true
6072
6125
  },
6126
+ "AWS::Route53::HealthCheck": { "HealthCheckConfig.EnableSNI": ({ declared, live }) => {
6127
+ const t = (declared["HealthCheckConfig"] ?? live["HealthCheckConfig"])?.["Type"];
6128
+ return t === "HTTPS" || t === "HTTPS_STR_MATCH";
6129
+ } },
6130
+ "AWS::AppRunner::Service": { "NetworkConfiguration.IngressConfiguration": () => true },
6131
+ "AWS::ImageBuilder::ImagePipeline": { "ImageTestsConfiguration.ImageTestsEnabled": () => true },
6073
6132
  "AWS::ECS::Service": { "DeploymentConfiguration.DeploymentCircuitBreaker.ResetOnHealthyTask": ({ declared, live }) => {
6074
6133
  const enabled = (v) => typeof v === "object" && v !== null && v["DeploymentCircuitBreaker"]?.["Enable"] === true;
6075
6134
  return enabled(declared["DeploymentConfiguration"]) || enabled(live["DeploymentConfiguration"]);
@@ -7150,11 +7209,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7150
7209
  HealthCheckTimeoutSeconds: 6,
7151
7210
  Matcher: { HttpCode: "200-399" }
7152
7211
  } : {},
7153
- ...protocol === "GENEVE" ? {
7154
- HealthCheckProtocol: "TCP",
7155
- HealthCheckPort: "80"
7156
- } : {},
7157
- ...protocol === "HTTPS" ? { HealthCheckProtocol: "HTTPS" } : {},
7212
+ ...(() => {
7213
+ const hcProto = elbTargetGroupDerivedHealthCheckProtocol(protocol, targetType);
7214
+ const hcPort = elbTargetGroupDerivedHealthCheckPort(protocol);
7215
+ return {
7216
+ ...hcProto !== void 0 ? { HealthCheckProtocol: hcProto } : {},
7217
+ ...hcPort !== void 0 ? { HealthCheckPort: hcPort } : {}
7218
+ };
7219
+ })(),
7158
7220
  ...protocolVersion === "GRPC" ? { Matcher: { GrpcCode: "12" } } : {}
7159
7221
  };
7160
7222
  }
@@ -7248,7 +7310,6 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7248
7310
  const proto = declared["Protocol"];
7249
7311
  if (typeof proto === "string" && (proto === "TCP" || proto === "TLS" || proto === "UDP" || proto === "TCP_UDP") && declared["TargetType"] !== "alb") knownDef = {
7250
7312
  ...knownDef,
7251
- HealthCheckProtocol: "TCP",
7252
7313
  HealthCheckTimeoutSeconds: 10
7253
7314
  };
7254
7315
  }
@@ -7321,7 +7382,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7321
7382
  if (resourceType === "AWS::RDS::DBInstance" && rdsReplicaSourceId !== void 0) {
7322
7383
  knownDef = {
7323
7384
  ...knownDef,
7324
- BackupRetentionPeriod: 0
7385
+ BackupRetentionPeriod: rdsReplicaDerivedBackupRetention(rdsReplicaSourceId) ?? 0
7325
7386
  };
7326
7387
  const src = opts.siblingRdsSourceModels?.[rdsReplicaSourceId];
7327
7388
  if (src) {
@@ -7329,7 +7390,9 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7329
7390
  for (const k of [
7330
7391
  "Engine",
7331
7392
  "AllocatedStorage",
7332
- "MasterUsername"
7393
+ "MasterUsername",
7394
+ "DBParameterGroupName",
7395
+ "DBSubnetGroupName"
7333
7396
  ]) if (src[k] !== void 0) inherit[k] = src[k];
7334
7397
  knownDef = {
7335
7398
  ...knownDef,
@@ -7339,7 +7402,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7339
7402
  }
7340
7403
  if (resourceType === "AWS::Route53::HealthCheck") {
7341
7404
  const hcType = declared["HealthCheckConfig"]?.["Type"];
7342
- const defaultPort = hcType === "HTTP" || hcType === "HTTP_STR_MATCH" ? 80 : hcType === "HTTPS" || hcType === "HTTPS_STR_MATCH" ? 443 : void 0;
7405
+ const defaultPort = route53HealthCheckDerivedPort(hcType);
7343
7406
  if (defaultPort !== void 0) knownDefPaths = {
7344
7407
  ...knownDefPaths,
7345
7408
  "HealthCheckConfig.Port": defaultPort
@@ -7478,7 +7541,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
7478
7541
  });
7479
7542
  };
7480
7543
  const allLeavesAtSchemaDefault = (value, basePath) => {
7481
- if (isTrivialEmpty(value)) return true;
7544
+ if (isTrivialEmpty(value)) {
7545
+ const schemaPath = basePath.replace(/\[[^\]]*\]/g, ".*");
7546
+ if (schemaPath in knownDefPaths && !matchesKnownDefault(value, knownDefPaths[schemaPath]) && (MEANINGFUL_WHEN_OFF_NESTED[resourceType]?.[schemaPath]?.({
7547
+ declared,
7548
+ live
7549
+ }) ?? false)) return false;
7550
+ return true;
7551
+ }
7482
7552
  if (Array.isArray(value)) return false;
7483
7553
  if (isNestedObject(value)) return Object.entries(value).every(([sk, sv]) => allLeavesAtSchemaDefault(sv, `${basePath}.${sk}`));
7484
7554
  const schemaPath = basePath.replace(/\[[^\]]*\]/g, ".*");
@@ -15614,8 +15684,8 @@ async function regatherTouched(gathered, touched, region) {
15614
15684
  clusterEchoModel: buildClusterEchoModels(desired),
15615
15685
  scalableTargetBands: buildScalableTargetBands(desired),
15616
15686
  siblingClientVpnEndpointVpcs: buildClientVpnEndpointSiblingVpcs(desired),
15617
- siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, liveModelMap(reads)),
15618
- siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, liveModelMap(reads)),
15687
+ siblingCloudFrontCdPolicyIds: buildCloudFrontStagingDistCdPolicyIds(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
15688
+ siblingRdsSourceModels: buildRdsReplicaSourceModels(desired, new Map([...gathered.liveByLogical, ...liveModelMap(reads)])),
15619
15689
  rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
15620
15690
  };
15621
15691
  const fresh = [];
@@ -19668,6 +19738,7 @@ const REVERT_SET_DEFAULT_PATHS = new Set([
19668
19738
  "AWS::RDS::DBInstance\0MonitoringInterval",
19669
19739
  "AWS::RDS::DBInstance\0CopyTagsToSnapshot",
19670
19740
  "AWS::RDS::DBInstance\0CACertificateIdentifier",
19741
+ "AWS::EC2::Volume\0VolumeType",
19671
19742
  "AWS::RDS::DBCluster\0AutoMinorVersionUpgrade",
19672
19743
  "AWS::Neptune::DBInstance\0AutoMinorVersionUpgrade",
19673
19744
  "AWS::ElastiCache::CacheCluster\0AutoMinorVersionUpgrade",
@@ -20066,7 +20137,8 @@ function buildRevertPlan(findings, baseline, opts = {}) {
20066
20137
  desired: [...f.desired, ...sib]
20067
20138
  };
20068
20139
  }
20069
- const op = revertOp(toRevert, recorded, opts.identity);
20140
+ const declaredModel = opts.declaredForLogical?.(f.logicalId);
20141
+ const op = revertOp(toRevert, recorded, opts.identity, declaredModel);
20070
20142
  const key = `${f.logicalId} ${kind}${propScoped ? ` ${f.path}` : ""}`;
20071
20143
  const item = itemsByLogical.get(key) ?? {
20072
20144
  logicalId: f.logicalId,
@@ -20077,6 +20149,20 @@ function buildRevertPlan(findings, baseline, opts = {}) {
20077
20149
  ops: []
20078
20150
  };
20079
20151
  item.ops.push(op);
20152
+ if (kind === "cc" && op.op === "add") {
20153
+ const live = opts.liveByLogical?.get(f.logicalId);
20154
+ for (const sibling of REVERT_COMPANION_REMOVES[`${f.resourceType}\0${f.path}`]?.(op.value) ?? []) {
20155
+ if (declaredModel?.[sibling] !== void 0) continue;
20156
+ if (!live || live[sibling] === void 0) continue;
20157
+ const siblingPointer = `/${sibling}`;
20158
+ if (item.ops.some((o) => o.path === siblingPointer)) continue;
20159
+ item.ops.push({
20160
+ op: "remove",
20161
+ path: siblingPointer,
20162
+ human: `${sibling} -> remove (incompatible with the restored default)`
20163
+ });
20164
+ }
20165
+ }
20080
20166
  itemsByLogical.set(key, item);
20081
20167
  }
20082
20168
  if (opts.liveByLogical) for (const item of itemsByLogical.values()) {
@@ -20116,7 +20202,20 @@ function contextArnDefaultFor(resourceType, path, identity) {
20116
20202
  const substitute = (t) => t.replace("{partition}", partition).replace("{region}", region).replace("{accountId}", accountId);
20117
20203
  return Array.isArray(template) ? template.map(substitute) : substitute(template);
20118
20204
  }
20119
- function revertOp(f, recorded, identity) {
20205
+ function derivedRevertDefaultFor(resourceType, path, declared) {
20206
+ if (!declared) return void 0;
20207
+ if (resourceType === "AWS::Route53::HealthCheck" && path === "HealthCheckConfig.Port") return route53HealthCheckDerivedPort(declared["HealthCheckConfig"]?.["Type"]);
20208
+ if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup") {
20209
+ if (path === "HealthCheckProtocol") return elbTargetGroupDerivedHealthCheckProtocol(declared["Protocol"], declared["TargetType"]);
20210
+ if (path === "HealthCheckPort") return elbTargetGroupDerivedHealthCheckPort(declared["Protocol"]);
20211
+ }
20212
+ if (resourceType === "AWS::RDS::DBInstance" && path === "BackupRetentionPeriod") return rdsReplicaDerivedBackupRetention(declared["SourceDBInstanceIdentifier"]);
20213
+ }
20214
+ const REVERT_COMPANION_REMOVES = {
20215
+ "AWS::ElasticLoadBalancingV2::TargetGroup\0HealthCheckProtocol": (value) => value === "TCP" ? ["Matcher", "HealthCheckPath"] : [],
20216
+ "AWS::EC2::Volume\0VolumeType": (value) => value === "gp2" || value === "standard" || value === "st1" || value === "sc1" ? ["Iops", "Throughput"] : value === "io1" || value === "io2" ? ["Throughput"] : []
20217
+ };
20218
+ function revertOp(f, recorded, identity, declaredModel) {
20120
20219
  const pointer = toPointer(f.path);
20121
20220
  if (f.tier === "declared") return {
20122
20221
  op: "add",
@@ -20140,6 +20239,14 @@ function revertOp(f, recorded, identity) {
20140
20239
  prior: f.actual,
20141
20240
  human: `${f.path} -> baseline value`
20142
20241
  };
20242
+ const derivedDefault = derivedRevertDefaultFor(f.resourceType, f.path, declaredModel);
20243
+ if (derivedDefault !== void 0) return {
20244
+ op: "add",
20245
+ path: pointer,
20246
+ value: derivedDefault,
20247
+ prior: f.actual,
20248
+ human: `${f.path} -> AWS default (derived from declared inputs)`
20249
+ };
20143
20250
  const setDefaultKey = `${f.resourceType}\0${f.path}`;
20144
20251
  const knownDefault = KNOWN_DEFAULTS[f.resourceType]?.[f.path] ?? REVERT_SET_DEFAULT_VALUES[setDefaultKey] ?? contextArnDefaultFor(f.resourceType, f.path, identity);
20145
20252
  if (knownDefault !== void 0 && REVERT_SET_DEFAULT_PATHS.has(setDefaultKey)) return {
@@ -21179,7 +21286,8 @@ async function revertStack(p) {
21179
21286
  identity: {
21180
21287
  accountId: gathered.desired.accountId,
21181
21288
  region
21182
- }
21289
+ },
21290
+ declaredForLogical
21183
21291
  });
21184
21292
  if (plan.items.length === 0 && plan.notRevertable.length === 0) {
21185
21293
  out(style.clean(`${stackName} (${region}): no drift to revert.`));