Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Commit

Permalink
fix(lambda-python): bundle asset files correctly
Browse files Browse the repository at this point in the history
Fixes aws#18301.
  • Loading branch information
setu4993 committed Jan 10, 2022
1 parent 4992d26 commit 1eb2134
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-python/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Bundling implements CdkBundlingOptions {
if (packaging.dependenciesFile) {
bundlingCommands.push(`python -m pip install -r ${DependenciesFile.PIP} -t ${options.outputDir}`);
}
bundlingCommands.push(`cp -R ${options.inputDir}/ ${options.outputDir}`);
bundlingCommands.push(`cp -a ${options.inputDir}/* ${options.outputDir}`);
return bundlingCommands;
}
}
Expand Down
16 changes: 8 additions & 8 deletions packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('Bundling a function without dependencies', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'cp -R /asset-input/ /asset-output',
'cp -a /asset-input/* /asset-output',
],
}),
}));
Expand All @@ -62,7 +62,7 @@ test('Bundling a function with requirements.txt', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'python -m pip install -r requirements.txt -t /asset-output && cp -R /asset-input/ /asset-output',
'python -m pip install -r requirements.txt -t /asset-output && cp -a /asset-input/* /asset-output',
],
}),
}));
Expand All @@ -81,7 +81,7 @@ test('Bundling Python 2.7 with requirements.txt installed', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'python -m pip install -r requirements.txt -t /asset-output && cp -R /asset-input/ /asset-output',
'python -m pip install -r requirements.txt -t /asset-output && cp -a /asset-input/* /asset-output',
],
}),
}));
Expand All @@ -101,7 +101,7 @@ test('Bundling a layer with dependencies', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input/ /asset-output/python',
'python -m pip install -r requirements.txt -t /asset-output/python && cp -a /asset-input/* /asset-output/python',
],
}),
}));
Expand All @@ -121,7 +121,7 @@ test('Bundling a python code layer', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'cp -R /asset-input/ /asset-output/python',
'cp -a /asset-input/* /asset-output/python',
],
}),
}));
Expand All @@ -141,7 +141,7 @@ test('Bundling a function with pipenv dependencies', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'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',
'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 -a /asset-input/* /asset-output/python',
],
}),
}));
Expand All @@ -161,7 +161,7 @@ test('Bundling a function with poetry dependencies', () => {
bundling: expect.objectContaining({
command: [
'bash', '-c',
'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',
'poetry export --with-credentials --format requirements.txt --output requirements.txt && python -m pip install -r requirements.txt -t /asset-output/python && cp -a /asset-input/* /asset-output/python',
],
}),
}));
Expand All @@ -184,7 +184,7 @@ test('Bundling a function with custom bundling image', () => {
image,
command: [
'bash', '-c',
'python -m pip install -r requirements.txt -t /asset-output/python && cp -R /asset-input/ /asset-output/python',
'python -m pip install -r requirements.txt -t /asset-output/python && cp -a /asset-input/* /asset-output/python',
],
}),
}));
Expand Down

0 comments on commit 1eb2134

Please sign in to comment.