aws/aws-cdk

(aws_lambda_python.PythonFunction): docker in docker fails

Closed this issue ยท 11 comments

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

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

tvb commented

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

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.

@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.

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.

@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 :(

โš ๏ธ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.

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

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

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

FYI we are tracking this via #8799