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
Documentation Update - Slightly clearer description of 'Refresh' and 'Plan' execution #28342
Comments
Hi @manmedia, It's true that If you see Funnily enough, I'm currently working on some changes over in #28297 which I think will make the relationships between these commands clearer as part of the documentation update. That'll eventually also include #26921, which will make it explicit in the UI when Terraform detects a difference during refresh and that you can apply the result to accept those changes. In particular, the updated documentation for
That's effectively what |
@apparentlymart Understood. But here is the problem:
The above is possible, and can inadvertently destroy resources. Because super users can do things as and when they please. But we can update the state with |
Does something unwanted happen if you don't run Once we include something like the change I prototyped in #26921, Terraform will also announce that it has detected those changes, allowing you to find out that they occurred without this other meddling team having to inform you first. But that's just a cosmetic change: Terraform is already tracking those changes internally and will record them once you apply the plan, it just does so quietly today. |
Yes it does. An example:
1. In my Terraform plan (before doing a forced refresh), I saw 3 added, 0
change, 1 replace.
2. After I did a forced `terraform refresh` and then `terraform plan` - it
mentioned 19 to add, 0 to change, 0 to replace.
Clearly - it says something during plan, but after refresh it shows
something else. I think where I am too demanding is the behaviour.
Terraform is nothing but a "Git" for Infrastructure. If you check git,
after every `git fetch --prune` it cleans up the local cache and a
following `git rebase` rebases off of all recent changes made in remote.
Terraform should allow doing something like that, if not exactly like that.
But anyway, feel free to think about my suggestion and improve things if
that suits your roadmap :)
And we are looking forward to your -refresh-only flag changes to be
released.
…On Tue, 13 Apr 2021 at 01:27, Martin Atkins ***@***.***> wrote:
Does something unwanted happen if you *don't* run terraform refresh, and
just run terraform apply as normal? In that case, Terraform should detect
and react to the changes made elsewhere, and create a new state snapshot
including those once you accept the proposed changes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#28342 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQC3KHEMMNZMAYGJ6J5OTDTIOFWNANCNFSM422BQDVA>
.
|
The current docs now claim the -refresh-only option exists. https://www.terraform.io/docs/cli/commands/refresh.html Yet in 0.15.3, they don't exist:
Are the docs ahead of the releases? Thanks. |
@apparentlymart i'll echo what @pll said, i got confused by the docs. And the situation is a bit complicated because TF docs are not bound to a spefcific release and so i had to bounce here to understand or figure out on which v the new flag is available. Would appreciate if either docs are aligned or maybe a note is being added to say "is coming soon" |
Hello,
Current Terraform docs suggest the following on Refresh and Plan respectively:
It's not well-explained on the above that "Plan" will not do a real refresh on the local/remote state files. It does the refresh in-memory. Therefore, an explicit "Refresh" is required before the plan.
Reason
terraform plan
on a feature branch before doingterraform apply -auto-approve
- this is a typical code review situation.apply
command is invoked - there is a risk that the state has not been updated correctly.It's therefore, required to do an explicit state refresh before the plan to have a 100% like-to-like behaviour for plan+apply. After all, plan is meant to be dry-run of
apply
. But this doesn't happen in real scenario. Therefore, I am requesting that the documentation should be updated to ensure that (at least) a cautionary statement is added for "Refresh" or "Plan" suggesting the above.Regards,
The text was updated successfully, but these errors were encountered: