Skip to content

[ISSUE] Issue with null_resource resource #5814

Description

@MichallHuPostNL

Resource(s) Affected

null_resource (hashicorp/null provider)

Configuration

```hcl

Relevant part (simplified)

module "secret_rotation" {

...

}

resource "null_resource" "insert_data" {
triggers = {
sp_display_name = var.sp_display_name
}
}
```

Expected Behavior

sp_display_name is defined once and should resolve to the same value throughout the run. The triggers["sp_display_name"] value on null_resource.insert_data should remain consistent between plan and apply, and Terraform should complete successfully without detecting any inconsistencies.

Actual Behavior

sp_display_name was only defined once, with a single value, but during terraform apply the null_resource provider reported two different values for triggers["sp_display_name"] on null_resource.insert_data (used here in a secret rotation module) — one at plan time and a different one during apply:

  • Initial planned value: "my-service-principala"
  • Final value during apply: "my-service-principal"

This resulted in the following error:

```
Error: Provider produced inconsistent final plan

When expanding the plan for
module.secret_rotation.null_resource.insert_data to include new values
learned so far during apply, provider
"registry.terraform.io/hashicorp/null" produced an invalid new value for
.triggers["sp_display_name"]: was cty.StringVal("my-service-principala"),
but now cty.StringVal("my-service-principal").

This is a bug in the provider, which should be reported in the provider's
own issue tracker.
```

Additionally, warnings were raised:

```
Use managed_services_customer_managed_key_id instead
(and 3 more similar warnings elsewhere)
```

Steps to Reproduce

  1. Define a null_resource with a triggers map referencing a variable once (e.g. sp_display_name = var.sp_display_name), and change sp_display_name from the original
  2. Run terraform apply
  3. Observe plan generation with sp_display_name = "my-service-principala"
  4. During apply, without any config change, the value Terraform reports for the same attribute becomes "my-service-principal"
  5. Terraform throws an inconsistent final plan error on the null_resource's triggers attribute

Terraform and provider versions

```shell
terraform version
```

Is it a regression?

Debug Output

Important Factoids

Would you like to implement a fix?

No (reporting issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions