Skip to content

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

@misterjoshua

Description

@misterjoshua

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.effort/smallSmall work item – less than a day of effortin-progressThis issue is being actively worked on.package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions