question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

‼️ (aws-lambda-python): SAM - CDK integration is broken in CDK V2.4.0

See original GitHub issue

What is the problem?

There is a new change in CDK Version 2.4.0 that makes the bundled assets to be created under the folder structure as following:

├── <asset root>
│   └── asset-input
│       ├── asset files

The issue is SAM expects to get the asset location in metadata property aws:asset:path, so SAM can read the Lambda Function source code, so the customers can do local testing, but in the new Version, the value of the added metadata is the path till the Asset root directory (till the <Asset Hash>), although it should be (<Asset Hash>/asset-input)

For an application that contains a PythonFunction, This is the directory structure after running cdk synth using version 2.4.0

147dda696921:cdk_app melasmar$ cdk --version
2.4.0 (build 993f14d)
147dda696921:cdk_app melasmar$ cd cdk.out
147dda696921:cdk.out melasmar$ tree
.
├── CDKV2SupportDemoStack.assets.json
├── CDKV2SupportDemoStack.template.json
├── asset.993168cfa75b295eeea55bf603340284b9be46ebc079e4965f2c16f5470efda5
│   └── asset-input
│       ├── __init__.py
│       └── app.py
├── cdk.out
├── manifest.json
└── tree.json

and this is the synthesized template:

"MyFunction3BAA72D1": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
              ............   
        },
      "DependsOn": [
        "MyFunctionServiceRole3C357FF2"
      ],
      "Metadata": {
        "aws:cdk:path": "CDKV2SupportDemoStack/MyFunction/Resource",
        "aws:asset:path": "asset.993168cfa75b295eeea55bf603340284b9be46ebc079e4965f2c16f5470efda5",
        "aws:asset:is-bundled": true,
        "aws:asset:property": "Code"
      }

and this is the output in case of using CDK version 2.3.0

147dda696921:cdk_app melasmar$ cdk --version
2.3.0 (build beaa5b2)
147dda696921:cdk_app melasmar$ cd cdk.out
147dda696921:cdk.out melasmar$ tree
.
├── CDKV2SupportDemoStack.assets.json
├── CDKV2SupportDemoStack.template.json
├── asset.8f47b59bc8d67146c1b3fdd46c077e64cf2e0021298beb44f424619eeaaad8d0
│   ├── __init__.py
│   └── app.py
├── cdk.out
├── manifest.json
└── tree.json

and this is the synthesized template:

"MyFunction3BAA72D1": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
         .........
      },
      "DependsOn": [
        "MyFunctionServiceRole3C357FF2"
      ],
      "Metadata": {
        "aws:cdk:path": "CDKV2SupportDemoStack/MyFunction/Resource",
        "aws:asset:path": "asset.8f47b59bc8d67146c1b3fdd46c077e64cf2e0021298beb44f424619eeaaad8d0",
        "aws:asset:is-bundled": true,
        "aws:asset:property": "Code"
      }
    },

Reproduction Steps

  • create a simple CDK stack that contains a PythonFunction.
  • run cdk synth
  • check the synthesized template, and the bundled assets directory

What did you expect to happen?

The value of the added aws:asset:path metadata property should be the location of the source code of the bundled assets.

What actually happened?

The value of the added aws:asset:path metadata property is the root asset directory.

CDK CLI Version

2.4.0

Framework Version

No response

Node.js Version

v14.15.4

OS

mac os

Language

Typescript

Language Version

No response

Other information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
gshpychkacommented, Feb 15, 2022

@corymhall can you reopen this? It’s still an issue.

2reactions
connorstorer-kescommented, Feb 5, 2022

Currently working with the following: aws-cdk-lib==2.5.0 aws-cdk.aws-lambda-python-alpha==2.3.0a0

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS SAM integration - AWS Documentation
The AWS CDK and the AWS Serverless Application Model (AWS SAM) can work together to let you to locally build and test serverless...
Read more >
Lambda can't find modules from outer folders when deployed ...
Problem was CDK not deploying the node_modules folder and other folders which are outside the folder which contains the lambda source file. When ......
Read more >
Tag Archives: AWS SAM - Noise
Another change to AWS CDK v2 is the removal of experimental modules. To help promote API stability and comply with semantic versioning, CDK...
Read more >
aws-cdk | Yarn - Package Manager
The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework to define cloud infrastructure in code and provision it through...
Read more >
AWS Toolkit - IntelliJ IDEs Plugin - JetBrains Marketplace
Screenshot 2. The AWS Toolkit for JetBrains makes it easier to write applications built on Amazon Web Services. If you come across bugs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found