@@ -14,7 +14,12 @@ import {
1414} from 'aws-cdk-lib/aws-lambda' ;
1515import type { BundlingOptions , ICommandHooks } from './types' ;
1616
17- export const HASHABLE_DEPENDENCIES_EXCLUDE = [ '*.pyc' ] ;
17+ export const HASHABLE_DEPENDENCIES_EXCLUDE = [
18+ '*.pyc' ,
19+ "cdk/**" ,
20+ ".git/**" ,
21+ ".venv/**" ,
22+ ] ;
1823
1924export const DEFAULT_ASSET_EXCLUDES = [
2025 '.venv/' ,
@@ -62,17 +67,26 @@ export interface BundlingProps extends BundlingOptions {
6267 * @default false
6368 */
6469 readonly skip ?: boolean ;
70+
71+ /**
72+ * Glob patterns to exclude from asset hash fingerprinting used for source change
73+ * detection
74+ *
75+ * @default HASHABLE_DEPENDENCIES_EXCLUDE
76+ */
77+ readonly hashableAssetExclude ?: string [ ] ;
6578}
6679
6780/**
6881 * Bundling options for Python Lambda assets
6982 */
7083export class Bundling {
7184 public static bundle ( options : BundlingProps ) : AssetCode {
85+ const { hashableAssetExclude = HASHABLE_DEPENDENCIES_EXCLUDE , ...bundlingOptions } = options ;
7286 return Code . fromAsset ( options . rootDir , {
7387 assetHashType : AssetHashType . SOURCE ,
74- exclude : HASHABLE_DEPENDENCIES_EXCLUDE ,
75- bundling : new Bundling ( options ) ,
88+ exclude : hashableAssetExclude ,
89+ bundling : new Bundling ( bundlingOptions ) ,
7690 } ) ;
7791 }
7892
@@ -100,13 +114,13 @@ export class Bundling {
100114 const bundlingCommands = props . skip
101115 ? [ ]
102116 : this . createBundlingCommands ( {
103- rootDir,
104- workspacePackage,
105- assetExcludes,
106- commandHooks,
107- inputDir : AssetStaging . BUNDLING_INPUT_DIR ,
108- outputDir : AssetStaging . BUNDLING_OUTPUT_DIR ,
109- } ) ;
117+ rootDir,
118+ workspacePackage,
119+ assetExcludes,
120+ commandHooks,
121+ inputDir : AssetStaging . BUNDLING_INPUT_DIR ,
122+ outputDir : AssetStaging . BUNDLING_OUTPUT_DIR ,
123+ } ) ;
110124
111125 this . image = image ?? this . createDockerImage ( props ) ;
112126
0 commit comments