-
-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform.tfvars
only for composition?
#28
Comments
compostion is a strange word for a workspace. A workspace is composed of many modules; but, there's already a standard term for this... workspace. in the example of small-size infrastructures, it is odd that there's no modules being used; but, there doesn't necessarily have to be in order to be considered a workspace. terraform.tfvar should not be found in modules, and should instead be found only in workspaces. Since the small-size infrastructure is indeed a workspace, it's okay for there to be terraform.tfvar files. It should be noted that by using terraform.tfvars files you are making somewhat more difficult to reuse this code. You would more than likely benefit from reading these docs, https://www.terraform.io/cloud-docs/guides/recommended-practices/part1. This document lists using one workspace per environment per configuration, this is where code reusability for workspaces comes into play. |
"Workspaces" are not "Workspaces"I think that it is important to note that the term "workspace" refers to very different things depending on if you are using it in the context of Terraform Cloud or Terraform CLI. In this case, a Terraform Cloud Workspace is "used to manage a collection of infrastructure," which is, in essence, what a "composition" does. This equivalent to a working directory in the CLI, which is probably how you're used to managing different collections of infrastructure with a local machine using different directories for each. Terraform CLI Workspaces are used to switch between multiple distinct instances of the same configuration, that is, using multiple state files with the same backend. This is convenient because you don't have to create a separate configuration with its own backend just to create a slightly different version of your infrastructure, for example if you wanted to test out a change to your configuration but you didn't want to affect your existing infrastructure. The docs expound on this and offers suggestions on whether or not to use the feature depending on the situation, but I digress. Compositions?But going back to the question of where to use a I think the problem with the term "composition" is that it is defined with a specific hierarchy and encapsulation rules. Going by that definition, technically the small-sized infrastructure example isn't a composition because it doesn't call any modules, let alone modules that call other modules. It is, however, the root module which in this case makes up the complete Terraform configuration.
Perhaps specifying the above would be an improvement, but I think the real problem is with the idea of what a "composition" is. |
First of all, thanks for providing this great book!
The Getting started with structuring of Terraform configurations section states that
terraform.tfvars
files should exclusively be used with composition:In turn, the Composition section defines composition as follows:
However, the example for small-size infrastructures doesn't have any module but nevertheless uses a
terraform.tfvars
file.I'm wondering who's wrong here - the code structure section or the code example?
The text was updated successfully, but these errors were encountered: