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

Prevent keepers from triggering an in-place update following import #385

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

bendbennett
Copy link
Contributor

Closes: #384

@bendbennett bendbennett added this to the v3.4.4 milestone Mar 13, 2023
@bendbennett bendbennett requested a review from a team as a code owner March 13, 2023 11:47
@bflad bflad modified the milestones: v3.4.4, v3.6.0 May 19, 2023
@bflad bflad removed this from the v3.6.0 milestone Dec 14, 2023
@opdude
Copy link

opdude commented Mar 27, 2024

@bflad What is holding this PR back from being merged?

Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🚀 Great fix, @bendbennett!

@bendbennett bendbennett merged commit f8a3f8b into main Apr 15, 2024
42 checks passed
@bendbennett bendbennett deleted the bendbennett/issues-384 branch April 15, 2024 15:46
@orgads
Copy link

orgads commented Apr 15, 2024

Thank you!

dduportal pushed a commit to jenkins-infra/azure that referenced this pull request Apr 19, 2024
<Actions>
<action
id="296d75eab55b9d23bd1e94dc34cea43b964c29945c12fefcb674e3c068a0a767">
        <h3>Bump Terraform `random` provider version</h3>
<details
id="1d9343c012f5434ac9fe8a98135bae3667b399259be16d9b14302ea3bd424a24">
            <summary>Update Terraform lock file</summary>
<p>changes detected:&#xA;&#x9;&#34;hashicorp/random&#34; updated from
&#34;3.6.0&#34; to &#34;3.6.1&#34; in file
&#34;.terraform.lock.hcl&#34;</p>
            <details>
                <summary>3.6.1</summary>
<pre>Changelog retrieved
from:&#xA;&#x9;https://github.com/hashicorp/terraform-provider-random/releases/tag/v3.6.1&#xA;BUG
FIXES:&#xA;&#xA;* all: Prevent `keepers` from triggering an in-place
update following import
([#385](hashicorp/terraform-provider-random#385
resource/random_shuffle: Prevent inconsistent result after apply when
result_count is set to 0
([#409](hashicorp/terraform-provider-random#409
provider/random_password: Fix bug which causes panic when special,
upper, lower and number/numeric are all false
([#551](hashicorp/terraform-provider-random#551
provider/random_string: Fix bug which causes panic when special, upper,
lower and number/numeric are all false
([#551](https://github.com/hashicorp/terraform-provider-random/issues/551))&#xA;&#xA;&#xA;</pre>
            </details>
        </details>
<a
href="https://infra.ci.jenkins.io/job/updatecli/job/azure/job/main/118/">Jenkins
pipeline link</a>
    </action>
</Actions>

---

<table>
  <tr>
    <td width="77">
<img src="https://www.updatecli.io/images/updatecli.png" alt="Updatecli
logo" width="50" height="50">
    </td>
    <td>
      <p>
Created automatically by <a
href="https://www.updatecli.io/">Updatecli</a>
      </p>
      <details><summary>Options:</summary>
        <br />
<p>Most of Updatecli configuration is done via <a
href="https://www.updatecli.io/docs/prologue/quick-start/">its
manifest(s)</a>.</p>
        <ul>
<li>If you close this pull request, Updatecli will automatically reopen
it, the next time it runs.</li>
<li>If you close this pull request and delete the base branch, Updatecli
will automatically recreate it, erasing all previous commits made.</li>
        </ul>
        <p>
Feel free to report any issues at <a
href="https://github.com/updatecli/updatecli/issues">github.com/updatecli/updatecli</a>.<br
/>
If you find this tool useful, do not hesitate to star <a
href="https://github.com/updatecli/updatecli/stargazers">our GitHub
repository</a> as a sign of appreciation, and/or to tell us directly on
our <a
href="https://matrix.to/#/#Updatecli_community:gitter.im">chat</a>!
        </p>
      </details>
    </td>
  </tr>
</table>

Co-authored-by: Jenkins Infra Bot (updatecli) <[email protected]>
jippi added a commit to jippi/atlantis that referenced this pull request Apr 19, 2024
Version v3.6.1 of the 'random' provider changed the behavior of 'keeper' in hashicorp/terraform-provider-random#385

This upstream change caused the extra keepers = {} output in our test output

since keepers are optional, and {} is same as absent for our use-cases, we're removing the empty keepers = {} from the .tf files
@Gitopolis
Copy link

Gitopolis commented May 3, 2024

It doesn't seem to work in my environment:

  • Step 1
> terraform state rm random_id.fernet_key

Removed random_id.fernet_key
Successfully removed 1 resource instance(s).

> terraform import random_id.fernet_key <REDACTED>

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
  • Step 2
> terraform init
- Installing hashicorp/random v3.6.1...
- Installed hashicorp/random v3.6.1 (verified checksum)

> terraform plan
random_id.fernet_key: Refreshing state... [id=<REDACTED>]

  # random_id.fernet_key must be replaced
-/+ resource "random_id" "fernet_key" {
      ~ b64_std     = "<REDACTED>" -> (known after apply)
      ~ b64_url     = "<REDACTED>" -> (known after apply)
      ~ dec         = "<REDACTED>" -> (known after apply)
      ~ hex         = "<REDACTED>" -> (known after apply)
      ~ id          = "<REDACTED>" -> (known after apply)
      + keepers     = { # forces replacement <----------- Not expected
          + "name" = "demo-secret-key"
        }
        # (1 unchanged attribute hidden)
    }

The resource:

resource "random_id" "fernet_key" {
  keepers = {
    name = var.secret.name
  }
  byte_length = 32
}

@bendbennett
Copy link
Contributor Author

Hi @Gitopolis 👋

I believe what you are seeing is expected behaviour.
The import command for random_id only handles importing of the id itself, so inclusion of any attributes other than byte_length (i.e., keepers or prefix) will result in a planned replacement.

Copy link

github-actions bot commented Jun 6, 2024

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent keepers triggering an in-place update following import
6 participants