Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random_password Showing Unexpected Plan 3.3.2 to 3.4.2 #306

Closed
1 task done
bflad opened this issue Sep 2, 2022 · 6 comments · Fixed by #312
Closed
1 task done

random_password Showing Unexpected Plan 3.3.2 to 3.4.2 #306

bflad opened this issue Sep 2, 2022 · 6 comments · Fixed by #312
Labels
Milestone

Comments

@bflad
Copy link
Member

bflad commented Sep 2, 2022

Terraform CLI and Provider Versions

Terraform v1.2.7
on darwin_arm64

  • provider registry.terraform.io/hashicorp/random v3.4.2

Terraform Configuration

terraform {
  required_providers {
    random = {
      source  = "hashicorp/random"
      version = "3.4.2"
      # version = "3.3.2"
    }
  }
}

resource "random_password" "test" {
  length = 20
}

Expected Behavior

No plan difference.

Actual Behavior

$ terraform apply        
random_password.test: Refreshing state... [id=none]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # random_password.test will be updated in-place
  ~ resource "random_password" "test" {
        id          = "none"
        # (12 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

May be related to small change in #305 where override_special was having issues with framework migration testing and the fix seemed to be adding a default value plan modifier of types.String{Value: ""}. Here's the state difference after the odd plan output:

4c4
<   "serial": 1,
---
>   "serial": 3,
28c28
<             "override_special": null,
---
>             "override_special": "",
33,34c33
<           "sensitive_attributes": [],
<           "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjIifQ=="
---
>           "sensitive_attributes": []

Potentially removing Computed and removing the default value plan modifier can fix this.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@bflad bflad added the bug label Sep 2, 2022
@amh-mw
Copy link

amh-mw commented Sep 2, 2022

Same behavior observed this morning for random_string, 3.4.1 -> 3.4.2.

@fgm
Copy link

fgm commented Sep 5, 2022

Same problem with random_string

bflad added a commit that referenced this issue Sep 5, 2022
… from 3.3.2

Reference: #306

This fixes the `override_special` attribute issues by removing `Computed: true` and the empty string default value plan modifier (this attribute's value should always come from the practitioner) and resolves the underlying issue of always reading `plan.OverrideSpecial.Value` into the state, which will never be correct for null configurations.

For any environment that happened to upgrade to 3.4.2 and save the empty string into state, the replacement plan modifier will allow in-place modification from empty string (`""`) to `null`.

Previously after removing `Computed: true` and default value plan modifier:

```
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_3_2
    resource_password_test.go:221: Step 2/2 error: Error running apply: exit status 1

        Error: Provider produced inconsistent result after apply

        When applying changes to random_password.test, provider
        "provider[\"registry.terraform.io/hashicorp/random\"]" produced an unexpected
        new value: .override_special: was null, but now cty.StringVal("").

        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_4_2
    resource_password_test.go:255: Step 2/2 error: Error running apply: exit status 1

        Error: Provider produced inconsistent result after apply

        When applying changes to random_password.test, provider
        "provider[\"registry.terraform.io/hashicorp/random\"]" produced an unexpected
        new value: .override_special: was null, but now cty.StringVal("").

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

Previously before adjusting requires replace plan modifier:

```
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_3_2
    resource_password_test.go:221: Step 2/2 error: Check failed: Check 3/3 error: attribute values are different, got :i$(*K3_Vinv and FSw{$8sB#Uc3
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_4_2
    resource_password_test.go:255: Step 2/2 error: Check failed: Check 3/3 error: attribute values are different, got VrNYb]{#Z2Xu and XZD#_<BjDhkH
```
@mycloud91
Copy link

Any solution/suggestion on the same? I'm also facing the same issue after upgrading the terraform azurerm version (v3.0.0).
can I safely ignore and what was the exact impact of this? whether it will reset the random password string?

@bflad bflad added this to the v3.4.3 milestone Sep 6, 2022
bflad added a commit that referenced this issue Sep 6, 2022
…erences upgrading from 3.3.2 (#312)

Reference: #306

This fixes the `override_special` attribute issues by removing `Computed: true` and the empty string default value plan modifier (this attribute's value should always come from the practitioner) and resolves the underlying issue of always reading `plan.OverrideSpecial.Value` into the state, which will never be correct for null configurations.

For any environment that happened to upgrade to 3.4.2 and save the empty string into state, the replacement plan modifier will allow in-place modification from empty string (`""`) to `null`.

Previously after removing `Computed: true` and default value plan modifier:

```
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_3_2
    resource_password_test.go:221: Step 2/2 error: Error running apply: exit status 1

        Error: Provider produced inconsistent result after apply

        When applying changes to random_password.test, provider
        "provider[\"registry.terraform.io/hashicorp/random\"]" produced an unexpected
        new value: .override_special: was null, but now cty.StringVal("").

        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_4_2
    resource_password_test.go:255: Step 2/2 error: Error running apply: exit status 1

        Error: Provider produced inconsistent result after apply

        When applying changes to random_password.test, provider
        "provider[\"registry.terraform.io/hashicorp/random\"]" produced an unexpected
        new value: .override_special: was null, but now cty.StringVal("").

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

Previously before adjusting requires replace plan modifier:

```
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_3_2
    resource_password_test.go:221: Step 2/2 error: Check failed: Check 3/3 error: attribute values are different, got :i$(*K3_Vinv and FSw{$8sB#Uc3
=== CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_4_2
    resource_password_test.go:255: Step 2/2 error: Check failed: Check 3/3 error: attribute values are different, got VrNYb]{#Z2Xu and XZD#_<BjDhkH
```
@bflad bflad closed this as completed in #312 Sep 6, 2022
@lucascantor
Copy link

lucascantor commented Sep 6, 2022

@SaravananGuru pinning to 3.3.2 for the time being seems to resolve this issue for me:

terraform {
  required_version = ">= 1.2.2"
  required_providers {
    random = {
      source  = "hashicorp/random"
      version = "3.3.2"
    }
  }
}

@mycloud91
Copy link

@bflad and @lucascantor thank you for the update. Even if it updates the ID to null technically its internal terraform value does not reset the value of the random password result. so, I have safely ignored and applied the plan. It working fine as expected.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.