cdk-real-drift 0.2.34 → 0.2.36

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
@@ -1192,7 +1192,10 @@ const KNOWN_DEFAULTS = {
1192
1192
  },
1193
1193
  "AWS::Lambda::Alias": { Description: "" },
1194
1194
  "AWS::Lambda::Version": { RuntimePolicy: { UpdateRuntimeOn: "Auto" } },
1195
- "AWS::Events::Rule": { EventBusName: "default" },
1195
+ "AWS::Events::Rule": {
1196
+ EventBusName: "default",
1197
+ State: "ENABLED"
1198
+ },
1196
1199
  "AWS::Athena::WorkGroup": {
1197
1200
  State: "ENABLED",
1198
1201
  WorkGroupConfiguration: {
@@ -1204,7 +1207,8 @@ const KNOWN_DEFAULTS = {
1204
1207
  },
1205
1208
  "AWS::EKS::Cluster": {
1206
1209
  ControlPlaneScalingConfig: { Tier: "standard" },
1207
- UpgradePolicy: { SupportType: "EXTENDED" }
1210
+ UpgradePolicy: { SupportType: "EXTENDED" },
1211
+ AccessConfig: { AuthenticationMode: "CONFIG_MAP" }
1208
1212
  },
1209
1213
  "AWS::EKS::Addon": { NamespaceConfig: { Namespace: "kube-system" } },
1210
1214
  "AWS::WAFv2::WebACL": { OnSourceDDoSProtectionConfig: { ALBLowReputationMode: "ACTIVE_UNDER_DDOS" } },
@@ -1252,7 +1256,9 @@ const KNOWN_DEFAULTS = {
1252
1256
  },
1253
1257
  "AWS::ElasticLoadBalancingV2::LoadBalancer": {
1254
1258
  IpAddressType: "ipv4",
1255
- EnablePrefixForIpv6SourceNat: "off"
1259
+ EnablePrefixForIpv6SourceNat: "off",
1260
+ Scheme: "internet-facing",
1261
+ Type: "application"
1256
1262
  },
1257
1263
  "AWS::ElasticLoadBalancingV2::Listener": { MutualAuthentication: { Mode: "off" } },
1258
1264
  "AWS::EC2::NatGateway": {
@@ -1368,6 +1374,14 @@ const KNOWN_DEFAULTS = {
1368
1374
  },
1369
1375
  KeyConfiguration: { KeyType: "AWS_OWNED_KEY" },
1370
1376
  IssuerConfiguration: { Type: "ORIGINAL" },
1377
+ VerificationMessageTemplate: { DefaultEmailOption: "CONFIRM_WITH_CODE" },
1378
+ AccountRecoverySetting: { RecoveryMechanisms: [{
1379
+ Priority: 1,
1380
+ Name: "verified_email"
1381
+ }, {
1382
+ Priority: 2,
1383
+ Name: "verified_phone_number"
1384
+ }] },
1371
1385
  WebAuthnFactorConfiguration: "SINGLE_FACTOR"
1372
1386
  },
1373
1387
  "AWS::Cognito::IdentityPool": { AllowClassicFlow: false },
@@ -1381,7 +1395,27 @@ const KNOWN_DEFAULTS = {
1381
1395
  SchedulingStrategy: "REPLICA",
1382
1396
  HealthCheckGracePeriodSeconds: 0,
1383
1397
  EnableExecuteCommand: false,
1384
- DeploymentController: { Type: "ECS" }
1398
+ DeploymentController: { Type: "ECS" },
1399
+ DeploymentConfiguration: {
1400
+ BakeTimeInMinutes: 0,
1401
+ Alarms: {
1402
+ AlarmNames: [],
1403
+ Enable: false,
1404
+ Rollback: false
1405
+ },
1406
+ Strategy: "ROLLING",
1407
+ DeploymentCircuitBreaker: {
1408
+ ThresholdConfiguration: {
1409
+ Type: "BOUNDED_PERCENT",
1410
+ Value: 50
1411
+ },
1412
+ Enable: false,
1413
+ ResetOnHealthyTask: true,
1414
+ Rollback: false
1415
+ },
1416
+ MaximumPercent: 200,
1417
+ MinimumHealthyPercent: 100
1418
+ }
1385
1419
  },
1386
1420
  "AWS::AppSync::GraphQLApi": {
1387
1421
  ApiType: "GRAPHQL",
@@ -1506,7 +1540,10 @@ const KNOWN_DEFAULTS = {
1506
1540
  }]
1507
1541
  }
1508
1542
  },
1509
- "AWS::EC2::EIP": { PublicIpv4Pool: "amazon" },
1543
+ "AWS::EC2::EIP": {
1544
+ PublicIpv4Pool: "amazon",
1545
+ Domain: "vpc"
1546
+ },
1510
1547
  "AWS::EC2::TransitGateway": { SecurityGroupReferencingSupport: "disable" },
1511
1548
  "AWS::EC2::FlowLog": { MaxAggregationInterval: 600 },
1512
1549
  "AWS::EC2::PlacementGroup": { SpreadLevel: "rack" },
@@ -1526,7 +1563,13 @@ const KNOWN_DEFAULTS = {
1526
1563
  "AWS::Synthetics::Canary": {
1527
1564
  FailureRetentionPeriod: 31,
1528
1565
  SuccessRetentionPeriod: 31,
1529
- ProvisionedResourceCleanup: "AUTOMATIC"
1566
+ ProvisionedResourceCleanup: "AUTOMATIC",
1567
+ RunConfig: {
1568
+ TimeoutInSeconds: 840,
1569
+ MemoryInMB: 1500,
1570
+ EphemeralStorage: 1024,
1571
+ ActiveTracing: false
1572
+ }
1530
1573
  },
1531
1574
  "AWS::MSK::Cluster": {
1532
1575
  EnhancedMonitoring: "DEFAULT",
@@ -1534,8 +1577,34 @@ const KNOWN_DEFAULTS = {
1534
1577
  },
1535
1578
  "AWS::Glue::Job": {
1536
1579
  JobMode: "SCRIPT",
1537
- MaxRetries: 0
1580
+ MaxRetries: 0,
1581
+ Timeout: 2880,
1582
+ ExecutionProperty: { MaxConcurrentRuns: 1 }
1583
+ },
1584
+ "AWS::SES::EmailIdentity": {
1585
+ DkimAttributes: { SigningEnabled: true },
1586
+ DkimSigningAttributes: { NextSigningKeyLength: "RSA_2048_BIT" },
1587
+ FeedbackAttributes: { EmailForwardingEnabled: true }
1538
1588
  },
1589
+ "AWS::SES::ConfigurationSet": {
1590
+ SendingOptions: { SendingEnabled: true },
1591
+ ReputationOptions: { ReputationMetricsEnabled: true }
1592
+ },
1593
+ "AWS::Glue::Schema": { CheckpointVersion: {
1594
+ IsLatest: true,
1595
+ VersionNumber: 1
1596
+ } },
1597
+ "AWS::Signer::SigningProfile": { SignatureValidityPeriod: {
1598
+ Type: "MONTHS",
1599
+ Value: 135
1600
+ } },
1601
+ "AWS::Lambda::CodeSigningConfig": { CodeSigningPolicies: { UntrustedArtifactOnDeployment: "Warn" } },
1602
+ "AWS::EC2::SecurityGroup": { SecurityGroupEgress: [{
1603
+ CidrIp: "0.0.0.0/0",
1604
+ FromPort: -1,
1605
+ ToPort: -1,
1606
+ IpProtocol: "-1"
1607
+ }] },
1539
1608
  "AWS::AutoScaling::AutoScalingGroup": {
1540
1609
  Cooldown: "300",
1541
1610
  HealthCheckType: "EC2",
@@ -1829,8 +1898,22 @@ const KNOWN_DEFAULT_PATHS = {
1829
1898
  "DeploymentConfiguration.DeploymentCircuitBreaker.ThresholdConfiguration": {
1830
1899
  Type: "BOUNDED_PERCENT",
1831
1900
  Value: 50
1901
+ },
1902
+ "DeploymentConfiguration.DeploymentCircuitBreaker": {
1903
+ ThresholdConfiguration: {
1904
+ Type: "BOUNDED_PERCENT",
1905
+ Value: 50
1906
+ },
1907
+ Enable: false,
1908
+ ResetOnHealthyTask: true,
1909
+ Rollback: false
1832
1910
  }
1833
1911
  },
1912
+ "AWS::Bedrock::Guardrail": {
1913
+ "ContentPolicyConfig.ContentFiltersTierConfig": { TierName: "CLASSIC" },
1914
+ "TopicPolicyConfig.TopicsTierConfig": { TierName: "CLASSIC" }
1915
+ },
1916
+ "AWS::Synthetics::Canary": { "Schedule.RetryConfig": { MaxRetries: 0 } },
1834
1917
  "AWS::OpenSearchService::Domain": {
1835
1918
  "EBSOptions.Iops": 3e3,
1836
1919
  "EBSOptions.Throughput": 125
@@ -1950,7 +2033,8 @@ const GENERATED_DEFAULTS = { "AWS::Lambda::Function": { LoggingConfig: {
1950
2033
  } } };
1951
2034
  const GENERATED_PATHS = {
1952
2035
  "AWS::ApiGateway::Method": ["Integration.CacheNamespace"],
1953
- "AWS::XRay::SamplingRule": ["SamplingRule.RuleARN"]
2036
+ "AWS::XRay::SamplingRule": ["SamplingRule.RuleARN"],
2037
+ "AWS::Budgets::Budget": ["Budget.BudgetName"]
1954
2038
  };
1955
2039
  const CONTEXT_DEFAULTS = { "AWS::EC2::VPCEndpointService": { SupportedRegions: "regionList" } };
1956
2040
  const CONTEXT_ARN_DEFAULTS = {
@@ -1969,7 +2053,8 @@ const ENGINE_DEFAULTS = {
1969
2053
  StorageType: (e) => e.startsWith("aurora") ? "aurora" : void 0,
1970
2054
  AllocatedStorage: (e) => e.startsWith("aurora") ? 1 : void 0,
1971
2055
  Port: rdsDefaultPort
1972
- }
2056
+ },
2057
+ "AWS::ElastiCache::CacheCluster": { Port: (e) => /memcached/i.test(e) ? 11211 : /redis|valkey/i.test(e) ? 6379 : void 0 }
1973
2058
  };
1974
2059
  function rdsDefaultPort(engine) {
1975
2060
  if (/mysql|maria/.test(engine)) return 3306;
@@ -2151,6 +2236,7 @@ function ebOptionSettingTier(namespace, optionName, value, envType) {
2151
2236
  return "undeclared";
2152
2237
  }
2153
2238
  const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
2239
+ "AWS::ElasticLoadBalancingV2::LoadBalancer": new Set(["SecurityGroups"]),
2154
2240
  "AWS::Batch::JobQueue": new Set(["JobQueueType"]),
2155
2241
  "AWS::ECS::Service": new Set(["AvailabilityZoneRebalancing", "PlatformVersion"]),
2156
2242
  "AWS::KinesisAnalyticsV2::Application": new Set(["ApplicationMaintenanceConfiguration"]),
@@ -2183,7 +2269,11 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
2183
2269
  "AWS::DocDB::DBInstance": new Set(["PreferredMaintenanceWindow"]),
2184
2270
  "AWS::Neptune::DBCluster": new Set(["PreferredMaintenanceWindow", "PreferredBackupWindow"]),
2185
2271
  "AWS::Neptune::DBInstance": new Set(["PreferredMaintenanceWindow", "AvailabilityZone"]),
2186
- "AWS::ElastiCache::CacheCluster": new Set(["PreferredMaintenanceWindow", "SnapshotWindow"]),
2272
+ "AWS::ElastiCache::CacheCluster": new Set([
2273
+ "PreferredMaintenanceWindow",
2274
+ "SnapshotWindow",
2275
+ "PreferredAvailabilityZones"
2276
+ ]),
2187
2277
  "AWS::ElastiCache::ReplicationGroup": new Set(["PreferredMaintenanceWindow", "SnapshotWindow"]),
2188
2278
  "AWS::ElastiCache::ServerlessCache": new Set(["DailySnapshotTime"]),
2189
2279
  "AWS::MemoryDB::Cluster": new Set(["MaintenanceWindow", "SnapshotWindow"]),
@@ -2198,7 +2288,10 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
2198
2288
  "AWS::EC2::NetworkInterface": new Set(["PrivateIpAddress"]),
2199
2289
  "AWS::EC2::NatGateway": new Set(["PrivateIpAddress", "VpcId"]),
2200
2290
  "AWS::EFS::MountTarget": new Set(["IpAddress"]),
2201
- "AWS::EC2::EIP": new Set(["NetworkBorderGroup"]),
2291
+ "AWS::EC2::EIP": new Set(["NetworkBorderGroup", "NetworkInterfaceId"]),
2292
+ "AWS::EFS::FileSystem": new Set(["KmsKeyId"]),
2293
+ "AWS::EC2::SecurityGroup": new Set(["VpcId"]),
2294
+ "AWS::GlobalAccelerator::Accelerator": new Set(["IpAddresses"]),
2202
2295
  "AWS::EC2::VPCEndpoint": new Set(["ServiceRegion", "DnsOptions"]),
2203
2296
  "AWS::EC2::VPCPeeringConnection": new Set(["PeerRegion"]),
2204
2297
  "AWS::EC2::VPCCidrBlock": new Set(["Ipv6CidrBlock", "Ipv6CidrBlockNetworkBorderGroup"]),
@@ -3830,7 +3923,7 @@ function isPolicySubsetOf(sub, sup) {
3830
3923
  function matchesKnownDefault(live, def) {
3831
3924
  if (deepEqual(live, def)) return true;
3832
3925
  if (!isNestedObject(live) || !isNestedObject(def)) return false;
3833
- return Object.entries(live).every(([k, v]) => k in def ? deepEqual(v, def[k]) : isTrivialEmpty(v));
3926
+ return Object.entries(live).every(([k, v]) => k in def ? matchesKnownDefault(v, def[k]) : isTrivialEmpty(v));
3834
3927
  }
3835
3928
  function collectNestedUndeclared(declaredVal, liveVal, path, emit, nestedArrayIdentity) {
3836
3929
  if (Array.isArray(declaredVal) && Array.isArray(liveVal)) {
@@ -3983,6 +4076,42 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
3983
4076
  ...knownDefPaths,
3984
4077
  "LoggingConfig.LogFormat": "JSON"
3985
4078
  };
4079
+ if (resourceType === "AWS::Glue::Schema") {
4080
+ const arn = declared["Registry"]?.["Arn"];
4081
+ if (typeof arn === "string") {
4082
+ const name = arn.split(/[:/]/).pop();
4083
+ if (name) knownDefPaths = {
4084
+ ...knownDefPaths,
4085
+ "Registry.Name": name
4086
+ };
4087
+ }
4088
+ }
4089
+ if (resourceType === "AWS::Lambda::EventSourceMapping") {
4090
+ const arn = declared["EventSourceArn"];
4091
+ const service = typeof arn === "string" ? arn.split(":")[2] : void 0;
4092
+ const batchDefault = service === "sqs" ? 10 : service === "kinesis" || service === "dynamodb" || service === "kafka" ? 100 : void 0;
4093
+ if (batchDefault !== void 0) knownDef = {
4094
+ ...knownDef,
4095
+ BatchSize: batchDefault
4096
+ };
4097
+ }
4098
+ if (resourceType === "AWS::KMS::Key" && opts.accountId !== void 0) {
4099
+ const partition = opts.region?.startsWith("cn-") ? "aws-cn" : opts.region?.startsWith("us-gov-") ? "aws-us-gov" : "aws";
4100
+ knownDef = {
4101
+ ...knownDef,
4102
+ KeyPolicy: canonicalizePolicy({
4103
+ Version: "2012-10-17",
4104
+ Id: "key-default-1",
4105
+ Statement: [{
4106
+ Sid: "Enable IAM User Permissions",
4107
+ Effect: "Allow",
4108
+ Principal: { AWS: `arn:${partition}:iam::${opts.accountId}:root` },
4109
+ Action: "kms:*",
4110
+ Resource: "*"
4111
+ }]
4112
+ })
4113
+ };
4114
+ }
3986
4115
  if (resourceType === "AWS::ApiGateway::RestApi") {
3987
4116
  const types = declared["EndpointConfiguration"]?.["Types"];
3988
4117
  if (Array.isArray(types) && types.includes("PRIVATE")) {
@@ -4354,7 +4483,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
4354
4483
  }
4355
4484
  continue;
4356
4485
  }
4357
- if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in knownDef && matchesKnownDefault(v, knownDef[k]) || KNOWN_DEFAULT_ONE_OF[resourceType]?.[k]?.some((d) => matchesKnownDefault(v, d)) || VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS[resourceType]?.has(k)) {
4486
+ if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in knownDef && matchesKnownDefault(v, knownDef[k]) || KNOWN_DEFAULT_ONE_OF[resourceType]?.[k]?.some((d) => matchesKnownDefault(v, d)) || VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS[resourceType]?.has(k) && !isTrivialEmpty(v)) {
4358
4487
  findings.push({
4359
4488
  tier: "atDefault",
4360
4489
  logicalId,
@@ -10743,6 +10872,24 @@ function isManagedPolicyAttachmentMember(f) {
10743
10872
  function isNestedSdkWritable(f) {
10744
10873
  return SDK_NESTED_WRITERS[f.resourceType]?.match(f.path) ?? false;
10745
10874
  }
10875
+ function nullHuskRemovalOps(model) {
10876
+ const ops = [];
10877
+ const walk = (value, pointer) => {
10878
+ if (Array.isArray(value)) {
10879
+ if (value.length > 0 && value.every((v) => v === null || v === void 0)) {
10880
+ if (pointer !== "") ops.push({
10881
+ op: "remove",
10882
+ path: pointer,
10883
+ human: `strip null array husk at ${pointer}`
10884
+ });
10885
+ return;
10886
+ }
10887
+ value.forEach((v, i) => walk(v, `${pointer}/${i}`));
10888
+ } else if (value && typeof value === "object") for (const [k, v] of Object.entries(value)) walk(v, `${pointer}/${k.replace(/~/g, "~0").replace(/\//g, "~1")}`);
10889
+ };
10890
+ walk(model, "");
10891
+ return ops;
10892
+ }
10746
10893
  function toPointer(dotted) {
10747
10894
  return "/" + dotted.split(".").map((s) => s.replace(/~/g, "~0").replace(/\//g, "~1")).join("/");
10748
10895
  }
@@ -10944,6 +11091,13 @@ function buildRevertPlan(findings, baseline, opts = {}) {
10944
11091
  item.ops.push(op);
10945
11092
  itemsByLogical.set(key, item);
10946
11093
  }
11094
+ if (opts.liveByLogical) for (const item of itemsByLogical.values()) {
11095
+ if (item.kind !== "cc") continue;
11096
+ const live = opts.liveByLogical.get(item.logicalId);
11097
+ if (!live) continue;
11098
+ const huskOps = nullHuskRemovalOps(live);
11099
+ if (huskOps.length > 0) item.ops.unshift(...huskOps);
11100
+ }
10947
11101
  const ordered = [...itemsByLogical.values()];
10948
11102
  return {
10949
11103
  items: [...ordered.filter((i) => i.kind !== "delete"), ...ordered.filter((i) => i.kind === "delete")],
@@ -11618,7 +11772,8 @@ async function revertStack(p) {
11618
11772
  removeUnrecorded: includeRemovals,
11619
11773
  schemas: gathered.schemas,
11620
11774
  siblingSgRules: buildSiblingSgRules(gathered.desired),
11621
- stackName
11775
+ stackName,
11776
+ liveByLogical: gathered.liveByLogical
11622
11777
  });
11623
11778
  if (plan.items.length === 0 && plan.notRevertable.length === 0) {
11624
11779
  console.log(style.clean(`${stackName} (${region}): no drift to revert.`));