Skip to content

Commit 1b056bd

Browse files
otaviomacedoTikiTDO
authored andcommitted
fix(lambda-python): asset files are generated inside the 'asset-input' folder (aws#18306)
Changes the asset structure from: ``` ├── asset.993168cfa75b295eeea55bf603340284b9be46ebc079e4965f2c16f5470efda5 │ └── asset-input │ ├── __init__.py │ └── app.py ``` to: ``` ├── asset.993168cfa75b295eeea55bf603340284b9be46ebc079e4965f2c16f5470efda5 │ ├── __init__.py │ └── app.py ``` Fixes aws#18301. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent b14fd8d commit 1b056bd

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Diff for: packages/@aws-cdk/aws-lambda-python/lib/bundling.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export class Bundling implements CdkBundlingOptions {
8686
bundlingCommands.push(packaging.exportCommand ?? '');
8787
if (packaging.dependenciesFile) {
8888
bundlingCommands.push(`python -m pip install -r ${DependenciesFile.PIP} -t ${options.outputDir}`);
89-
};
90-
bundlingCommands.push(`cp -R ${options.inputDir} ${options.outputDir}`);
89+
}
90+
bundlingCommands.push(`cp -R ${options.inputDir}/ ${options.outputDir}`);
9191
return bundlingCommands;
9292
}
9393
}

Diff for: packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test('Bundling a function without dependencies', () => {
3636
bundling: expect.objectContaining({
3737
command: [
3838
'bash', '-c',
39-
'cp -R /asset-input /asset-output',
39+
'cp -R /asset-input/ /asset-output',
4040
],
4141
}),
4242
}));
@@ -62,7 +62,7 @@ test('Bundling a function with requirements.txt', () => {
6262
bundling: expect.objectContaining({
6363
command: [
6464
'bash', '-c',
65-
'python -m pip install -r requirements.txt -t /asset-output && cp -R /asset-input /asset-output',
65+
'python -m pip install -r requirements.txt -t /asset-output && cp -R /asset-input/ /asset-output',
6666
],
6767
}),
6868
}));
@@ -81,7 +81,7 @@ test('Bundling Python 2.7 with requirements.txt installed', () => {
8181
bundling: expect.objectContaining({
8282
command: [
8383
'bash', '-c',
84-
'python -m pip install -r requirements.txt -t /asset-output && cp -R /asset-input /asset-output',
84+
'python -m pip install -r requirements.txt -t /asset-output && cp -R /asset-input/ /asset-output',
8585
],
8686
}),
8787
}));
@@ -101,7 +101,7 @@ test('Bundling a layer with dependencies', () => {
101101
bundling: expect.objectContaining({
102102
command: [
103103
'bash', '-c',
104-
'python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input /asset-output/python',
104+
'python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input/ /asset-output/python',
105105
],
106106
}),
107107
}));
@@ -121,7 +121,7 @@ test('Bundling a python code layer', () => {
121121
bundling: expect.objectContaining({
122122
command: [
123123
'bash', '-c',
124-
'cp -R /asset-input /asset-output/python',
124+
'cp -R /asset-input/ /asset-output/python',
125125
],
126126
}),
127127
}));
@@ -141,7 +141,7 @@ test('Bundling a function with pipenv dependencies', () => {
141141
bundling: expect.objectContaining({
142142
command: [
143143
'bash', '-c',
144-
'PIPENV_VENV_IN_PROJECT=1 pipenv lock -r > requirements.txt && rm -rf .venv && python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input /asset-output/python',
144+
'PIPENV_VENV_IN_PROJECT=1 pipenv lock -r > requirements.txt && rm -rf .venv && python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input/ /asset-output/python',
145145
],
146146
}),
147147
}));
@@ -161,7 +161,7 @@ test('Bundling a function with poetry dependencies', () => {
161161
bundling: expect.objectContaining({
162162
command: [
163163
'bash', '-c',
164-
'poetry export --with-credentials --format requirements.txt --output requirements.txt && python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input /asset-output/python',
164+
'poetry export --with-credentials --format requirements.txt --output requirements.txt && python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input/ /asset-output/python',
165165
],
166166
}),
167167
}));
@@ -184,7 +184,7 @@ test('Bundling a function with custom bundling image', () => {
184184
image,
185185
command: [
186186
'bash', '-c',
187-
'python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input /asset-output/python',
187+
'python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input/ /asset-output/python',
188188
],
189189
}),
190190
}));

0 commit comments

Comments
 (0)