> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/infrastructure-as-code-management/use-iacm/iac-provisioners/aws-cdk/cdk-runtime-version.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Configure CDK plugin variables

Configure CDK plugin variables to override runtime versions, control diff behavior, and use pre-baked binaries in locked-down environments.

The IaCM CDK plugin reads version and behavior configuration from the workspace UI. You can override that configuration using pipeline or stage variables when the workspace settings do not meet your requirements: for example, when a CDK version is not yet available in the workspace version selector, when you need to control how `cdk diff` runs, or when your environment cannot download binaries at runtime.

{% hint style="warning" %}
**Overridden versions are not validated by Harness**

Versions specified through plugin variables are installed at runtime from upstream package registries. Harness does not test these versions for compatibility with the IaCM plugin. Validate the versions with your CDK application before using them in production.
{% endhint %}

***

## Before you begin

* **Pipeline permissions:** To create or edit a pipeline, your Harness role must include the **Pipeline: Create/Edit** permission. Contact your account administrator to assign a role that includes this permission.
* **Compatible versions:** Confirm that the CDK CLI version, language runtime version, and package manager version you need are compatible with each other and with your CDK app before setting overrides.
* Go to [IaCM plugins](https://developer.harness.io/infrastructure-as-code-management/platform/iacm-connectors-variables/iacm-plugins.md) to review all available plugin environment variables.

***

## Plugin variables

Use the following pipeline or stage variables to override the versions and behavior configured in the workspace UI. Set only the variables you want to override.

### CDK CLI, language, and package manager versions

| Variable                                | Purpose                                                                              | Example value |
| --------------------------------------- | ------------------------------------------------------------------------------------ | ------------- |
| `PLUGIN_TF_VERSION`                     | Overrides the CDK CLI version. This variable is shared across all IaCM provisioners. | `2.175.0`     |
| `PLUGIN_AWSCDK_LANGUAGE`                | Overrides the language runtime.                                                      | `python`      |
| `PLUGIN_AWSCDK_LANGUAGE_VERSION`        | Overrides the language runtime version.                                              | `3.13`        |
| `PLUGIN_AWSCDK_PACKAGE_MANAGER`         | Overrides the package manager.                                                       | `pip`         |
| `PLUGIN_AWSCDK_PACKAGE_MANAGER_VERSION` | Overrides the package manager version.                                               | `25.3`        |

{% hint style="info" %}
**`PLUGIN_TF_VERSION` is shared with Terraform and OpenTofu**

`PLUGIN_TF_VERSION` is the provisioner version variable used by all IaCM provisioners. For CDK workspaces, it controls the CDK CLI version. Setting it on a Terraform or OpenTofu workspace changes the provisioner version for that workspace instead.
{% endhint %}

### CDK behavior variables

| Variable                    | Purpose                                                                                                                                                                                                                        | Default | Example value |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- | ------------- |
| `PLUGIN_DIFF_VIA_CHANGESET` | Controls whether `cdk diff` uses a CloudFormation change set (`true`) or runs `cdk diff` directly (`false`). Direct diff produces human-readable text output without a tabular resource summary.                               | `true`  | `false`       |
| `PLUGIN_DRIFT_VIA_CFN`      | Controls whether drift detection uses the [CloudFormation drift detection API](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html) (`true`) or a change-set-based comparison (`false`). | `true`  | `false`       |
| `PLUGIN_DEPLOY_VIA_CFN`     | Controls whether deployment uses the CloudFormation-based method (`true`) or the direct CDK deployment method (`false`).                                                                                                       | `true`  | `false`       |

CloudFormation-based operations provide additional visibility in the AWS Console, including stack events, rollback behavior, and change set details.

{% hint style="warning" %}
**Behavior variables follow workspace variable precedence**

`PLUGIN_DIFF_VIA_CHANGESET`, `PLUGIN_DRIFT_VIA_CFN`, and `PLUGIN_DEPLOY_VIA_CFN` follow workspace variable precedence. If you set one of these on the workspace **Connectors and Variables** tab, the workspace value takes precedence over a pipeline or stage variable with the same name. To ensure the pipeline variable takes effect, remove the matching environment variable from the workspace.
{% endhint %}

### Expected value format

Version strings must match the format used by the tool's official distribution:

* **CDK CLI:** `2.x.y` format. Go to [AWS CDK releases on npm](https://www.npmjs.com/package/aws-cdk?activeTab=versions) to find published versions. The plugin installs the CDK CLI at this exact version using `npm install aws-cdk@<version>`.
* **Language runtime:** The version format used by the runtime, such as `3.13` for Python or `20.11.0` for Node.js.
* **Package manager:** The versioning scheme of the package manager, such as `10.2.4` for npm or `25.3` for pip.
* **Language and package manager type:** A string name, such as `python` or `pip`.

### Variable precedence

All plugin variables — both version variables and behavior variables — follow standard workspace variable precedence. If the same variable is set both on the workspace **Connectors and Variables** tab and in the pipeline or stage, the workspace value takes precedence. To use a pipeline or stage override, remove the matching variable from the workspace.

***

## Set a version override

To set a version override, open the pipeline in the Harness pipeline editor. Select the **Variables** tab to add a pipeline-level variable (applies to all stages), or select the stage and open its **Variables** section to add a stage-level variable (applies to that stage only).

### Pipeline-level override

```yaml
pipeline:
  variables:
    - name: PLUGIN_TF_VERSION
      type: String
      value: 2.175.0
```

### Stage-level override

```yaml
stage:
  variables:
    - name: PLUGIN_TF_VERSION
      type: String
      value: 2.175.0
    - name: PLUGIN_AWSCDK_LANGUAGE_VERSION
      type: String
      value: 3.13
```

### Example: Override the CDK CLI version

A workspace is configured with CDK `2.150.0` in the workspace UI, but the CDK app requires `2.175.0`. Set the following stage variables:

```
PLUGIN_TF_VERSION                       = 2.175.0
PLUGIN_AWSCDK_LANGUAGE                  = python
PLUGIN_AWSCDK_LANGUAGE_VERSION          = 3.13
PLUGIN_AWSCDK_PACKAGE_MANAGER           = pip
PLUGIN_AWSCDK_PACKAGE_MANAGER_VERSION   = 25.3
```

The workspace UI continues to display `2.150.0`. During execution, the plugin installs and uses `2.175.0` for the CDK CLI and `3.13` for Python. Check the CDK step logs at the start of the run to confirm that the plugin is installing the overridden versions.

***

## Use pre-baked binaries

If your CDK app runs in a locked-down VPC where public package registries are not reachable, or you want to avoid downloading binaries at every runtime, you can point the plugin to pre-baked binaries in a custom image or shared volume.

| Variable                                  | Binary           |
| ----------------------------------------- | ---------------- |
| `PLUGIN_AWSCDK_EXEC_PATH`                 | CDK CLI          |
| `PLUGIN_AWSCDK_LANGUAGE_EXEC_PATH`        | Language runtime |
| `PLUGIN_AWSCDK_PACKAGE_MANAGER_EXEC_PATH` | Package manager  |

Set each variable to the directory path where the binary is located. The plugin searches for the version specified in the workspace configuration, or the version override variables, at the given path. If the version is found, the plugin uses it without downloading.

Because these paths typically apply to all runs in a workspace, set them on the workspace **Connectors and Variables** tab rather than in the pipeline:

```yaml
# workspace Connectors and Variables tab
PLUGIN_AWSCDK_EXEC_PATH                  = /opt/cdk/bin
PLUGIN_AWSCDK_LANGUAGE_EXEC_PATH         = /opt/python/bin
PLUGIN_AWSCDK_PACKAGE_MANAGER_EXEC_PATH  = /opt/pip/bin
```

If you need to override the paths for a specific pipeline run, you can also set them as pipeline or stage variables:

```yaml
stage:
  variables:
    - name: PLUGIN_AWSCDK_EXEC_PATH
      type: String
      value: /opt/cdk/bin
    - name: PLUGIN_AWSCDK_LANGUAGE_EXEC_PATH
      type: String
      value: /opt/python/bin
    - name: PLUGIN_AWSCDK_PACKAGE_MANAGER_EXEC_PATH
      type: String
      value: /opt/pip/bin
```

{% hint style="warning" %}
**Fallback download requires registry access**

If the plugin does not find the specified version at the given path, it attempts to download the binary from the upstream registry. In a locked-down VPC without registry access, this fallback fails and the step errors. Pre-bake the exact version specified in the workspace configuration or the override variables to prevent this.
{% endhint %}

***

## Troubleshooting

<details>

<summary>The step fails because the specified version is not available</summary>

If the version string in `PLUGIN_TF_VERSION` or `PLUGIN_AWSCDK_LANGUAGE_VERSION` does not exist in the upstream registry, the plugin step fails with a download error. Verify the version string against the official release list:

* CDK CLI: go to [AWS CDK releases on npm](https://www.npmjs.com/package/aws-cdk?activeTab=versions)
* Node.js: go to the [Node.js releases page](https://nodejs.org/en/about/previous-releases)
* Python: go to the [Python downloads page](https://www.python.org/downloads/)

</details>

<details>

<summary>The step fails in a locked-down VPC even though binary paths are set</summary>

If the binary is not found at the path specified in `PLUGIN_AWSCDK_EXEC_PATH` (or the language or package manager equivalent), the plugin falls back to downloading from the upstream registry. In environments without registry access, that fallback fails.

Confirm that the binary version at the specified path exactly matches the version configured in the workspace or the override variable.

</details>

<details>

<summary>A pipeline or stage variable for a version setting is not taking effect</summary>

Version variables (`PLUGIN_TF_VERSION`, `PLUGIN_AWSCDK_LANGUAGE`, `PLUGIN_AWSCDK_LANGUAGE_VERSION`, `PLUGIN_AWSCDK_PACKAGE_MANAGER`, `PLUGIN_AWSCDK_PACKAGE_MANAGER_VERSION`) follow standard workspace variable precedence. If the same variable is set on the workspace **Connectors and Variables** tab, the workspace value takes precedence over the pipeline or stage variable.

Check the workspace **Connectors and Variables** tab and remove the matching variable from the workspace so the pipeline or stage value can take effect.

</details>

<details>

<summary>A pipeline variable for a behavior setting is not taking effect</summary>

Behavior variables (`PLUGIN_DIFF_VIA_CHANGESET`, `PLUGIN_DRIFT_VIA_CFN`, `PLUGIN_DEPLOY_VIA_CFN`) follow workspace variable precedence. If the same variable is also set on the workspace **Connectors and Variables** tab, the workspace value takes precedence over the pipeline or stage variable.

Check the workspace **Connectors and Variables** tab and remove the matching environment variable from the workspace so the pipeline variable can take effect.

</details>

***

## Next steps

* Go to [IaCM plugins](https://developer.harness.io/infrastructure-as-code-management/platform/iacm-connectors-variables/iacm-plugins.md) to review all available plugin environment variables.
* Go to [Get started with AWS CDK](https://developer.harness.io/infrastructure-as-code-management/new-to-iacm/get-started/aws-cdk-get-started.md) to configure a CDK workspace.
* Go to [AWS CDK pipeline steps](https://developer.harness.io/infrastructure-as-code-management/use-iacm/iac-provisioners/aws-cdk/cdk-pipeline-steps.md) to configure CDK pipeline steps.

{% @harness-feedback/feedback %}
