cdk-real-drift 0.16.2 → 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 +49 -6
- 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";
|
|
@@ -2303,7 +2303,10 @@ const KNOWN_DEFAULTS = {
|
|
|
2303
2303
|
Scheme: "internet-facing",
|
|
2304
2304
|
Type: "application"
|
|
2305
2305
|
},
|
|
2306
|
-
"AWS::ElasticLoadBalancingV2::Listener": {
|
|
2306
|
+
"AWS::ElasticLoadBalancingV2::Listener": {
|
|
2307
|
+
MutualAuthentication: { Mode: "off" },
|
|
2308
|
+
SslPolicy: "ELBSecurityPolicy-2016-08"
|
|
2309
|
+
},
|
|
2307
2310
|
"AWS::EC2::NatGateway": {
|
|
2308
2311
|
ConnectivityType: "public",
|
|
2309
2312
|
AvailabilityMode: "zonal"
|
|
@@ -2734,10 +2737,17 @@ const KNOWN_DEFAULTS = {
|
|
|
2734
2737
|
AuthorizationType: "NONE"
|
|
2735
2738
|
},
|
|
2736
2739
|
"AWS::ElasticLoadBalancingV2::ListenerRule": { IsDefault: false },
|
|
2737
|
-
"AWS::Glue::Crawler": {
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2740
|
+
"AWS::Glue::Crawler": {
|
|
2741
|
+
LakeFormationConfiguration: {
|
|
2742
|
+
AccountId: "",
|
|
2743
|
+
UseLakeFormationCredentials: false
|
|
2744
|
+
},
|
|
2745
|
+
SchemaChangePolicy: {
|
|
2746
|
+
UpdateBehavior: "UPDATE_IN_DATABASE",
|
|
2747
|
+
DeleteBehavior: "DEPRECATE_IN_DATABASE"
|
|
2748
|
+
},
|
|
2749
|
+
RecrawlPolicy: { RecrawlBehavior: "CRAWL_EVERYTHING" }
|
|
2750
|
+
},
|
|
2741
2751
|
"AWS::Config::ConfigRule": { EvaluationModes: [{ Mode: "DETECTIVE" }] },
|
|
2742
2752
|
"AWS::RUM::AppMonitor": {
|
|
2743
2753
|
Platform: "Web",
|
|
@@ -2920,6 +2930,7 @@ const KNOWN_DEFAULT_ONE_OF_PATHS = {
|
|
|
2920
2930
|
"AWS::Batch::ComputeEnvironment": { "ComputeResources.Ec2Configuration": [[{ ImageType: "ECS_AL2023" }], [{ ImageType: "ECS_AL2" }]] }
|
|
2921
2931
|
};
|
|
2922
2932
|
const KNOWN_DEFAULT_PATHS = {
|
|
2933
|
+
"AWS::IoT::TopicRule": { "TopicRulePayload.AwsIotSqlVersion": "2015-10-08" },
|
|
2923
2934
|
"AWS::SageMaker::DataQualityJobDefinition": {
|
|
2924
2935
|
"DataQualityJobInput.BatchTransformInput.S3DataDistributionType": "FullyReplicated",
|
|
2925
2936
|
"DataQualityJobInput.BatchTransformInput.S3InputMode": "File",
|
|
@@ -12824,7 +12835,39 @@ const readConfigDeliveryChannel = async ({ physicalId, region }) => {
|
|
|
12824
12835
|
if (str$1(freq)) model.ConfigSnapshotDeliveryProperties = { DeliveryFrequency: freq };
|
|
12825
12836
|
return model;
|
|
12826
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
|
+
};
|
|
12827
12869
|
const SDK_OVERRIDES = {
|
|
12870
|
+
"AWS::ElasticLoadBalancingV2::ListenerCertificate": readElbv2ListenerCertificate,
|
|
12828
12871
|
"AWS::CertificateManager::Certificate": readAcmCertificate,
|
|
12829
12872
|
"AWS::SES::ReceiptRuleSet": readSesReceiptRuleSet,
|
|
12830
12873
|
"AWS::SES::ReceiptRule": readSesReceiptRule,
|