Skip to content

Commit 56af12b

Browse files
committed
add exclude
1 parent d9dc325 commit 56af12b

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

packages/cdkConstructs/src/constructs/PythonLambdaFunction.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ export interface PythonLambdaFunctionProps {
8080
* @default Architecture.X86_64
8181
*/
8282
readonly architecture?: Architecture
83+
/**
84+
* Any files to exclude from the Lambda asset bundle.
85+
* Defaults to these files
86+
* "tests",
87+
* "pytest.ini",
88+
* ".vscode",
89+
* "__pycache__",
90+
* "*.pyc"
91+
*/
92+
readonly excludeFromAsset?: Array<string>
93+
8394
}
8495

8596
export class PythonLambdaFunction extends Construct {
@@ -167,7 +178,14 @@ export class PythonLambdaFunction extends Construct {
167178
layers = [], // Default to empty array
168179
timeoutInSeconds = 50,
169180
runtime = Runtime.PYTHON_3_14,
170-
architecture = Architecture.X86_64
181+
architecture = Architecture.X86_64,
182+
excludeFromAsset = [
183+
"tests",
184+
"pytest.ini",
185+
".vscode",
186+
"__pycache__",
187+
"*.pyc"
188+
]
171189
} = props
172190

173191
const {logGroup, role, insightsLayer} = createSharedLambdaResources(this, {
@@ -196,7 +214,9 @@ export class PythonLambdaFunction extends Construct {
196214
functionName: functionName,
197215
architecture,
198216
handler: handler,
199-
code: Code.fromAsset(join(projectBaseDir, packageBasePath)),
217+
code: Code.fromAsset(join(projectBaseDir, packageBasePath), {
218+
exclude: excludeFromAsset
219+
}),
200220
role,
201221
environment: {
202222
...environmentVariables,

0 commit comments

Comments
 (0)