Skip to content

Commit

Permalink
fix(lambda-python): asset files are generated inside the 'asset-input…
Browse files Browse the repository at this point in the history
…' folder (#18306)

Changes the asset structure from:

```
├── asset.993168cfa75b295eeea55bf603340284b9be46ebc079e4965f2c16f5470efda5
│   └── asset-input
│       ├── __init__.py
│       └── app.py
```

to:

```
├── asset.993168cfa75b295eeea55bf603340284b9be46ebc079e4965f2c16f5470efda5
│   ├── __init__.py
│   └── app.py
```

Fixes #18301.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*

(cherry picked from commit aff607a)
  • Loading branch information
otaviomacedo authored and mergify-bot committed Jan 10, 2022
1 parent 2d2ed06 commit 37b425e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-lambda-python/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export class Bundling implements CdkBundlingOptions {
bundlingCommands.push(packaging.exportCommand ?? '');
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 -R ${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 -R /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 -R /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 -R /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 -R /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 -R /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 -R /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 -R /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 -R /asset-input/ /asset-output/python',
],
}),
}));
Expand Down

0 comments on commit 37b425e

Please sign in to comment.