Navigation Menu

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

Warn when ignore_changes includes a Computed attribute #30517

Merged
merged 5 commits into from Feb 18, 2022

Conversation

kmoe
Copy link
Member

@kmoe kmoe commented Feb 14, 2022

Adding a (non-Optional) Computed attribute to ignore_changes is a no-op, so we should warn users when they do this, as it is likely they intended something else.

Throwing an error here would be a breaking change.

Also adds test for the StaticValidateTraversal() check that verifies ignore_changes paths are present in the schema.

Add a test verifying that attempting to add a nonexistent attribute to
ignore_changes throws an error.
Return a warning if a Computed attribute is present in ignore_changes,
unless the attribute is also Optional.

ignore_changes on a non-Optional Computed attribute is a no-op, so the user
likely did not want to set this in config.
An Optional Computed attribute, however, is still subject to ignore_changes
behaviour, since it is possible to make changes in the configuration that
Terraform must ignore.
@kmoe kmoe force-pushed the kmoe/ignore-changes-computed branch from 7b6faac to d6cc3d9 Compare February 14, 2022 15:39
@kmoe kmoe changed the title Return error when ignore_changes includes a Computed attribute Warn when ignore_changes includes a Computed attribute Feb 14, 2022
@kmoe kmoe marked this pull request as ready for review February 14, 2022 15:40
@kmoe kmoe requested a review from a team February 14, 2022 15:40
@kmoe kmoe force-pushed the kmoe/ignore-changes-computed branch from 9794650 to 4e3507f Compare February 17, 2022 11:41
Copy link
Member

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

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

This looks good to me!

I left an inline comment about the text of the error message. I'm sorry I didn't catch that the first time I looked here; I think when I was here the first time I was focused only the one active comment thread and didn't look at the rest of the diff. 😖

I feel hopeful that if we introduce the other ignore_changes-alike thing we've been sketching it'll be able to reuse this same validation logic and thus not necessarily require generalizing the trick of trimming off that leading dot from the displayed address, but if that turns out to make things awkward then not the end of the world to have a helper function to do it, I suppose. We'll see how that turns out in the subsequent PR! 😀

internal/terraform/node_resource_validate.go Outdated Show resolved Hide resolved
@kmoe kmoe merged commit 1613747 into main Feb 18, 2022
@kmoe kmoe deleted the kmoe/ignore-changes-computed branch February 18, 2022 10:38
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link

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 Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants