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.

(cli): `--hotswap` does not detect function env variables changes

See original GitHub issue

The new hot-swap feature doesn’t detect function prop changes like environment variables.

Reproduction Steps

app.ts

export class BugStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props: cdk.StackProps = {}) {
    super(scope, id, props);

    const dateString = new Date().toISOString();

    new lambda.Function(this, 'Function', {
      runtime: lambda.Runtime.NODEJS_14_X,
      code: lambda.Code.fromAsset(__dirname),
      handler: 'bug-handler.handler',
      environment: {
        ENV_VARS_LAST_UPDATE: dateString,
      },
    });
  }
}

const app = new cdk.App();
new BugStack(app, 'BugStack');

bug-handler.js

exports.handler = async () => process.env.ENV_VARS_LAST_UPDATE || 'unset';

What did you expect to happen?

I expected cdk deploy BugStack --hotswap to deploy the stack every time I ran it.

What actually happened?

It said (no changes) on the second deployment, failing to update the environment variable.

Environment

  • CDK CLI Version : 1.122.0
  • Framework Version: 1.122.0
  • Node.js Version: v14.15.4
  • OS : Windows
  • Language (Version): TypeScript (4.4.2)

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
skinny85commented, Sep 10, 2021

Yeah, this definitely looks like a bug in the diff command (which hotswap uses, like you correctly guessed).

1reaction
skinny85commented, Sep 10, 2021

Thanks @misterjoshua!

If I could ask for one more thing 🙂. Before running cdk deploy --hotswap, can you run cdk diff, and show me the output of that command?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Swapping - LocalStack Docs
This way you can easily import modules from your virtualenv, without having to change the file system layout. Note: As an alternative to...
Read more >
AWS CDK Toolkit (cdk command) - AWS Documentation
Use the --hotswap flag with cdk deploy to attempt to update your AWS resources directly instead of generating an AWS CloudFormation changeset and...
Read more >
Using HotswapAgent to Speed up Development - Blog | Payara
In this post, I'm going to write up how I got the HotswapAgent running in my IDE and Payara Server.
Read more >
Azure Functions deployment slots | Microsoft Learn
With a function app that is running under an App Service plan, you can change the underlying App Service plan for a slot....
Read more >
AWS CDK Toolkit - npm
If the tool detects that the change does not support hotswapping, it will fall back and perform a full CloudFormation deployment, exactly like ......
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