Stale CDK build files can trick AI tools into recommending deleted infrastructure
A developer discovered that CDK monorepos can retain orphaned CloudFormation templates in the cdk.out build directory even after stacks are deleted, because each new synth only writes current templates without removing old ones. Since cdk.out is listed in .gitignore by default, these leftover files are invisible to version control, code reviews, and CI pipelines, making them nearly impossible to detect. An infrastructure drift analyzer running against such a repo falsely flagged deleted resources as 'defined but not deployed,' generating multiple medium-severity findings all confidently citing real file paths on disk. The problem is compounded in monorepos with many stacks, where a single deleted stack can flood the report with one erroneous finding per resource, and orphaned export values can cause downstream stacks to fail silently at deploy time. The bug was fixed and a regression fixture was added after three reports from a user testing the analyzer against a CDK monorepo backed by a shared CloudFront distribution.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in