Skip to content

cdk diff: ignores cloudformation parameters #1995

Description

@ChristerGustavsson

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

  • Select this option if this issue appears to be a regression.

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"
Image

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

Activity

  1. added theissue type on Sep 24, 2026
  2. changed the issue type fromtoon Sep 24, 2026
  3. proton0210 commented on Oct 8, 2026

    @proton0210
    Contributor

    Draft implementation is in #2030: diff now accepts --parameters and forwards global/stack-qualified values to change-set preparation. Template-only modes reject the option explicitly. All 107 relevant CLI unit tests pass, and the added live parameter-diff integration test compiles. The PR remains draft until that test runs in a disposable AWS account; no live result is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions