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

Modify terraform plan output instead of doing terraform refresh #11

Closed
FurqanHabibi opened this issue Feb 27, 2023 · 4 comments · Fixed by #12
Closed

Modify terraform plan output instead of doing terraform refresh #11

FurqanHabibi opened this issue Feb 27, 2023 · 4 comments · Fixed by #12
Assignees
Labels
enhancement New feature or request

Comments

@FurqanHabibi
Copy link
Contributor

FurqanHabibi commented Feb 27, 2023

This is an enhancement for the hide_refresh option. As explained in this article, running terraform refresh can be dangerous, as it will automatically update the state file. Some credentials misconfiguration for example can misled terraform to think that the resources do not exist, thereby emptying the state file.

I would suggest to just remove Refreshing... or Reading... lines from terraform plan outputs instead of performing terraform refresh. Here's an example taken from this issue:

terraform plan | grep -v "Refreshing state...\|Reading...\|Read complete after"
@FurqanHabibi FurqanHabibi added the enhancement New feature or request label Feb 27, 2023
@hanscg
Copy link
Contributor

hanscg commented Feb 28, 2023

Reading the documentation for terraform plan I assumed running it refreshes the state file by default, is it not the case? 🤔

-refresh=false - Disables the default behavior of synchronizing the Terraform state with remote objects before checking for configuration changes.

@FurqanHabibi
Copy link
Contributor Author

FurqanHabibi commented Feb 28, 2023

image

It is a bit different than terraform refresh in that the state refreshing is done in-memory, and will only be applied to the state file when terraform apply is carried on. This is unlike terraform refresh where the state file will always be updated.

https://developer.hashicorp.com/terraform/tutorials/state/refresh

@hanscg
Copy link
Contributor

hanscg commented Feb 28, 2023

I see, the docs for terraform plan is annoyingly vague about this 😓
Thank you for the suggestion!
Do you want to open a PR for this? I can do it if you're busy with something else.

@FurqanHabibi
Copy link
Contributor Author

Let me create one, maybe not today though 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants