tfvc
tfvc copied to clipboard
Feature request: Recursive mode
It'd be great to have a recursive mode, we have a monorepo with lots of modules.
@KTamas I thought about this, but given that you can currently just pass multiple directories to tfvc
I decided that was good enough for me at the moment. Does that not meet your requirement? e.g.
tfvc ./directory1 ./directory2 ./directory3
The problem is that even that's not without issues, for example:
$ tfvc . modules/vpc
provider 'hashicorp/aws' WARNING Configured version does not match the latest available version
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Resolution
──────────────────────────────────────────────────────────
Consider using the latest version of this provider
Details
────────────────────────────────────────────────────────
Type: provider
Path: .
Name: hashicorp/aws
Source: registry.terraform.io/hashicorp/aws
Version Constraints: 4.29.0
Version: 4.29.0
Latest Match:
Latest Overall: 4.36.1
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
module 'vpc' WARNING Configured version does not match the latest available version
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Resolution
────────────────────────────────────────────────────────
Consider using the latest version of this module
Details
──────────────────────────────────────────────────
Type: module
Path: modules/vpc/main.tf
Name: vpc
Source: terraform-aws-modules/vpc/aws
Version Constraints: 3.14.4
Version: 3.14.4
Latest Match:
Latest Overall: 3.18.0
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
terraform FAILED Missing version constraints
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Resolution
───────────────────────────────────────────────────
Configure version constraints for terraform
Details
───────────────────────────────────────────────────
Type: terraform
Path: modules/vpc
Name: terraform
Source: github.com/hashicorp/terraform
Version Constraints:
Version:
Latest Match:
Latest Overall: 1.3.3
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
- we have many many modules and listing them by hand is just, Not Great
- This error is misleading
terraform FAILED Missing version constraints
Ah, yes, point 2 is related to #34 however, I do understand your point 1. I will leave this open and take a look at it when I get a chance.
@KTamas on further thought, I actually don't think your 2nd point above "This error is misleading terraform FAILED Missing version constraints" is quite correct. Your modules/vpc
module should be defining a version constraint for the version(s) of terraform that it supports in a terraform { required_version = "x" }
block. Does your vpc module have this configured?
Ah, right, we don't have that. Mostly because it's a non-issue for us, most of the time. Perhaps an option to disable that check?
Perhaps, I definitely want to add something to be able to ignore checks etc. just haven't looked at the best way to do it yet.
Recursive mode would help us greatly as we're preparing a migration to AWS provider v4 across the board in our monorepo.
I've been thinking about this a bit more and I'm still not sold on the idea. The issue is that it could end up adding a lot of complexity as I'm sure everyone will have different repo structures/requirements. For example, some people might only want to recurse one level deep, others might only want to recurse into a specific subdirectory called modules
, others might want full multi-level recursion etc. etc.
My point is, currently you can specify multiple directories (separated by a comma) to tfvc
and it will happily loop through them all. If that is not sufficient then it should be pretty trivial for people to put together a simple script to work out which directories they want to recurse into and just run tfvc
in a for loop.
I'll leave this open for a bit longer in case people want to add some weight to the feature, but for now it is probably not going to implemented.