cdk-real-drift 0.16.3 → 0.17.0
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 +39 -2
- package/dist/cli.js +33 -1
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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 (
|
|
505
|
-
|
|
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";
|
|
@@ -12835,7 +12835,39 @@ const readConfigDeliveryChannel = async ({ physicalId, region }) => {
|
|
|
12835
12835
|
if (str$1(freq)) model.ConfigSnapshotDeliveryProperties = { DeliveryFrequency: freq };
|
|
12836
12836
|
return model;
|
|
12837
12837
|
};
|
|
12838
|
+
const declaredCertArns = (declared) => {
|
|
12839
|
+
const list = Array.isArray(declared.Certificates) ? declared.Certificates : [];
|
|
12840
|
+
const arns = [];
|
|
12841
|
+
for (const c of list) {
|
|
12842
|
+
const arn = c && typeof c === "object" ? str$1(c.CertificateArn) : void 0;
|
|
12843
|
+
if (arn) arns.push(arn);
|
|
12844
|
+
}
|
|
12845
|
+
return arns;
|
|
12846
|
+
};
|
|
12847
|
+
const readElbv2ListenerCertificate = async ({ declared, region }) => {
|
|
12848
|
+
const listenerArn = str$1(declared.ListenerArn);
|
|
12849
|
+
if (!listenerArn) return void 0;
|
|
12850
|
+
const c = new ElasticLoadBalancingV2Client({
|
|
12851
|
+
region,
|
|
12852
|
+
...READ_RETRY
|
|
12853
|
+
});
|
|
12854
|
+
const liveNonDefault = /* @__PURE__ */ new Set();
|
|
12855
|
+
let marker;
|
|
12856
|
+
do {
|
|
12857
|
+
const r = await c.send(new DescribeListenerCertificatesCommand({
|
|
12858
|
+
ListenerArn: listenerArn,
|
|
12859
|
+
Marker: marker
|
|
12860
|
+
}));
|
|
12861
|
+
for (const cert of r.Certificates ?? []) if (cert.IsDefault !== true && str$1(cert.CertificateArn)) liveNonDefault.add(cert.CertificateArn);
|
|
12862
|
+
marker = r.NextMarker;
|
|
12863
|
+
} while (marker);
|
|
12864
|
+
const model = {};
|
|
12865
|
+
model.ListenerArn = listenerArn;
|
|
12866
|
+
model.Certificates = declaredCertArns(declared).filter((arn) => liveNonDefault.has(arn)).map((arn) => ({ CertificateArn: arn }));
|
|
12867
|
+
return model;
|
|
12868
|
+
};
|
|
12838
12869
|
const SDK_OVERRIDES = {
|
|
12870
|
+
"AWS::ElasticLoadBalancingV2::ListenerCertificate": readElbv2ListenerCertificate,
|
|
12839
12871
|
"AWS::CertificateManager::Certificate": readAcmCertificate,
|
|
12840
12872
|
"AWS::SES::ReceiptRuleSet": readSesReceiptRuleSet,
|
|
12841
12873
|
"AWS::SES::ReceiptRule": readSesReceiptRule,
|