4 ms·
@rcowley -- I'm going to preface this with I'm a Staff SRE at an adtech corp that does billions and have been a k8s and terraform contributor since 2015 (k8s 1
by swozey 3y ago
@rcowley --
I'm going to preface this with I'm a Staff SRE at an adtech corp that does billions and have been a k8s and terraform contributor since 2015 (k8s 1.1 I forget the tf versions). I don't mean this to brag I just want to set my experience expectation since I'm a random name on hn who you'd never know.
I think calling a service/stack (or whatever, app, etc) a "root module" is a very, very confusing thing to do. Terraform has actual micro objects called modules. We work with them every day. I get how you could consider encompassing an entire chunk of terrafrom code that calls various modules a "root module".. but I think this is just going to lead to absolute confusion to anyone not familiar with your terminology. I don't know every TF conversation but I can't think of a single time where I've heard root module in that context. Very good chance I've just missed those conversation and am ignorant to them.
I'm currently hiring SRE 2s and 3s so I've been interviewing lots of terraform writers and one of my tech questions is to ask someone what makes them to decide to write a terraform module and what type of modules they've written - it's always ALBs, EKS, dbs, etc. components indepedently that go into creating a service/stack. I've definitely not heard anyone mention that they write "root modules" in the sense of an entire service/stack.
I don't mean you're right or wrong, maybe more people are aware of that verbage than I am. I just wanted to mention that in my personal case I think it's confusing so I would assume that there are a lot of people in my shoes who would also be confused by it.
- erik_seaberg 3y agohttps://developer.hashicorp.com/terraform/language/modules#the-root-module https://developer.hashicorp.com/terraform/language/modules#t... is what Terraform calls the module in the current directory, to distinguish it from child modules you might introduce.
- swozey 3y agoOk I may absolutely have the dumb today I appreciate the response. The way this is worded, because of this line - "Modules are the main way to package and reuse resource configurations with Terraform." reads like - "I have 10 golang apps, they all at a minimum use these same services, this is our "golang root module". But some services might have more or less modules, ie service A uses redis, service B uses kafka without redis. So in this verbiage, is every single "stack/app" a "root module" and if one of them has a different database/whatever module it's just using different child modules and the child modules are the big differentiator? Just to kind of prove the root-module argument I'm making here, this post in here is confused on calling a "stack" a module as well https://news.ycombinator.com/item?id=37005949 https://news.ycombinator.com/item?id=37005949
- rcrowley 3y agoGlad we cleared up our terminology! I agree that “root module” risks ambiguity, just like you point out. I just realized I never responded to the very last point in your original comment. I don’t have, and I don’t think Terraform has, a complete solution to dependencies between root modules. Fortunately, data sources will at least fail if they don’t find what they’re looking for. For me, these failures never come up in production since I’m never using `terraform destroy` there. It does come up in pre-production testing and that’s an area that seems rich with patterns and products on top of Terraform that are controlling order and dependence between root modules. PS thanks for your work on Terraform and Kubernetes.
- xomodo 3y agoUse 'terraform destroy' during CI phase. That is your pre-prod.
- xomodo 3y agoRoot-module: contains resources, sub-modules, incl. remote module calls. Stack: deployable with hardcoded tfstate and tfvars configs.
- OJFord 3y agoMy 2ç as also a (very minor) terraform core, and numerous providers & modules contributor, and user (also 2015 I think): I've never heard of 'terraform stacks' before this thread, but 'root module' makes perfect sense to me: 1) without the context of where the state is/its contents, or estimating based on the resources/style/what's variable vs. hardcoded, a 'stack' (if you like) is indistinguishable from a module that's to be used in someone else's 'stack'; 2) `path.root`
- swozey 3y agolol That's interesting. I feel like all of the TACOS (spacelift, env0, atlantis) refer to stacks. Thanks for your response It's great to hear corroboration
- firesteelrain 3y ago> it's always ALBs, EKS, dbs, etc. components indepedently that go into creating a service/stack More importantly, modules represent the DRY principles. We host them in our private Terraform registry and share between teams
- datatrashfire 3y agoRoot module is the official terminology used in Hashicorps own documentation. That's actually the term I'm most familiar with in my own experience. https://developer.hashicorp.com/terraform/language/modules/syntax https://developer.hashicorp.com/terraform/language/modules/s... > Every Terraform configuration has at least one module, known as its root module, which consists of the resources defined in the .tf files in the main working directory.