Comments (5)
Hi @pyranja, Thank you for sharing your use-case. For a workaround, I came up with a dirty hack. 😉
When switching a remote backend to local, the tfmigrate generates an override file named _tfmigrate_override.tf
under the hood and you can replace the terraform command to a custom wrapper script with TFMIGRATE_EXEC_PATH
environment variable. This means that there is room for customizing the behavior of the terraform command depending on whether the backend is configured as remote or local.
from tfmigrate.
@minamijoyo I see, thanks.
So I could check for the presence of the override in a wrapper to decide whether backend config has to be provided or not?
I'll see if I can make that work.
What is your general feeling about accepting pass-through backend-config
for the remote init?
If it's ok for you I'd try my luck on a PR some time later.
from tfmigrate.
It's ok to add support for the partial backend config. I think it should be a new migration block attribute rather than a new CLI flag, because a backend config is related to a working directory. It will cause the following problems if it's a CLI flag:
(1) The multi_state
migration type uses two working directories, which have potentially different backend configs.
(2) With the migration history mode enabled, it applies multiple migration files in one-shot, which have potentially different backend configs.
from tfmigrate.
Update: The workaround with a terraform wrapper worked very well, thanks for the suggestion.
For our use case adding the backend config to the migration block would not work as is:
- we deploy the same terraform code to different environments (staging and production)
- the repo consists of many working directories, where each one defines some part of the infrastructure (e.g. a service)
- the working directories only define the state key in a backend block
- all other backend config is included from a common backend config file per environment
- we would like to apply migrations in a similar way to different environments
If the backend config reference is part of the migration, we would have to edit the migrations depending on the target environment or duplicate them for each target with a different backend config.
That's why I thought about a cli flag immediately.
Your concerns with the multi_state and history mode are very relevant too though.
I'm not sure if all requirements can be met at the same time, it would need a mix of having backend config in the migration and an option to override parts. But that feels like it's even messier than the workaround. 🤷
Thanks a lot for your explanation!
from tfmigrate.
I understood the cli flag would be useful your use-case. Not all requirements must be met at the same time. In your case the multi_state migration doesn't make sense across environments. If you apply migrations per environment, you can assume all pending migrations have the same backend config override.
There is no single solution for meeting all use-cases. It's ok to add it as the cli flag. If someone want to use it as the migration attribute, then we can support both individually.
from tfmigrate.
Related Issues (20)
- Migrating states from codebases with different terraform version HOT 3
- tfmigrate reports success despite backend not properly configured HOT 1
- Cannot use `*` with tfmigrate actions HOT 4
- Feature request: Display of state plan for to_dir in multi-state HOT 3
- tfmigrate reports migration plan success when Terraform plan command returns an error HOT 2
- Feature request: add an option to skip `terraform plan`-ing HOT 4
- Feature request: support replace-provider HOT 5
- Change tfmigrate-storage license from MPL2 to MIT HOT 3
- Feature request: support skip_plan in state migration HOT 2
- Feature request: support actions spanning multiple HCL files targeting the same projects HOT 4
- multi_state xmv attempts to migrate data sources? HOT 4
- Possible to optimise multi_state_mv execution time?
- Possible to optimise multi_state_mv execution time? HOT 1
- OpenTofu support HOT 3
- Add terraform >=1.1 moved resource documentation? HOT 1
- [bug] Does not work when working with terragrunt & dynamic backend config
- Error executing ftmigrate on MacOS 14.0 (ARM) HOT 1
- split resources with dependencies. HOT 1
- Bug when you have module that have the same resource names
- High vulnerability in golang library HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfmigrate.