cdk-real-drift 0.16.3 → 0.17.1

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/README.md CHANGED
@@ -166,6 +166,34 @@ result: 1 drift(s) (undeclared=1)
166
166
  `record` covers live-only state only, not a `[CFn-Declared Drift]`; the other
167
167
  verbs are in [The model](#the-model-one-verb-you-run-three-it-offers).
168
168
 
169
+ ### Fixing it in code instead
170
+
171
+ record / revert / ignore all treat your CDK code as fixed. The fourth remedy —
172
+ often the right one for a change you want to _keep_ — is to **adopt the drift
173
+ into your CDK code**: if someone bumped a Lambda's memory to 2048 during an
174
+ incident and that's simply correct now, declare it.
175
+
176
+ [`--pre-deploy`](#--pre-deploy) is the verification loop for that edit, because
177
+ it compares live state against your **local synth** instead of the deployed
178
+ template:
179
+
180
+ ```console
181
+ $ npx cdkrd check # 1. drift: Handler.MemorySize desired=1024 actual=2048
182
+ # 2. the live value is right → set memorySize: 2048 in your CDK code
183
+ $ npx cdkrd check --pre-deploy # 3. finding gone: local code now matches reality
184
+ $ npx cdk deploy # 4. now a no-op for that property — nothing clobbered
185
+ $ npx cdkrd check # 5. clean against the updated deployed template
186
+ ```
187
+
188
+ If step 3 still shows the finding, your code doesn't match live yet (`desired`
189
+ is what your code would set) — fix and re-run before deploying. The deploy in
190
+ step 4 is what updates the **deployed** template to declare the value, so the
191
+ day-to-day `check` (which compares against it) comes back clean in step 5.
192
+
193
+ This also works for a `[Potential / CFn-Undeclared Drift]` value you'd rather
194
+ own in code than `record`: declaring the property moves it into the declared
195
+ tier, and step 3 confirms your declaration matches what's live.
196
+
169
197
  ### In CI
170
198
 
171
199
  Run `npx cdkrd check --fail`. It's read-only, never prompts, and exits 1 on drift;
@@ -501,8 +529,9 @@ result: 1 drift(s) (declared=1)
501
529
  ```
502
530
 
503
531
  `desired` is what your local code is about to set; `actual` is live now: someone
504
- bumped memory to 2048 out of band. Port it into code (or decide it should go away)
505
- before deploying. As a pipeline gate:
532
+ bumped memory to 2048 out of band. Port it into code (the step-by-step loop is in
533
+ [Fixing it in code instead](#fixing-it-in-code-instead)) or decide it should go
534
+ away before deploying. As a pipeline gate:
506
535
 
507
536
  ```yaml
508
537
  - run: npx cdkrd check --pre-deploy --fail # block the deploy on clobber risk
@@ -887,6 +916,14 @@ covers them. **If you never run `revert`, cdkrd needs no write permissions at al
887
916
  undeclared `RecordingGroup.RecordingStrategy` mirror and `RecordingMode` default
888
917
  fold to atDefault, so a fresh recorder is clean while a recording-scope change
889
918
  still surfaces),
919
+ `elasticloadbalancing:DescribeListenerCertificates` (reads an
920
+ `AWS::ElasticLoadBalancingV2::ListenerCertificate` — the SNI extra-cert
921
+ attachment whose registry type ships NO read handler at all, so Cloud Control
922
+ returns `UnsupportedActionException` and it was silently skipped; the reader
923
+ derives the listener ARN from the declared `ListenerArn` and projects this
924
+ resource's declared certs still present in the live non-default set, so a
925
+ declared cert removed out of band surfaces as drift while multiple attachments
926
+ on one listener stay false-positive-free),
890
927
  `ssm:DescribeParameters` (supplements the Cloud Control read of an
891
928
  `AWS::SSM::Parameter` with its writeOnly `Description` / `AllowedPattern`),
892
929
  `elasticache:DescribeReplicationGroups` + `elasticache:DescribeCacheClusters`
package/dist/cli.js CHANGED
@@ -25,7 +25,7 @@ import { AutoScalingClient, DescribeLifecycleHooksCommand, DescribeScheduledActi
25
25
  import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
26
26
  import { CognitoIdentityProviderClient, DescribeUserPoolCommand, ListGroupsCommand, ListIdentityProvidersCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
27
27
  import { DescribeMountTargetsCommand, EFSClient } from "@aws-sdk/client-efs";
28
- import { DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
28
+ import { DescribeListenerCertificatesCommand, DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
29
29
  import { DescribeEventBusCommand, EventBridgeClient, ListRulesCommand, PutPermissionCommand } from "@aws-sdk/client-eventbridge";
30
30
  import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetSecurityConfigurationCommand, GetTableCommand, GetTablesCommand, GetTagsCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
31
31
  import { GetFunctionCommand, GetPolicyCommand, LambdaClient, ListAliasesCommand as ListAliasesCommand$1, ListEventSourceMappingsCommand, ListFunctionUrlConfigsCommand, ListVersionsByFunctionCommand } from "@aws-sdk/client-lambda";
@@ -2672,7 +2672,6 @@ const KNOWN_DEFAULTS = {
2672
2672
  "AWS::Glue::Job": {
2673
2673
  JobMode: "SCRIPT",
2674
2674
  MaxRetries: 0,
2675
- Timeout: 2880,
2676
2675
  ExecutionProperty: { MaxConcurrentRuns: 1 }
2677
2676
  },
2678
2677
  "AWS::SES::EmailIdentity": {
@@ -2922,7 +2921,8 @@ const KNOWN_DEFAULTS = {
2922
2921
  };
2923
2922
  const KNOWN_DEFAULT_ONE_OF = {
2924
2923
  "AWS::ApiGatewayV2::Integration": { TimeoutInMillis: [29e3, 3e4] },
2925
- "AWS::SecurityHub::Hub": { ControlFindingGenerator: ["SECURITY_CONTROL", "STANDARD_CONTROL"] }
2924
+ "AWS::SecurityHub::Hub": { ControlFindingGenerator: ["SECURITY_CONTROL", "STANDARD_CONTROL"] },
2925
+ "AWS::Glue::Job": { Timeout: [2880, 480] }
2926
2926
  };
2927
2927
  const KNOWN_DEFAULT_ONE_OF_PATHS = {
2928
2928
  "AWS::EKS::Cluster": { "KubernetesNetworkConfig.ServiceIpv4Cidr": ["10.100.0.0/16", "172.20.0.0/16"] },
@@ -3039,6 +3039,7 @@ const KNOWN_DEFAULT_PATHS = {
3039
3039
  "ContainerDefinitions.*.Cpu": 0,
3040
3040
  "ContainerDefinitions.*.Essential": true
3041
3041
  },
3042
+ "AWS::Glue::Job": { "Command.PythonVersion": "2" },
3042
3043
  "AWS::Glue::Database": { "DatabaseInput.CreateTableDefaultPermissions": [{
3043
3044
  Permissions: ["ALL"],
3044
3045
  Principal: { DataLakePrincipalIdentifier: "IAM_ALLOWED_PRINCIPALS" }
@@ -3537,7 +3538,13 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
3537
3538
  "AWS::RDS::GlobalCluster": new Set(["EngineLifecycleSupport"]),
3538
3539
  "AWS::EKS::Cluster": new Set(["Version"]),
3539
3540
  "AWS::EKS::Addon": new Set(["AddonVersion"]),
3540
- "AWS::Glue::Job": new Set(["MaxCapacity", "AllocatedCapacity"]),
3541
+ "AWS::Glue::Job": new Set([
3542
+ "MaxCapacity",
3543
+ "AllocatedCapacity",
3544
+ "GlueVersion",
3545
+ "WorkerType",
3546
+ "NumberOfWorkers"
3547
+ ]),
3541
3548
  "AWS::EC2::SecurityGroupIngress": new Set(["SourceSecurityGroupName"]),
3542
3549
  "AWS::EC2::SecurityGroupEgress": new Set(["DestinationSecurityGroupName"]),
3543
3550
  "AWS::DocDB::DBCluster": new Set([
@@ -12835,7 +12842,39 @@ const readConfigDeliveryChannel = async ({ physicalId, region }) => {
12835
12842
  if (str$1(freq)) model.ConfigSnapshotDeliveryProperties = { DeliveryFrequency: freq };
12836
12843
  return model;
12837
12844
  };
12845
+ const declaredCertArns = (declared) => {
12846
+ const list = Array.isArray(declared.Certificates) ? declared.Certificates : [];
12847
+ const arns = [];
12848
+ for (const c of list) {
12849
+ const arn = c && typeof c === "object" ? str$1(c.CertificateArn) : void 0;
12850
+ if (arn) arns.push(arn);
12851
+ }
12852
+ return arns;
12853
+ };
12854
+ const readElbv2ListenerCertificate = async ({ declared, region }) => {
12855
+ const listenerArn = str$1(declared.ListenerArn);
12856
+ if (!listenerArn) return void 0;
12857
+ const c = new ElasticLoadBalancingV2Client({
12858
+ region,
12859
+ ...READ_RETRY
12860
+ });
12861
+ const liveNonDefault = /* @__PURE__ */ new Set();
12862
+ let marker;
12863
+ do {
12864
+ const r = await c.send(new DescribeListenerCertificatesCommand({
12865
+ ListenerArn: listenerArn,
12866
+ Marker: marker
12867
+ }));
12868
+ for (const cert of r.Certificates ?? []) if (cert.IsDefault !== true && str$1(cert.CertificateArn)) liveNonDefault.add(cert.CertificateArn);
12869
+ marker = r.NextMarker;
12870
+ } while (marker);
12871
+ const model = {};
12872
+ model.ListenerArn = listenerArn;
12873
+ model.Certificates = declaredCertArns(declared).filter((arn) => liveNonDefault.has(arn)).map((arn) => ({ CertificateArn: arn }));
12874
+ return model;
12875
+ };
12838
12876
  const SDK_OVERRIDES = {
12877
+ "AWS::ElasticLoadBalancingV2::ListenerCertificate": readElbv2ListenerCertificate,
12839
12878
  "AWS::CertificateManager::Certificate": readAcmCertificate,
12840
12879
  "AWS::SES::ReceiptRuleSet": readSesReceiptRuleSet,
12841
12880
  "AWS::SES::ReceiptRule": readSesReceiptRule,
@@ -16907,7 +16946,7 @@ const writeGlueJob = async (ctx, ops) => {
16907
16946
  for (const k of GLUE_JOB_UPDATE_FIELDS) if (m[k] !== void 0) update[k] = m[k];
16908
16947
  if (m.WorkerType === void 0) {
16909
16948
  if (m.MaxCapacity !== void 0) update.MaxCapacity = m.MaxCapacity;
16910
- if (m.AllocatedCapacity !== void 0) update.AllocatedCapacity = m.AllocatedCapacity;
16949
+ else if (m.AllocatedCapacity !== void 0) update.AllocatedCapacity = m.AllocatedCapacity;
16911
16950
  }
16912
16951
  await c.send(new UpdateJobCommand({
16913
16952
  JobName: name,
@@ -18511,13 +18550,17 @@ const REVERT_SET_DEFAULT_PATHS = new Set([
18511
18550
  "AWS::ElastiCache::ReplicationGroup\0AutoMinorVersionUpgrade",
18512
18551
  "AWS::MemoryDB::Cluster\0AutoMinorVersionUpgrade",
18513
18552
  "AWS::Redshift::Cluster\0AllowVersionUpgrade",
18514
- "AWS::DAX::ParameterGroup\0ParameterNameValues"
18553
+ "AWS::DAX::ParameterGroup\0ParameterNameValues",
18554
+ "AWS::ApiGatewayV2::IntegrationResponse\0TemplateSelectionExpression",
18555
+ "AWS::ApiGatewayV2::RouteResponse\0ModelSelectionExpression"
18515
18556
  ]);
18516
18557
  const REVERT_SET_DEFAULT_VALUES = {
18517
18558
  "AWS::EC2::Subnet\0EnableDns64": false,
18518
18559
  "AWS::EC2::ClientVpnEndpoint\0SplitTunnel": false,
18519
18560
  "AWS::DocDB::DBCluster\0DeletionProtection": false,
18520
- "AWS::EKS::Cluster\0ResourcesVpcConfig.EndpointPrivateAccess": false
18561
+ "AWS::EKS::Cluster\0ResourcesVpcConfig.EndpointPrivateAccess": false,
18562
+ "AWS::ApiGatewayV2::IntegrationResponse\0TemplateSelectionExpression": "",
18563
+ "AWS::ApiGatewayV2::RouteResponse\0ModelSelectionExpression": ""
18521
18564
  };
18522
18565
  /**
18523
18566
  * A nested undeclared value (a live sub-key inside a declared object, R96/R98) — a dotted