Hey folks, I was fiddling with implementing lockfi...
# development
c
Hey folks, I was fiddling with implementing lockfiles for Terraform, and was hitting some design issues ๐Ÿงต
1. Terraform makes a distinction between "modules" (reusable groups of resources) and "root modules" (things you might actually deploy). But Terraform doesn't really, uh, support that notion https://github.com/hashicorp/terraform/issues/28490 . Do we want to make that distinction too, and implement a new
terraform_deployment
target (we'd probably want this as well for
experimental-deploy
)?
2. Terraform doesn't really have a notion of a "Resolve" the way Pants does. Every root module effectively has its own universe of dependencies, and there isn't a way of joining multiple modules' requirements. We could do something weird like synthesise a Terraform file that tries to depend on multiple modules, or manually combine dependencies ourselves, but that sounds bad. Would it be fine to just synthesise a resolve per "root module" with the name being the path to the module or something based off it?
h
Re 1. at Toolchain we differentiated these by putting the former under a
modules
directory and the latter under a
resources
directory. That was fine, but distinguishing in BUILD files rather than by naming convention makes a ton of sense to me.
๐Ÿ‘ 1
Re 2. Yes, I think doing everything per root module makes sense. I don't think we should get in the way of TFs idioms or try and jam pants-isms into them, unless it adds substantial value. In this case I think people are used to the top-level thing being a root module.
But why do we need to synthesize a resolve at all? What would that represent?
c
I thought a resolve name was necessary for generating the lockfile, like in
./pants generate-lockfiles --resolve="..."
? If there's another way I'll give it a try
h
Ah, I see
I didn't realize we were tying this in to generate-lockfiles, but makes sense
so maybe the "resolve" name should be, as you say, the relpath from the repo root to the root folder of the resource
./pants generate-lockfiles --resolve="src/terraform/us-east-1/network"
or whatever