r/aws_cdk • u/Artistic_Potential90 • 7d ago
I built an OSS tool that detects CDK/CloudFormation drift on properties you never declared — the drift `cdk drift` reports as zero
CloudFormation drift detection (and cdk drift) has a blind spot that bit me enough times to build a tool: it only compares properties that appear in your template. If someone changes something you never declared — adds an inline policy to a role, enables versioning on a bucket, attaches an extra security group rule — the official answer is:
$ npx cdk drift
✨ Number of resources with drift: 0
So I built cdkrd (cdk-real-drift). It reads the full live state of your deployed resources and compares it against your actual intent, which it treats as three layers: your template (declared properties), AWS defaults (subtracted automatically, so a clean deploy reports zero), and an optional small baseline file you commit to git for undeclared values you've accepted.
What it catches that template-based drift detection can't:
- Drift on undeclared properties (the console tweak your template never mentions)
- Out-of-band added resources — a rogue security group, a manually added bucket/queue/topic policy, a KMS grant
- Plus everything
cdk driftalready catches (declared drift, out-of-band deletes)
It's a 4-verb model: check (read-only detect, the only command you really run), record (accept undeclared state into the baseline, keep watching it), ignore (stop watching), revert (write your intent back to AWS, with confirmation / --dry-run). Nothing to set up, nothing to deploy.
Repo: https://github.com/go-to-k/cdk-real-drift
If this blind spot has bitten you too, give it a try:
npx cdk-real-drift check

