|
| 1 | +--- |
| 2 | +page_title: "helm: helm_diff" |
| 3 | +sidebar_current: "docs-helm-diff" |
| 4 | +description: |- |
| 5 | +
|
| 6 | +--- |
| 7 | +# Data Source: helm_diff |
| 8 | + |
| 9 | +Compare a proposed Helm chart configuration against a deployed release. |
| 10 | + |
| 11 | +`helm_diff` compares a proposed chart configuration against what is currently deployed in the Kubernetes cluster and outputs the differences. This is useful for drift detection, change preview before upgrades, and CI/CD integration. |
| 12 | + |
| 13 | +<!-- schema generated by tfplugindocs --> |
| 14 | +## Schema |
| 15 | + |
| 16 | +### Required |
| 17 | + |
| 18 | +- `chart` (String) Chart name to be installed. A path may be used. |
| 19 | +- `name` (String) Release name |
| 20 | + |
| 21 | +### Optional |
| 22 | + |
| 23 | +- `api_versions` (List of String) Kubernetes api versions used for Capabilities.APIVersions. |
| 24 | +- `create_namespace` (Boolean) Create the namespace if it does not exist. |
| 25 | +- `dependency_update` (Boolean) Run helm dependency update before installing the chart. |
| 26 | +- `description` (String) Add a custom description. |
| 27 | +- `devel` (Boolean) Use chart development versions, too. Equivalent to version '>0.0.0-0'. If `version` is set, this is ignored. |
| 28 | +- `disable_openapi_validation` (Boolean) If set, the installation process will not validate rendered templates against the Kubernetes OpenAPI Schema. |
| 29 | +- `disable_webhooks` (Boolean) Prevent hooks from running. |
| 30 | +- `include_crds` (Boolean) Include CRDs in the templated output. |
| 31 | +- `keyring` (String) Location of public keys used for verification. Used only if `verify` is true. |
| 32 | +- `kube_version` (String) Kubernetes version used for Capabilities.KubeVersion. |
| 33 | +- `namespace` (String) Namespace to install the release into. |
| 34 | +- `pass_credentials` (Boolean) Pass credentials to all domains |
| 35 | +- `postrender` (Attributes) Postrender command config (see [below for nested schema](#nestedatt--postrender)) |
| 36 | +- `render_subchart_notes` (Boolean) If set, render subchart notes along with the parent. |
| 37 | +- `repository` (String) Repository where to locate the requested chart. If it is a URL the chart is installed without installing the repository. |
| 38 | +- `repository_ca_file` (String) The repository's CA file |
| 39 | +- `repository_cert_file` (String) The repository's cert file |
| 40 | +- `repository_key_file` (String) The repository's cert key file |
| 41 | +- `repository_password` (String, Sensitive) Password for HTTP basic authentication |
| 42 | +- `repository_username` (String) Username for HTTP basic authentication |
| 43 | +- `set` (Attributes Set) Custom values to be merged with the values (see [below for nested schema](#nestedatt--set)) |
| 44 | +- `set_list` (Attributes List) Custom sensitive values to be merged with the values (see [below for nested schema](#nestedatt--set_list)) |
| 45 | +- `set_sensitive` (Attributes Set) Custom sensitive values to be merged with the values (see [below for nested schema](#nestedatt--set_sensitive)) |
| 46 | +- `set_wo` (Attributes List) Write-only custom values to be merged with the values. (see [below for nested schema](#nestedatt--set_wo)) |
| 47 | +- `skip_crds` (Boolean) If set, no CRDs will be installed. By default, CRDs are installed if not already present. |
| 48 | +- `timeout` (Number) Time in seconds to wait for any individual Kubernetes operation. |
| 49 | +- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts)) |
| 50 | +- `validate` (Boolean) Validate your manifests against the Kubernetes cluster you are currently pointing at. This is the same validation performed on an install. |
| 51 | +- `values` (List of String) List of values in raw yaml format to pass to helm. |
| 52 | +- `verify` (Boolean) Verify the package before installing it. |
| 53 | +- `version` (String) Specify the exact chart version to install. If this is not specified, the latest version is installed. |
| 54 | + |
| 55 | +### Read-Only |
| 56 | + |
| 57 | +- `current_manifest` (String) Currently deployed manifest |
| 58 | +- `diff` (String) Unified diff output |
| 59 | +- `diff_json` (String) Structured JSON diff |
| 60 | +- `has_changes` (Boolean) Whether any changes were detected |
| 61 | +- `id` (String) The ID of this resource. |
| 62 | +- `proposed_manifest` (String) Proposed manifest |
| 63 | + |
| 64 | +<a id="nestedatt--postrender"></a> |
| 65 | +### Nested Schema for `postrender` |
| 66 | + |
| 67 | +Required: |
| 68 | + |
| 69 | +- `binary_path` (String) The common binary path |
| 70 | + |
| 71 | +Optional: |
| 72 | + |
| 73 | +- `args` (List of String) An argument to the post-renderer (can specify multiple) |
| 74 | + |
| 75 | + |
| 76 | +<a id="nestedatt--set"></a> |
| 77 | +### Nested Schema for `set` |
| 78 | + |
| 79 | +Required: |
| 80 | + |
| 81 | +- `name` (String) |
| 82 | + |
| 83 | +Optional: |
| 84 | + |
| 85 | +- `type` (String) |
| 86 | +- `value` (String) |
| 87 | + |
| 88 | + |
| 89 | +<a id="nestedatt--set_list"></a> |
| 90 | +### Nested Schema for `set_list` |
| 91 | + |
| 92 | +Required: |
| 93 | + |
| 94 | +- `value` (List of String) |
| 95 | + |
| 96 | +Optional: |
| 97 | + |
| 98 | +- `name` (String) |
| 99 | + |
| 100 | + |
| 101 | +<a id="nestedatt--set_sensitive"></a> |
| 102 | +### Nested Schema for `set_sensitive` |
| 103 | + |
| 104 | +Required: |
| 105 | + |
| 106 | +- `name` (String) |
| 107 | +- `value` (String, Sensitive) |
| 108 | + |
| 109 | +Optional: |
| 110 | + |
| 111 | +- `type` (String) |
| 112 | + |
| 113 | + |
| 114 | +<a id="nestedatt--set_wo"></a> |
| 115 | +### Nested Schema for `set_wo` |
| 116 | + |
| 117 | +Required: |
| 118 | + |
| 119 | +- `name` (String) |
| 120 | +- `value` (String) |
| 121 | + |
| 122 | +Optional: |
| 123 | + |
| 124 | +- `type` (String) |
| 125 | + |
| 126 | + |
| 127 | +<a id="nestedatt--timeouts"></a> |
| 128 | +### Nested Schema for `timeouts` |
| 129 | + |
| 130 | +Optional: |
| 131 | + |
| 132 | +- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | +## Example Usage |
| 138 | + |
| 139 | +### Check what would be created for a new release |
| 140 | + |
| 141 | +The following example shows using `helm_diff` to preview what resources would be created when deploying a new release that doesn't exist yet. |
| 142 | + |
| 143 | +```terraform |
| 144 | +# Deploy initial release with specific configuration |
| 145 | +resource "helm_release" "mariadb" { |
| 146 | + name = "mariadb-instance" |
| 147 | + namespace = "default" |
| 148 | + repository = "https://charts.helm.sh/stable" |
| 149 | +
|
| 150 | + chart = "mariadb" |
| 151 | + version = "7.1.0" |
| 152 | +
|
| 153 | + set { |
| 154 | + name = "service.port" |
| 155 | + value = "13306" |
| 156 | + } |
| 157 | +
|
| 158 | + set { |
| 159 | + name = "replication.enabled" |
| 160 | + value = "false" |
| 161 | + } |
| 162 | +} |
| 163 | +
|
| 164 | +# Check what would change if we modify the configuration |
| 165 | +data "helm_diff" "mariadb_upgrade" { |
| 166 | + name = "mariadb-instance" |
| 167 | + namespace = "default" |
| 168 | + repository = "https://charts.helm.sh/stable" |
| 169 | +
|
| 170 | + chart = "mariadb" |
| 171 | + version = "7.1.0" # Same version |
| 172 | +
|
| 173 | + set = [ |
| 174 | + { |
| 175 | + name = "service.port" |
| 176 | + value = "3306" |
| 177 | + }, |
| 178 | + { |
| 179 | + name = "replication.enabled" |
| 180 | + value = "true" |
| 181 | + } |
| 182 | + ] |
| 183 | +
|
| 184 | + depends_on = [helm_release.mariadb] |
| 185 | +} |
| 186 | +
|
| 187 | +output "has_changes" { |
| 188 | + description = "Whether the proposed config differs from deployed" |
| 189 | + value = data.helm_diff.mariadb_upgrade.has_changes |
| 190 | +} |
| 191 | +
|
| 192 | +output "what_will_change" { |
| 193 | + description = "Detailed diff of configuration changes" |
| 194 | + value = data.helm_diff.mariadb_upgrade.diff |
| 195 | +} |
| 196 | +
|
| 197 | +output "changes_json" { |
| 198 | + description = "JSON structure showing modified resources" |
| 199 | + value = data.helm_diff.mariadb_upgrade.diff_json |
| 200 | +} |
| 201 | +``` |
| 202 | + |
| 203 | +### Verify deployed release matches desired configuration |
| 204 | + |
| 205 | +The following example shows using `helm_diff` to verify that a deployed release matches your desired configuration (drift detection). |
| 206 | + |
| 207 | +```terraform |
| 208 | +data "helm_diff" "mariadb_instance" { |
| 209 | + name = "mariadb-instance" |
| 210 | + namespace = "default" |
| 211 | + repository = "https://charts.helm.sh/stable" |
| 212 | +
|
| 213 | + chart = "mariadb" |
| 214 | + version = "7.1.0" |
| 215 | +
|
| 216 | + set = [ |
| 217 | + { |
| 218 | + name = "service.port" |
| 219 | + value = "13306" |
| 220 | + } |
| 221 | + ] |
| 222 | +
|
| 223 | + set_sensitive = [ |
| 224 | + { |
| 225 | + name = "rootUser.password" |
| 226 | + value = "s3cr3t!" |
| 227 | + } |
| 228 | + ] |
| 229 | +} |
| 230 | +
|
| 231 | +
|
| 232 | +output "has_changes" { |
| 233 | + value = data.helm_diff.mariadb_instance.has_changes |
| 234 | +} |
| 235 | +
|
| 236 | +output "diff_output" { |
| 237 | + value = data.helm_diff.mariadb_instance.diff |
| 238 | +} |
| 239 | +
|
| 240 | +output "current_manifest" { |
| 241 | + value = data.helm_diff.mariadb_instance.current_manifest |
| 242 | +} |
| 243 | +
|
| 244 | +output "proposed_manifest" { |
| 245 | + value = data.helm_diff.mariadb_instance.proposed_manifest |
| 246 | +} |
| 247 | +``` |
| 248 | + |
| 249 | +### Preview configuration changes before applying |
| 250 | + |
| 251 | +The following example shows using `helm_diff` to preview what would change if you modify the configuration of an existing release. |
| 252 | + |
| 253 | +```terraform |
| 254 | +resource "helm_release" "mariadb" { |
| 255 | + name = "mariadb-instance" |
| 256 | + namespace = "default" |
| 257 | + repository = "https://charts.helm.sh/stable" |
| 258 | +
|
| 259 | + chart = "mariadb" |
| 260 | + version = "7.1.0" |
| 261 | +
|
| 262 | + set { |
| 263 | + name = "service.port" |
| 264 | + value = "13306" |
| 265 | + } |
| 266 | +
|
| 267 | + set { |
| 268 | + name = "replication.enabled" |
| 269 | + value = "false" |
| 270 | + } |
| 271 | +} |
| 272 | +
|
| 273 | +data "helm_diff" "mariadb_upgrade" { |
| 274 | + name = "mariadb-instance" |
| 275 | + namespace = "default" |
| 276 | + repository = "https://charts.helm.sh/stable" |
| 277 | +
|
| 278 | + chart = "mariadb" |
| 279 | + version = "7.1.0" |
| 280 | +
|
| 281 | + set = [ |
| 282 | + { |
| 283 | + name = "service.port" |
| 284 | + value = "3306" |
| 285 | + }, |
| 286 | + { |
| 287 | + name = "replication.enabled" |
| 288 | + value = "true" |
| 289 | + } |
| 290 | + ] |
| 291 | +
|
| 292 | + depends_on = [helm_release.mariadb] |
| 293 | +} |
| 294 | +
|
| 295 | +output "has_changes" { |
| 296 | + value = data.helm_diff.mariadb_upgrade.has_changes |
| 297 | +} |
| 298 | +
|
| 299 | +output "what_will_change" { |
| 300 | + value = data.helm_diff.mariadb_upgrade.diff |
| 301 | +} |
| 302 | +
|
| 303 | +output "changes_json" { |
| 304 | + value = data.helm_diff.mariadb_upgrade.diff_json |
| 305 | +} |
| 306 | +``` |
0 commit comments