Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(aws-lambda): CDK does not update Lambda environment variables #26184

Closed
Schwartz-Matthew-bah opened this issue Jun 30, 2023 · 3 comments
Closed
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@Schwartz-Matthew-bah
Copy link

Describe the bug

After deploying a Lambda function, all future modifications to the function's environment variables must be done manually.

Changing the environment variables in CDK and redeploying does not update the variables.

Expected Behavior

CDK should update the Lambda function configuration such that it matches what is codified.

Current Behavior

CDK ignores changes to Lambda environment variables.

Reproduction Steps

Deploy a lambda function with environment variables, for example:

    const lambdaFunction = new lambda.Function(this, 'MyLambdaFunction', {
      runtime: lambda.Runtime.NODEJS_16_X,
      code: lambda.Code.fromAsset('lambda'),
      handler: 'index.handler',
      environment: {
        LOG_LEVEL: 'INFO',
      },
    });

Now change the LOG_LEVEL variable from 'INFO' to 'DEBUG' and redeploy your stack.

    const lambdaFunction = new lambda.Function(this, 'MyLambdaFunction', {
      runtime: lambda.Runtime.NODEJS_16_X,
      code: lambda.Code.fromAsset('lambda'),
      handler: 'index.handler',
      environment: {
        LOG_LEVEL: 'DEBUG',
      },
    });

The variable value does not change.

Screenshot 2023-06-30 at 10 22 33 AM

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.86.0 (build 1130fab)

Framework Version

No response

Node.js Version

v16.14.0

OS

MacOS Catalina

Language

Typescript

Language Version

No response

Other information

No response

@Schwartz-Matthew-bah Schwartz-Matthew-bah added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 30, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jun 30, 2023
@Schwartz-Matthew-bah
Copy link
Author

Seems like this happens specifically if you skip the npm run build step before running cdk deploy

@Schwartz-Matthew-bah
Copy link
Author

Nevermind, I can no longer reproduce. Looks like its working fine.

@github-actions
Copy link

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant