Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws_lambda_python.PythonFunction): docker in docker fails #12940

Closed
bafonso opened this issue Feb 9, 2021 · 11 comments
Closed

(aws_lambda_python.PythonFunction): docker in docker fails #12940

bafonso opened this issue Feb 9, 2021 · 11 comments
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. effort/small Small work item – less than a day of effort p1 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@bafonso
Copy link

bafonso commented Feb 9, 2021

aws_lambda_python.PythonFunction fails at running bundling a python function with requirements.txt

Reproduction Steps

  1. Create python function:
        function = _lambda_python.PythonFunction(
                self, 
                "lambda_function",
                runtime=_lambda.Runtime.PYTHON_3_7,
                handler="main",
                entry="./lambda",
                index="lambda-handler.py"
        )
  1. Run cdk synth

What did you expect to happen?

Not error out? :)

What actually happened?

Successfully tagged cdk-573ead1ff90e3efe905c76e4e3cbfe9a7282d92e5f2a2b7582566828e7a2ef15:latest
Bundling asset my-python-sample/lambda_function/Code/Stage...
jsii.errors.JavaScriptError: 
  Error: Bundling did not produce any output. Check that content is written to /asset-output.
      at AssetStaging.bundle (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/core/lib/asset-staging.js:313:19)
      at AssetStaging.stageByBundling (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/core/lib/asset-staging.js:183:14)
      at stageThisAsset (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/core/lib/asset-staging.js:64:41)
      at Cache.obtain (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/core/lib/private/cache.js:28:17)
      at new AssetStaging (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/core/lib/asset-staging.js:88:48)
      at new Asset (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/aws-s3-assets/lib/asset.js:28:25)
      at AssetCode.bind (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/aws-lambda/lib/code.js:225:26)
      at new Function (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/aws-lambda/lib/function.js:95:33)
      at new PythonFunction (/tmp/jsii-kernel-Q2sdku/node_modules/@aws-cdk/aws-lambda-python/lib/function.js:34:9)
      at /tmp/tmpva3wp68e/lib/program.js:2700:58

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "app.py", line 9, in <module>
    MyPythonSampleStack(app, "my-python-sample", env={'region': 'us-west-2'})
  File "/workspace/git_code/my_python_sample/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/workspace/git_code/my_python_sample/my_python_sample/my_python_sample_stack.py", line 26, in __init__
    function = _lambda_python.PythonFunction(
  File "/workspace/git_code/my_python_sample/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/workspace/git_code/my_python_sample/.venv/lib/python3.8/site-packages/aws_cdk/aws_lambda_python/__init__.py", line 243, in __init__
    jsii.create(PythonFunction, self, [scope, id, props])
  File "/workspace/git_code/my_python_sample/.venv/lib/python3.8/site-packages/jsii/_kernel/__init__.py", line 265, in create
    response = self.provider.create(
  File "/workspace/git_code/my_python_sample/.venv/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 348, in create
    return self._process.send(request, CreateResponse)
  File "/workspace/git_code/my_python_sample/.venv/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 330, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Bundling did not produce any output. Check that content is written to /asset-output.
Subprocess exited with error 1

Environment

  • CDK CLI Version : 1.88
  • Framework Version:
  • Node.js Version: 14.15.4
  • OS : Ubuntu running on docker, Docker version 20.10.3, build 48d30b5
  • Language (Version): aws-cdk for Python, running Python 3.8.7

Other


This is 🐛 Bug Report

@bafonso bafonso added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 9, 2021
@eladb eladb added effort/small Small work item – less than a day of effort p1 labels Feb 15, 2021
@eladb eladb removed their assignment Feb 25, 2021
@bigkraig
Copy link

I think this can be corrected by using cp on the image rather than providing the image to the lambda Code.

@NGL321 NGL321 removed the needs-triage This issue or PR still needs to be triaged. label Jul 23, 2021
@tvb
Copy link

tvb commented Jul 30, 2021

Having the same issue when running cdk synth within GitHub Actions. I've been searching for a solution for days now.

@1davidmichael
Copy link
Contributor

I've gone back to using the aws-cdk/aws-lambda Function construct with localBundling after trying to find a solution to this for a couple days. Here is a repo example: https://github.com/1davidmichael/cdk-local-bundling-example

I am wondering if exploring some option that prefers local bundling if available like the NodeJS one does with eslint would work.

@corymhall
Copy link
Contributor

@bafonso can you let me know if you are still seeing this issue? I think it may be fixed after the recent updates to the way docker bundling is performed.

@corymhall corymhall added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 26, 2022
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jan 29, 2022
@bafonso
Copy link
Author

bafonso commented Jan 31, 2022

@bafonso can you let me know if you are still seeing this issue? I think it may be fixed after the recent updates to the way docker bundling is performed.

Hi @corymhall , we are currently not using this method anymore so at this point I can't reproduce the conditions. Please feel free to close this issue as I don't have the bandwidth to further test :(

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@trobert2
Copy link

trobert2 commented Feb 1, 2022

@bafonso would it be possible to share your solution, please?
I am facing a similar issue right now

@bafonso
Copy link
Author

bafonso commented Feb 9, 2022

@trobert2 I was running a docker remotely via vscode but now we just run vscode remotely via ssh.

@lcastroemello
Copy link

I am facing a similar issue right now, did someone find a solution in the meantime?

@mrgrain
Copy link
Contributor

mrgrain commented Dec 9, 2022

FYI we are tracking this via #8799

@aws aws locked and limited conversation to collaborators Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. effort/small Small work item – less than a day of effort p1 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests