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.