Skip to content

Commit 1453734

Browse files
authored
Chore: [AEA-0000] - add exclude array for python lambdas (#602)
## Summary - Routine Change ### Details - add exclude array for python lambdas
1 parent d9dc325 commit 1453734

4 files changed

Lines changed: 30 additions & 28 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ _site/
2525
.sass-cache
2626
.jekyll-cache
2727
.jekyll-metadata
28-
vendor
28+
vendor
29+
.trivy_out/

.trivy_out/license_scan.txt

Lines changed: 0 additions & 25 deletions
This file was deleted.

.trivyignore.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,9 @@ vulnerabilities:
7171
- id: CVE-2026-27142
7272
statement: asdf go stdlib
7373
expired_at: 2026-06-01
74+
- id: CVE-2026-27142
75+
statement: asdf go stdlib
76+
expired_at: 2026-06-01
77+
- id: CVE-2026-32141
78+
statement: flatted
79+
expired_at: 2026-06-01

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)