CI Perf Lint

cdk-asset-waste-files

Summary

CDK assets contain unnecessary files that inflate deployment package size.

Why It Matters

CDK assets are uploaded to AWS as-is during deployment. Including test files, documentation, examples, and large data files:

What Gets Flagged

Two categories of files inside cdk.out/ asset directories:

1. Files with waste-indicating names (regardless of size)

2. Large data/doc files (>50KB)

Small files with these extensions are allowed, as they may be needed at runtime (e.g., small config CSVs, README.md).

How to Fix

  1. Add a .cdkignore file in the asset source directory:
# .cdkignore
**/*.test.*
**/*.spec.*
**/__tests__/**
**/tests/**
**/docs/**
**/examples/**
**/fixtures/**
**/mocks/**
**/large-data.csv
  1. Or configure bundling exclusions in your CDK code:
new AssetCode(path.join(__dirname, "my-asset"), {
  exclude: ["**/*.test.*", "**/__tests__/**", "**/docs/**"],
});
  1. Re-synth and verify the asset size decreased.

Measurement

Compare asset size and cdk deploy duration before and after adding exclusions.

Scanner requirements

This rule reads cdk.out/manifest.json and the files under cdk.out/, so the CDK app must be synthesized before scanning. Run cdk synth first, and make sure the synthesized output is present in the workspace being scanned. In CI this usually means adding a synth step, and passing cdk.out as an artifact when the scanner runs in a separate job. Without cdk.out, the rule cannot evaluate the assets and stays silent.