Describe the bug
Running cdk diff on a stack with parameters passed to lambda functions as environment variables always assume it's using the default parameter values. This makes it show a diff when a previous deploy has set parameters to value different from the default value.
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I expected to be able to send parameters used for diffs. Either with passing them again, or using a similar flag to cdk deploy with --previous-parameters
Current Behavior
Currently the parameters gets their default values and show diffs, if they have been updated by a deploy with values not equal to the default
Reproduction Steps
For example with a simple stack that uses a parameter, sent as environment to a lambda function
import { Construct } from 'constructs'
import * as cdk from 'aws-cdk-lib/core'
import * as lambda from 'aws-cdk-lib/aws-lambda'
export default class StackWithParameters extends cdk.Stack {
constructor(scope: Construct) {
super(scope, 'StackWithParameters')
const logLevel = new cdk.CfnParameter(this, 'LogLevel', {
type: 'String',
description: 'The log level to use for lambda functions, defaults to "INFO"',
default: 'INFO',
})
new lambda.Function(this, 'Function', {
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_LATEST,
environment: {
LOG_LEVEL: logLevel.valueAsString,
},
})
}
}
When deployed with parameter set to "DEBUG":
npx cdk deploy -e StackWithParameters --parameters "StackWithParameters:LogLevel=DEBUG"
It will always show a diff on the lambda environment variables:
npx cdk diff -e StackWithParameters --parameters "StackWithParameters:LogLevel=DEBUG"
Possible Solution
Add --parameters, or --previous-parameters to the cdk diff command
Additional Information/Context
No response
CDK CLI Version
2.1139.0 (build d51353e)
Framework Version
2.266.0
Node.js Version
v24.14.1
OS
macOs 26.6.2 (25G83)
Language
TypeScript
Language Version
TypeScript (6.0.3)
Other information
No response
Describe the bug
Running
cdk diffon a stack with parameters passed to lambda functions as environment variables always assume it's using the default parameter values. This makes it show a diff when a previous deploy has set parameters to value different from the default value.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I expected to be able to send parameters used for diffs. Either with passing them again, or using a similar flag to
cdk deploywith--previous-parametersCurrent Behavior
Currently the parameters gets their default values and show diffs, if they have been updated by a deploy with values not equal to the default
Reproduction Steps
For example with a simple stack that uses a parameter, sent as environment to a lambda function
When deployed with parameter set to "DEBUG":
npx cdk deploy -e StackWithParameters --parameters "StackWithParameters:LogLevel=DEBUG"It will always show a diff on the lambda environment variables:
npx cdk diff -e StackWithParameters --parameters "StackWithParameters:LogLevel=DEBUG"Possible Solution
Add
--parameters, or--previous-parametersto thecdk diffcommandAdditional Information/Context
No response
CDK CLI Version
2.1139.0 (build d51353e)
Framework Version
2.266.0
Node.js Version
v24.14.1
OS
macOs 26.6.2 (25G83)
Language
TypeScript
Language Version
TypeScript (6.0.3)
Other information
No response