Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

(lambda): (cdk synth not working) #29311

Closed
shivpathak-teg opened this issue Feb 29, 2024 · 3 comments
Closed

(lambda): (cdk synth not working) #29311

shivpathak-teg opened this issue Feb 29, 2024 · 3 comments
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@shivpathak-teg
Copy link

Describe the bug

cdk synth command is not working, Please see below details steps and logs

current working directory is:
/home/circleci/project

files in current working dir are:
total 98404
-rw-r--r-- 1 circleci circleci       637 Feb 29 13:44 app.py
-rw-r--r-- 1 circleci circleci      3055 Feb 29 13:44 cdk.json
drwxr-xr-x 3 circleci circleci      4096 Feb 29 13:45 cdk.out
drwxr-xr-x 3 circleci circleci      4096 Feb 29 13:45 demo_jira_integration
drwxr-xr-x 3 circleci circleci      4096 Feb 29 13:44 demo_jira_refresh
-rwxr-xr-x 1 circleci circleci 100723120 Feb 29 13:44 fcs
-rw-r--r-- 1 circleci circleci      1658 Feb 29 13:44 README.md
-rw-r--r-- 1 circleci circleci        14 Feb 29 13:44 requirements-dev.txt
-rw-r--r-- 1 circleci circleci        62 Feb 29 13:44 requirements.txt
-rw-r--r-- 1 circleci circleci       437 Feb 29 13:44 source.bat
drwxr-xr-x 3 circleci circleci      4096 Feb 29 13:44 tests

CKD Stack list name is:
DemoJiraIntegrationStack

cdk version is:
2.130.0 (build bd6e5ee)

node version is:
v18.17.1

python version is:
Python 3.8.18

npm version is:
9.6.7

docker version is:
Docker version 20.10.23, build 7155243

os version is:
Linux 5bd5cb2b6a50 6.2.0-1018-aws #18~22.04.1-Ubuntu SMP Wed Jan 10 22:54:16 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

The requirements.txt is present under directory which needs to be packaged as lambda function
total 12
-rw-r--r-- 1 circleci circleci 2172 Feb 29 13:44 demo_jira_refresh.py
-rw-r--r-- 1 circleci circleci   91 Feb 29 13:44 requirements.txt
-rw-r--r-- 1 circleci circleci 1907 Feb 29 13:44 utils.py

Now going to run cdk synth which will generate error like its not able to find requirements txt

Bundling asset DemoJiraIntegrationStack/DemoJiraRefresh/Code/Stage...
Unable to find image 'public.ecr.aws/sam/build-python3.11:latest' locally
latest: Pulling from sam/build-python3.11
7957f4aa706c: Pulling fs layer
4fede9ed4e55: Pulling fs layer
4dd60869ed79: Pulling fs layer
2a9f1ae020e1: Pulling fs layer
bc013f00830a: Pulling fs layer
aea0d944e7a2: Pulling fs layer
96264c7449c5: Pulling fs layer
51403e93fb73: Pulling fs layer
d16da685d132: Pulling fs layer
e4859867cb15: Pulling fs layer
b29d8ecf1438: Pulling fs layer
54f25f7d9506: Pulling fs layer
6d460948940c: Pulling fs layer
682ec923eded: Pulling fs layer
a47dca7c36f0: Pulling fs layer
2a9f1ae020e1: Waiting
bc013f00830a: Waiting
aea0d944e7a2: Waiting
96264c7449c5: Waiting
51403e93fb73: Waiting
d16da685d132: Waiting
e4859867cb15: Waiting
b29d8ecf1438: Waiting
54f25f7d9506: Waiting
6d460948940c: Waiting
682ec923eded: Waiting
a47dca7c36f0: Waiting
4dd60869ed79: Verifying Checksum
4dd60869ed79: Download complete
4fede9ed4e55: Verifying Checksum
4fede9ed4e55: Download complete
2a9f1ae020e1: Verifying Checksum
2a9f1ae020e1: Download complete
aea0d944e7a2: Verifying Checksum
aea0d944e7a2: Download complete
7957f4aa706c: Verifying Checksum
7957f4aa706c: Download complete
bc013f00830a: Verifying Checksum
bc013f00830a: Download complete
51403e93fb73: Verifying Checksum
51403e93fb73: Download complete
e4859867cb15: Verifying Checksum
e4859867cb15: Download complete
d16da685d132: Verifying Checksum
d16da685d132: Download complete
b29d8ecf1438: Verifying Checksum
b29d8ecf1438: Download complete
54f25f7d9506: Verifying Checksum
54f25f7d9506: Download complete
6d460948940c: Verifying Checksum
6d460948940c: Download complete
682ec923eded: Verifying Checksum
682ec923eded: Download complete
a47dca7c36f0: Verifying Checksum
a47dca7c36f0: Download complete
96264c7449c5: Verifying Checksum
96264c7449c5: Download complete
7957f4aa706c: Pull complete
4fede9ed4e55: Pull complete
4dd60869ed79: Pull complete
2a9f1ae020e1: Pull complete
bc013f00830a: Pull complete
aea0d944e7a2: Pull complete
96264c7449c5: Pull complete
51403e93fb73: Pull complete
d16da685d132: Pull complete
e4859867cb15: Pull complete
b29d8ecf1438: Pull complete
54f25f7d9506: Pull complete
6d460948940c: Pull complete
682ec923eded: Pull complete
a47dca7c36f0: Pull complete
Digest: sha256:0814ef4fb45563e04c103a1cf207feb5dfe0ce560b55fa16b5368a9fddec968e
Status: Downloaded newer image for public.ecr.aws/sam/build-python3.11:latest
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
jsii.errors.JavaScriptError: 
  Error: Failed to bundle asset DemoJiraIntegrationStack/DemoJiraRefresh/Code/Stage, bundle output is located at /home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9-error: Error: docker exited with status 1
  --> Command: docker run --rm -u "1001:1002" -v "/home/circleci/project/demo_jira_refresh/lambda_source:/asset-input:delegated" -v "/home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9:/asset-output:delegated" -w "/asset-input" "public.ecr.aws/sam/build-python3.11" bash -c "pip install --no-cache -r requirements.txt -t /asset-output && cp -au . /asset-output"
      at AssetStaging.bundle (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:619)
      at AssetStaging.stageByBundling (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:5297)
      at stageThisAsset (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2728)
      at Cache.obtain (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
      at new AssetStaging (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:3125)
      at new Asset (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1080)
      at AssetCode.bind (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4881)
      at new Function (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:9422)
      at Kernel._Kernel_create (/tmp/tmpi75xj43e/lib/program.js:10108:25)
      at Kernel.create (/tmp/tmpi75xj43e/lib/program.js:9779:93)

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

Traceback (most recent call last):
  File "app.py", line 20, in <module>
    DemoJiraIntegrationStack(app, "DemoJiraIntegrationStack",
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/home/circleci/project/demo_jira_integration/demo_jira_integration_stack.py", line 38, in __init__
    demo_jira_refresh = _lambda.Function(
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/aws_cdk/aws_lambda/__init__.py", line 25841, in __init__
    jsii.create(self.__class__, self, [scope, id, props])
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_kernel/__init__.py", line 334, in create
    response = self.provider.create(
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 365, in create
    return self._process.send(request, CreateResponse)
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 342, in send
    raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
RuntimeError: Failed to bundle asset DemoJiraIntegrationStack/DemoJiraRefresh/Code/Stage, bundle output is located at /home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9-error: Error: docker exited with status 1
--> Command: docker run --rm -u "1001:1002" -v "/home/circleci/project/demo_jira_refresh/lambda_source:/asset-input:delegated" -v "/home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9:/asset-output:delegated" -w "/asset-input" "public.ecr.aws/sam/build-python3.11" bash -c "pip install --no-cache -r requirements.txt -t /asset-output && cp -au . /asset-output"

Subprocess exited with error 1

Exited with code exit status 1

Expected Behavior

cdk synth should bundle the lambda and generate CloudFormation template

Current Behavior

cdk synth complains requirements.txt not found but it's there on path which is mounted in docker: /home/circleci/project/demo_jira_refresh/lambda_source on host.

Bundling asset DemoJiraIntegrationStack/DemoJiraRefresh/Code/Stage...
Unable to find image 'public.ecr.aws/sam/build-python3.11:latest' locally
latest: Pulling from sam/build-python3.11
7957f4aa706c: Pulling fs layer
4fede9ed4e55: Pulling fs layer
4dd60869ed79: Pulling fs layer
2a9f1ae020e1: Pulling fs layer
bc013f00830a: Pulling fs layer
aea0d944e7a2: Pulling fs layer
96264c7449c5: Pulling fs layer
51403e93fb73: Pulling fs layer
d16da685d132: Pulling fs layer
e4859867cb15: Pulling fs layer
b29d8ecf1438: Pulling fs layer
54f25f7d9506: Pulling fs layer
6d460948940c: Pulling fs layer
682ec923eded: Pulling fs layer
a47dca7c36f0: Pulling fs layer
2a9f1ae020e1: Waiting
bc013f00830a: Waiting
aea0d944e7a2: Waiting
96264c7449c5: Waiting
51403e93fb73: Waiting
d16da685d132: Waiting
e4859867cb15: Waiting
b29d8ecf1438: Waiting
54f25f7d9506: Waiting
6d460948940c: Waiting
682ec923eded: Waiting
a47dca7c36f0: Waiting
4dd60869ed79: Verifying Checksum
4dd60869ed79: Download complete
4fede9ed4e55: Verifying Checksum
4fede9ed4e55: Download complete
2a9f1ae020e1: Verifying Checksum
2a9f1ae020e1: Download complete
aea0d944e7a2: Verifying Checksum
aea0d944e7a2: Download complete
7957f4aa706c: Verifying Checksum
7957f4aa706c: Download complete
bc013f00830a: Verifying Checksum
bc013f00830a: Download complete
51403e93fb73: Verifying Checksum
51403e93fb73: Download complete
e4859867cb15: Verifying Checksum
e4859867cb15: Download complete
d16da685d132: Verifying Checksum
d16da685d132: Download complete
b29d8ecf1438: Verifying Checksum
b29d8ecf1438: Download complete
54f25f7d9506: Verifying Checksum
54f25f7d9506: Download complete
6d460948940c: Verifying Checksum
6d460948940c: Download complete
682ec923eded: Verifying Checksum
682ec923eded: Download complete
a47dca7c36f0: Verifying Checksum
a47dca7c36f0: Download complete
96264c7449c5: Verifying Checksum
96264c7449c5: Download complete
7957f4aa706c: Pull complete
4fede9ed4e55: Pull complete
4dd60869ed79: Pull complete
2a9f1ae020e1: Pull complete
bc013f00830a: Pull complete
aea0d944e7a2: Pull complete
96264c7449c5: Pull complete
51403e93fb73: Pull complete
d16da685d132: Pull complete
e4859867cb15: Pull complete
b29d8ecf1438: Pull complete
54f25f7d9506: Pull complete
6d460948940c: Pull complete
682ec923eded: Pull complete
a47dca7c36f0: Pull complete
Digest: sha256:0814ef4fb45563e04c103a1cf207feb5dfe0ce560b55fa16b5368a9fddec968e
Status: Downloaded newer image for public.ecr.aws/sam/build-python3.11:latest
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
jsii.errors.JavaScriptError: 
  Error: Failed to bundle asset DemoJiraIntegrationStack/DemoJiraRefresh/Code/Stage, bundle output is located at /home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9-error: Error: docker exited with status 1
  --> Command: docker run --rm -u "1001:1002" -v "/home/circleci/project/demo_jira_refresh/lambda_source:/asset-input:delegated" -v "/home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9:/asset-output:delegated" -w "/asset-input" "public.ecr.aws/sam/build-python3.11" bash -c "pip install --no-cache -r requirements.txt -t /asset-output && cp -au . /asset-output"
      at AssetStaging.bundle (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:619)
      at AssetStaging.stageByBundling (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:5297)
      at stageThisAsset (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2728)
      at Cache.obtain (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
      at new AssetStaging (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:3125)
      at new Asset (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1080)
      at AssetCode.bind (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4881)
      at new Function (/tmp/jsii-kernel-e2AaYz/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:9422)
      at Kernel._Kernel_create (/tmp/tmpi75xj43e/lib/program.js:10108:25)
      at Kernel.create (/tmp/tmpi75xj43e/lib/program.js:9779:93)

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

Traceback (most recent call last):
  File "app.py", line 20, in <module>
    DemoJiraIntegrationStack(app, "DemoJiraIntegrationStack",
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/home/circleci/project/demo_jira_integration/demo_jira_integration_stack.py", line 38, in __init__
    demo_jira_refresh = _lambda.Function(
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/aws_cdk/aws_lambda/__init__.py", line 25841, in __init__
    jsii.create(self.__class__, self, [scope, id, props])
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_kernel/__init__.py", line 334, in create
    response = self.provider.create(
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 365, in create
    return self._process.send(request, CreateResponse)
  File "/home/circleci/.pyenv/versions/3.8.18/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 342, in send
    raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
RuntimeError: Failed to bundle asset DemoJiraIntegrationStack/DemoJiraRefresh/Code/Stage, bundle output is located at /home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9-error: Error: docker exited with status 1
--> Command: docker run --rm -u "1001:1002" -v "/home/circleci/project/demo_jira_refresh/lambda_source:/asset-input:delegated" -v "/home/circleci/project/cdk.out/asset.8b63adc307a2d846dcbb9b311c490f5aba9cdecce9ca70833b8c9eb3fe087dd9:/asset-output:delegated" -w "/asset-input" "public.ecr.aws/sam/build-python3.11" bash -c "pip install --no-cache -r requirements.txt -t /asset-output && cp -au . /asset-output"

Subprocess exited with error 1

Exited with code exit status 1

Reproduction Steps

$ mkdir reproduce-cdk-issue
$ cd reproduce-cdk-issue
$ cdk init app --language python

Empty the file reproduce_cdk_issue/reproduce_cdk_issue_stack.py and put following code block:

from aws_cdk import (
    BundlingOptions,
    Duration,
    Stack,
    aws_iam as iam,
    aws_lambda as _lambda,
    aws_logs as logs,
)
from constructs import Construct

class ReproduceCdkIssueStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        logs_policy = iam.PolicyStatement(
            actions=[
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents",
            ],
            resources=[
                "*",
            ]
        )
        reproduce_cdk_issue = _lambda.Function(
            self,
            "ReproduceCdkIssue",
            function_name="reproduce-cdk-issue",
            runtime=_lambda.Runtime.PYTHON_3_11,
            handler="reproduce_cdk_issue.lambda_handler",
            code=_lambda.Code.from_asset(
                "./",
                bundling=BundlingOptions(
                    image=_lambda.Runtime.PYTHON_3_11.bundling_image,
                    command=[
                        "bash",
                        "-c",
                        "pip install --no-cache -r requirements.txt -t /asset-output && cp -au . /asset-output",
                    ],
                ),
            ),
            log_retention=logs.RetentionDays.ONE_WEEK,
            timeout=Duration.minutes(10),
        )
        reproduce_cdk_issue.grant_invoke(
            iam.ServicePrincipal(
                "events.amazonaws.com"
            )
        )
        reproduce_cdk_issue.add_to_role_policy(logs_policy)

Now run the cdk synth

Bundling asset ReproduceCdkIssueStack/ReproduceCdkIssue/Code/Stage...
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
jsii.errors.JavaScriptError:
  Error: Failed to bundle asset ReproduceCdkIssueStack/ReproduceCdkIssue/Code/Stage, bundle output is located at /private/tmp/reproduce-cdk-issue/cdk.out/asset.03bc14d375e0fe07e0cbdd8ecbc90748d6975287ba819ff83fc06eb7df70430b-error: Error: docker exited with status 1
  --> Command: docker run --rm -u "1274739409:965809149" -v "/private/tmp/reproduce-cdk-issue:/asset-input:delegated" -v "/private/tmp/reproduce-cdk-issue/cdk.out/asset.03bc14d375e0fe07e0cbdd8ecbc90748d6975287ba819ff83fc06eb7df70430b:/asset-output:delegated" -w "/asset-input" "public.ecr.aws/sam/build-python3.11" bash -c "pip install --no-cache -r requirements.txt -t /asset-output && cp -au . /asset-output"
      at AssetStaging.bundle (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:619)
      at AssetStaging.stageByBundling (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:5297)
      at stageThisAsset (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2728)
      at Cache.obtain (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
      at new AssetStaging (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:3125)
      at new Asset (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1080)
      at AssetCode.bind (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4881)
      at new Function (/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/jsii-kernel-E4lgIM/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:9422)
      at Kernel._Kernel_create (/private/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/tmpfzttj8_y/lib/program.js:10108:25)
      at Kernel.create (/private/var/folders/9g/xgnmd_ss013541zns0vn7fxs5znypj/T/tmpfzttj8_y/lib/program.js:9779:93)

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

Traceback (most recent call last):
  File "/private/tmp/reproduce-cdk-issue/app.py", line 10, in <module>
    ReproduceCdkIssueStack(app, "ReproduceCdkIssueStack",
  File "/Users/shivpathak/work/crowdstrike-jira-integration/.venv/lib/python3.9/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/private/tmp/reproduce-cdk-issue/reproduce_cdk_issue/reproduce_cdk_issue_stack.py", line 26, in __init__
    reproduce_cdk_issue = _lambda.Function(
  File "/Users/shivpathak/work/crowdstrike-jira-integration/.venv/lib/python3.9/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/Users/shivpathak/work/crowdstrike-jira-integration/.venv/lib/python3.9/site-packages/aws_cdk/aws_lambda/__init__.py", line 25841, in __init__
    jsii.create(self.__class__, self, [scope, id, props])
  File "/Users/shivpathak/work/crowdstrike-jira-integration/.venv/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 334, in create
    response = self.provider.create(
  File "/Users/shivpathak/work/crowdstrike-jira-integration/.venv/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 365, in create
    return self._process.send(request, CreateResponse)
  File "/Users/shivpathak/work/crowdstrike-jira-integration/.venv/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 342, in send
    raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
RuntimeError: Failed to bundle asset ReproduceCdkIssueStack/ReproduceCdkIssue/Code/Stage, bundle output is located at /private/tmp/reproduce-cdk-issue/cdk.out/asset.03bc14d375e0fe07e0cbdd8ecbc90748d6975287ba819ff83fc06eb7df70430b-error: Error: docker exited with status 1
--> Command: docker run --rm -u "1274739409:965809149" -v "/private/tmp/reproduce-cdk-issue:/asset-input:delegated" -v "/private/tmp/reproduce-cdk-issue/cdk.out/asset.03bc14d375e0fe07e0cbdd8ecbc90748d6975287ba819ff83fc06eb7df70430b:/asset-output:delegated" -w "/asset-input" "public.ecr.aws/sam/build-python3.11" bash -c "pip install --no-cache -r requirements.txt -t /asset-output && cp -au . /asset-output"

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.130.0 (build bd6e5ee)

Framework Version

No response

Node.js Version

v18.17.1

OS

22.04.1-Ubuntu

Language

Python

Language Version

Python 3.8.18

Other information

No response

@shivpathak-teg shivpathak-teg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 29, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Feb 29, 2024
@shivpathak-teg
Copy link
Author

in reproduce step I forgot to mention that I did exported the default variable for cdk bootstrapping:

export CDK_DEFAULT_ACCOUNT=<my-aws-account-number>
export CDK_DEFAULT_REGION=us-east-1

@pahud
Copy link
Contributor

pahud commented Feb 29, 2024

I followed your steps and it works to me.

reproduce-cdk-issue % npx cdk synth
Bundling asset ReproduceCdkIssueStack/ReproduceCdkIssue/Code/Stage...
Unable to find image 'public.ecr.aws/sam/build-python3.11:latest' locally
latest: Pulling from sam/build-python3.11
6361f4a083b8: Already exists
ad1a4acb8be4: Already exists
f63b93097e74: Already exists
3b4f997427bc: Already exists
d254ea64cecf: Already exists
5467a235a254: Already exists
9d88804a4f6d: Pulling fs layer
d79cc589e61f: Pulling fs layer
d324af7d880c: Pulling fs layer
bacab1d8b86a: Pulling fs layer
215a470ee3a2: Pulling fs layer
385a28e8aa0c: Pulling fs layer
f34db0d3bb38: Pulling fs layer
727b5c52951a: Pulling fs layer
a47dca7c36f0: Pulling fs layer
385a28e8aa0c: Waiting
bacab1d8b86a: Waiting
215a470ee3a2: Waiting
a47dca7c36f0: Waiting
727b5c52951a: Waiting
f34db0d3bb38: Waiting
d79cc589e61f: Verifying Checksum
d79cc589e61f: Download complete
bacab1d8b86a: Verifying Checksum
bacab1d8b86a: Download complete
215a470ee3a2: Verifying Checksum
215a470ee3a2: Download complete
d324af7d880c: Verifying Checksum
d324af7d880c: Download complete
f34db0d3bb38: Verifying Checksum
f34db0d3bb38: Download complete
727b5c52951a: Verifying Checksum
727b5c52951a: Download complete
a47dca7c36f0: Verifying Checksum
a47dca7c36f0: Download complete
385a28e8aa0c: Verifying Checksum
385a28e8aa0c: Download complete
9d88804a4f6d: Verifying Checksum
9d88804a4f6d: Download complete
9d88804a4f6d: Pull complete
d79cc589e61f: Pull complete
d324af7d880c: Pull complete
bacab1d8b86a: Pull complete
215a470ee3a2: Pull complete
385a28e8aa0c: Pull complete
f34db0d3bb38: Pull complete
727b5c52951a: Pull complete
a47dca7c36f0: Pull complete
Digest: sha256:0814ef4fb45563e04c103a1cf207feb5dfe0ce560b55fa16b5368a9fddec968e
Status: Downloaded newer image for public.ecr.aws/sam/build-python3.11:latest
Collecting aws-cdk-lib==2.125.0 (from -r requirements.txt (line 1))
  Obtaining dependency information for aws-cdk-lib==2.125.0 from https://files.pythonhosted.org/packages/4e/03/bbce36e2ba342290cb16ce7d3c7493922abc0c37c12c997ab3b1e0d0d3f1/aws_cdk_lib-2.125.0-py3-none-any.whl.metadata
  Downloading aws_cdk_lib-2.125.0-py3-none-any.whl.metadata (59 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.3/59.3 kB 3.5 MB/s eta 0:00:00
Collecting constructs<11.0.0,>=10.0.0 (from -r requirements.txt (line 2))
  Obtaining dependency information for constructs<11.0.0,>=10.0.0 from https://files.pythonhosted.org/packages/8f/82/5b1407b9747a8c0133d56433dd9b67ec622558b4b47dad6b1751c9d5aeeb/constructs-10.3.0-py3-none-any.whl.metadata
  Downloading constructs-10.3.0-py3-none-any.whl.metadata (2.7 kB)
Collecting aws-cdk.asset-awscli-v1<3.0.0,>=2.2.202 (from aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for aws-cdk.asset-awscli-v1<3.0.0,>=2.2.202 from https://files.pythonhosted.org/packages/72/67/3e15a7bd6aa67e6e136b09fec7fc3e21483c7d8ad6ce38649117ae25a4dd/aws_cdk.asset_awscli_v1-2.2.202-py3-none-any.whl.metadata
  Downloading aws_cdk.asset_awscli_v1-2.2.202-py3-none-any.whl.metadata (1.1 kB)
Collecting aws-cdk.asset-kubectl-v20<3.0.0,>=2.1.2 (from aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for aws-cdk.asset-kubectl-v20<3.0.0,>=2.1.2 from https://files.pythonhosted.org/packages/d9/97/b4eaa76c87a745ecf61b7ab49a712653e6f5c71f8bd476e1a0d5215b55d3/aws_cdk.asset_kubectl_v20-2.1.2-py3-none-any.whl.metadata
  Downloading aws_cdk.asset_kubectl_v20-2.1.2-py3-none-any.whl.metadata (1.2 kB)
Collecting aws-cdk.asset-node-proxy-agent-v6<3.0.0,>=2.0.1 (from aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for aws-cdk.asset-node-proxy-agent-v6<3.0.0,>=2.0.1 from https://files.pythonhosted.org/packages/4d/82/e1acc95f74e93988fb67d4e66c167fbae7817efe1bc8e6a120506dc6318e/aws_cdk.asset_node_proxy_agent_v6-2.0.1-py3-none-any.whl.metadata
  Downloading aws_cdk.asset_node_proxy_agent_v6-2.0.1-py3-none-any.whl.metadata (1.2 kB)
Collecting jsii<2.0.0,>=1.94.0 (from aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for jsii<2.0.0,>=1.94.0 from https://files.pythonhosted.org/packages/7c/c0/b5cde57516ba7319604cbc1a4476d66ee5384ebe19a7719757afa345e814/jsii-1.94.0-py3-none-any.whl.metadata
  Downloading jsii-1.94.0-py3-none-any.whl.metadata (79 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.7/79.7 kB 13.2 MB/s eta 0:00:00
Collecting publication>=0.0.3 (from aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Downloading publication-0.0.3-py2.py3-none-any.whl (7.7 kB)
Collecting typeguard~=2.13.3 (from aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for typeguard~=2.13.3 from https://files.pythonhosted.org/packages/9a/bb/d43e5c75054e53efce310e79d63df0ac3f25e34c926be5dffb7d283fb2a8/typeguard-2.13.3-py3-none-any.whl.metadata
  Downloading typeguard-2.13.3-py3-none-any.whl.metadata (3.6 kB)
Collecting attrs<24.0,>=21.2 (from jsii<2.0.0,>=1.94.0->aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for attrs<24.0,>=21.2 from https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl.metadata
  Downloading attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)
Collecting cattrs<23.3,>=1.8 (from jsii<2.0.0,>=1.94.0->aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for cattrs<23.3,>=1.8 from https://files.pythonhosted.org/packages/b3/0d/cd4a4071c7f38385dc5ba91286723b4d1090b87815db48216212c6c6c30e/cattrs-23.2.3-py3-none-any.whl.metadata
  Downloading cattrs-23.2.3-py3-none-any.whl.metadata (10 kB)
Collecting importlib-resources>=5.2.0 (from jsii<2.0.0,>=1.94.0->aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for importlib-resources>=5.2.0 from https://files.pythonhosted.org/packages/ba/0b/27d13042335942abc29a87f49f1ce6b56fa58e025e96454ef25929aeb603/importlib_resources-6.1.2-py3-none-any.whl.metadata
  Downloading importlib_resources-6.1.2-py3-none-any.whl.metadata (3.9 kB)
Collecting python-dateutil (from jsii<2.0.0,>=1.94.0->aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for python-dateutil from https://files.pythonhosted.org/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl.metadata
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl.metadata (8.2 kB)
Collecting typing-extensions<5.0,>=3.8 (from jsii<2.0.0,>=1.94.0->aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for typing-extensions<5.0,>=3.8 from https://files.pythonhosted.org/packages/f9/de/dc04a3ea60b22624b51c703a84bbe0184abcd1d0b9bc8074b5d6b7ab90bb/typing_extensions-4.10.0-py3-none-any.whl.metadata
  Downloading typing_extensions-4.10.0-py3-none-any.whl.metadata (3.0 kB)
Collecting six>=1.5 (from python-dateutil->jsii<2.0.0,>=1.94.0->aws-cdk-lib==2.125.0->-r requirements.txt (line 1))
  Obtaining dependency information for six>=1.5 from https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl.metadata
  Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Downloading aws_cdk_lib-2.125.0-py3-none-any.whl (33.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 33.9/33.9 MB 11.9 MB/s eta 0:00:00
Downloading constructs-10.3.0-py3-none-any.whl (58 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.2/58.2 kB 15.1 MB/s eta 0:00:00
Downloading aws_cdk.asset_awscli_v1-2.2.202-py3-none-any.whl (16.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.2/16.2 MB 13.6 MB/s eta 0:00:00
Downloading aws_cdk.asset_kubectl_v20-2.1.2-py3-none-any.whl (25.4 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 25.4/25.4 MB 17.3 MB/s eta 0:00:00
Downloading aws_cdk.asset_node_proxy_agent_v6-2.0.1-py3-none-any.whl (1.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5/1.5 MB 18.8 MB/s eta 0:00:00
Downloading jsii-1.94.0-py3-none-any.whl (583 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 583.7/583.7 kB 18.4 MB/s eta 0:00:00
Downloading typeguard-2.13.3-py3-none-any.whl (17 kB)
Downloading attrs-23.2.0-py3-none-any.whl (60 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.8/60.8 kB 30.2 MB/s eta 0:00:00
Downloading cattrs-23.2.3-py3-none-any.whl (57 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.5/57.5 kB 20.5 MB/s eta 0:00:00
Downloading importlib_resources-6.1.2-py3-none-any.whl (34 kB)
Downloading typing_extensions-4.10.0-py3-none-any.whl (33 kB)
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 21.7 MB/s eta 0:00:00
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: publication, typing-extensions, typeguard, six, importlib-resources, attrs, python-dateutil, cattrs, jsii, constructs, aws-cdk.asset-node-proxy-agent-v6, aws-cdk.asset-kubectl-v20, aws-cdk.asset-awscli-v1, aws-cdk-lib
Successfully installed attrs-23.2.0 aws-cdk-lib-2.125.0 aws-cdk.asset-awscli-v1-2.2.202 aws-cdk.asset-kubectl-v20-2.1.2 aws-cdk.asset-node-proxy-agent-v6-2.0.1 cattrs-23.2.3 constructs-10.3.0 importlib-resources-6.1.2 jsii-1.94.0 publication-0.0.3 python-dateutil-2.8.2 six-1.16.0 typeguard-2.13.3 typing-extensions-4.10.0

Looking at your directory structure I think you should separate the lambda code from your CDK code. The requirements.txt comes with cdk init -l python is for CDK project, not for your lambda function.

Check my screenshot here for your reference

image

@pahud
Copy link
Contributor

pahud commented Feb 29, 2024

Moving to discussion as this doesn't appear to be a bug.

@aws aws locked and limited conversation to collaborators Feb 29, 2024
@pahud pahud converted this issue into discussion #29314 Feb 29, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants