Hiya all :wave:, we have a growing terraform repo ...
# development
Hiya all πŸ‘‹, we have a growing terraform repo over at Foursquare. As it grows, we're facing some interesting dependency problems that feel like a great fit for a tool like Pants. I took a poke around the codebase and found the terraform subsystem, kind of curious what the plans are in that area.
Just linting and formatting for now.
terraform fmt
and `terraform validate``
πŸ‘ 1
cc @early-jelly-55072 who has been really excited about what could come from it
The existing terraform backend in Pants also does dependency inference for first-party modules (i.e. in repo).
so you should be able to run
./pants dependencies some/path/:target_name
to see dependencies of a Terraform module
What functionality are you envisioning @bitter-piano-88933?
The dependency inference for first-party modules is really interesting.
At the lowest level, I want a tool that correctly determines what terraform needs to be applied if a module it depends on has been updated. All our modules are in the same repo and we don't currently use any 3rd party modules.
πŸ’― 1
Currently we have some scripts that attempt to do this. But they're not the most robust peaces of code. We could invest in them more, but we'd be rebuilding something like pants and get none of the more advanced features.
Do you have any plans to support plan/apply down the line?
Sweet! So sounds like you'd be looking for project introspection, not having Pants run terraform itself to deploy etc? I think there was discussion last month about how Pants should probably not go too far down the rabbit hole of Terraform support. It's a non-goal to 100% manage/run Terraform via Pants, you probably will still run it directly. Focus on what Pants excels at instead
Hum, that's interesting. Yeah, I don't think we have a particular need to run Terraform via Pants. So I think this could work for us. Let me try it out.
Out of curiosity, if you can run validate, that means you're already are dealing with terraform state to some extent. Is there anything that would stop us from extending that to say running plan or apply?
no just the fact that we intentionally don’t want to officially support that use case for now. You are free to use the code in non-merged PR https://github.com/pantsbuild/pants/pull/13023 in your own local repo though if it is useful.
also for
to work, we may need to put the
local directory into the Pants execution sandbox. The current version of the backend does not do that, and so is incomplete in this regard.
Makes sense, thanks for sharing that PR.
Btw this isn't documented b/c it's experimental, but tl;dr to get Terraform working is add to this
Copy code
backend_packages = ["pants.backend.experimental.terraform"]
Then run
./pants tailor
Should be able to run
./pants fmt path/to/terraform::
then You'll want to use 2.8.0rc1
πŸ™ 1
πŸ™πŸ½ 1
I definitely understand the decision made on that PR. But part of me is attracted to the idea of using pants as the single entry point to the tooling in the repo. But apart from aesthetics, no good reason comes to mind. I'll play around with the current iteration and see if I can make a more coherent case.
πŸ’― 1
We're definitely eager to revisit that thinking! And even if it doesn't make sense for core Pants to have more robust Terraform support, we're happy to help with writing a plugin πŸ™‚
πŸ‘ 1