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

[Feature Request] Like other tools, attempt to locate a .tfmigrate.hcl in parent directories #199

Open
rtizzy opened this issue Jan 17, 2025 · 3 comments

Comments

@rtizzy
Copy link
Contributor

rtizzy commented Jan 17, 2025

Currently leveraging the config file requires passing in the config option everytime the command is used.

It would be useful if tfmigrate attempted to locate the configuration in parent directories when the config option is not passed in.

@minamijoyo
Copy link
Owner

I'm open to adding a new environment variable for the tfmigrate's configuration file path, but hesitant about implicitly exploring the parent directory. Reading above the current directory adds a lot of complexity, so just because other tools are doing it is not a good enough reason.

Is your specific use case related to #200?

@rtizzy
Copy link
Contributor Author

rtizzy commented Jan 20, 2025

@minamijoyo

An environment variable is better than nothing as long as it supports relative pathing in some manner.

Reading above the current directory adds a lot of complexity, so just because other tools are doing it is not a good enough reason.
Is your specific use case related to #200?

That isn't the exact use case though they can go hand in hand.

It's worth considering why other tooling in the space does so.

With something like tfmigrate (or a linter, or other tooling), you want everyone who uses the tool to leverage the same configuration.

That's typically performed by checking for config files in a number of locations given some order of precedence (Typically env var or CLI, current dir, parent dir, then home dir).

With this sort of setup it's possible to check configuration directly into the repository so all other tooling/people using tfmigrate utilize the correct configuration.

With this method it is also possible, if desired, to override the configuration as needed.

For tfmigrate:

  1. Check the config into the root of the directory or anything that's a parent of all the Terraform directories.
  2. Check all migrations into the repository
  3. Go to a particular directory in the repository
  4. Run plan or apply as needed
  5. The configuration from Setup actions #1 is used in each case.

@minamijoyo
Copy link
Owner

Each tool has its own context. It seems to me that it is simply a matter of running the tfmigrate command in the parent directory where the configuration file is located, not in the children's directory. You don't need to go to the children's directory. Because the state block in the migration file has a dir attribute that specifies the working directory, and the multi_state block also has from_dir and to_dir attributes. Am I missing something?

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