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.

Code.fromAsset("...") is not updating lambda-functions

See original GitHub issue

Description

When I create a lambda-function within a cdk-stack based on Code.fromAsset("dist", { exclude: ["**", "!lambda-already-bundled-with-webpack.js"] }), then the lambda-function, when deployed for the first time, works fine. But when a code-update to the lambda-function is made, a re-deploy of the same cdk-stack is not updating the code of the deployed lambda-function. The lambda-function still has the old code from the first deployment. A cdk diff also says that no changes were detected…

Reproduction Steps

Error Log

Environment

  • **CLI Version :1.35.0
  • **Framework Version:1.35.0
  • **OS :macOS Catalina 10.15.4
  • **Language :typescript

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nija-atcommented, May 15, 2020

I just tried your example and it worked fine for me.

The CDK app I used -

import { Function, Code, Runtime } from '@aws-cdk/aws-lambda';
import { App, Stack } from '@aws-cdk/core';

const app = new App();
const stack = new Stack(app, 'mystack-lambda');

new Function(stack, 'myfn', {
  runtime: Runtime.NODEJS_12_X,
  handler: 'index.handler',
  code: Code.fromAsset('resources', {
    exclude: [ '**', '!a.js']
  })
})

The resources/ folder looks like this -

⇒  tree resources
resources
├── a.js
├── b.js
└── fs
    └── c.js

1 directory, 3 files

and the asset folder looks like this -

⇒  tree cdk.out/asset.612208983ad862413ed9c910ace722035cd862a55d2b8d203a2e04c7538ea257
cdk.out/asset.612208983ad862413ed9c910ace722035cd862a55d2b8d203a2e04c7538ea257
└── a.js

0 directories, 1 file

I believe this matches what was intended with the exclude option.

0reactions
nija-atcommented, May 15, 2020

Nice. Thanks @jogold. Resolving this issue.

Feel free to re-open with more details if it persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dev notes: aws-cdk not updating Lambda function
When using the aws-cdk Lambda docs and examples, the code for the Lambda function is fetched by lambda.Code.fromAsset() This is from a local ......
Read more >
CDK not updating - Stack Overflow
Create a new lambda version. Then the lambda's code updates when you deploy the CDK stack! const versionIdKey = 'Versions.0.
Read more >
aws-cdk/aws-lambda module - AWS Documentation
NOTE: The currentVersion property is only supported when your AWS Lambda function uses either lambda.Code.fromAsset or lambda.Code.fromInline .
Read more >
Creating Lambda Functions in AWS CDK - Complete Guide
The static fromAsset method on the Code class takes a path to a directory on the local file system, where our lambda handler...
Read more >
AWS lambda function not updating - Atlassian Community
Solved: hi. I have a bamboo build plan with two steps: "source code checkout" "aws lambda function" everything seems to work.
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