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

(cli ls): building of Lambda layers is not disabled during "cdk ls" #14747

Closed
imincik opened this issue May 18, 2021 · 2 comments · Fixed by #16192
Closed

(cli ls): building of Lambda layers is not disabled during "cdk ls" #14747

imincik opened this issue May 18, 2021 · 2 comments · Fixed by #16192
Labels
bug This issue is a bug. effort/medium Medium work item – several days of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@imincik
Copy link

imincik commented May 18, 2021

Lambda functions bundling is disabled by default when running command such as cdk ls , but building of Lambda layers is not.

This results in long delays until command returns desired output and output is populated by Docker build messages which makes it very hard to read. Also, Docker image needs to be downloaded when not locally available, which can extend command execution time to very long time.

Reproduction Steps

Run cdk ls with following code in app.py:

from aws_cdk import aws_lambda, aws_lambda_python, core


class LambdaLayer(core.Stack):
    def __init__(self, app: core.App, stack_id: str) -> None:
        super().__init__(app, stack_id)

        layer = aws_lambda_python.PythonLayerVersion(
            self,
            f"lambda-layer",
            entry=".",
            compatible_runtimes=[aws_lambda.Runtime.PYTHON_3_8],
        )


app = core.App()
LambdaLayer(app, "lambda-layer")
app.synth()

What did you expect to happen?

I expect command to quickly return list of CDK stacks .

What actually happened?

CDK starts downloading Docker image it needs to build Lambda layer (executed only once) and builds the layer (executed always).

Command output is following:

$ cdk ls

Sending build context to Docker daemon  2.048kB
Step 1/4 : ARG IMAGE=amazon/aws-sam-cli-build-image-python3.7
Step 2/4 : FROM $IMAGE
 ---> 40e4293ff66e
Step 3/4 : RUN yum -q list installed rsync &>/dev/null || yum install -y rsync
 ---> Using cache
 ---> f0d7fe9bb69b
Step 4/4 : CMD [ "python" ]
 ---> Running in edeba5efd7dc
Removing intermediate container edeba5efd7dc
 ---> d5ca8ee099d3
Successfully built d5ca8ee099d3
Successfully tagged cdk-9215bb63fac76077ff7cf3db5f65c8184df47c073d23e625953a8fd0fd539612:latest
lambda-layer

Environment

  • CDK CLI Version : 1.103.0 (build bc13a66)
  • Framework Version:
  • Node.js Version: v14.15.4
  • OS : Ubuntu 18.04
  • Language (Version): Python 3.8.6

Other


This is 🐛 Bug Report

@imincik imincik added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 18, 2021
@peterwoodworth peterwoodworth added the package/tools Related to AWS CDK Tools or CLI label May 18, 2021
@rix0rrr rix0rrr added effort/medium Medium work item – several days of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jun 4, 2021
@rix0rrr rix0rrr removed their assignment Jun 4, 2021
@corymhall
Copy link
Contributor

CDK starts downloading Docker image it needs to build Lambda layer (executed only once) and builds the layer (executed always).

The Docker image will still be downloaded, but the building of the layer should no longer occur in the latest version of the CDK (2.4.0/1.38.0).

@mergify mergify bot closed this as completed in #16192 Mar 4, 2022
mergify bot pushed a commit that referenced this issue Mar 4, 2022
…o bundle assets (#16192)

`DockerImage.fromBuild` was being called for bundling regardless of whether the stack needed bundling or not. With this change, we will check if the stack needs bundling before proceeding to build the docker image.

Fixes #14747

----

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

github-actions bot commented Mar 4, 2022

⚠️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.

TheRealAmazonKendra pushed a commit to TheRealAmazonKendra/aws-cdk that referenced this issue Mar 11, 2022
…o bundle assets (aws#16192)

`DockerImage.fromBuild` was being called for bundling regardless of whether the stack needed bundling or not. With this change, we will check if the stack needs bundling before proceeding to build the docker image.

Fixes aws#14747

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/medium Medium work item – several days of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants