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

Add version block even if block is missing #72

Open
nitrocode opened this issue Jul 19, 2022 · 1 comment
Open

Add version block even if block is missing #72

nitrocode opened this issue Jul 19, 2022 · 1 comment

Comments

@nitrocode
Copy link

I noticed if I ran this, it doesn't return any output, and exits with 0 even though it did not make any modification to the module.

This module does not have a terraform { required_version = "x.y.z" } block.

tfupdate terraform -v ">= 1.0.0" my_module/

It would be nice if it would by default or by an additional option, it could add this block to a specified file, and if no specified file, it could add/append it to the module's versions.tf.

# if no required_version block, this creates a new versions.tf with this version set
tfupdate terraform -v ">= 1.0.0" my_module/
# if no required_version block, this creates a new my_versions.tf with this version set
tfupdate terraform -v ">= 1.0.0" my_module/my_versions.tf
@minamijoyo
Copy link
Owner

HI @nitrocode, thank you for your proposal.

For the user interface, I hesitate to enable it by default because tfupdate is intended to be applied recursively to multiple directories. Still, it is acceptable if it is added as a new opt-in flag.

The problem is that the current implementation rewrites each file on the fly. This means there is no way to detect whether requirements are defined or not in other files. We need to split the rewrite implementation into two phases; analyzing and updating. I can't start the implementation now but will consider it when refactoring.

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

No branches or pull requests

2 participants