forked from aztfmod/terraform-azurerm-caf
-
Notifications
You must be signed in to change notification settings - Fork 0
Directory Structure
GlennChia edited this page Jul 7, 2021
·
3 revisions
Using the example of consumption_budget, a module has the following simplified structure in the caf_repo
├───.github
│ └───workflows
│ └───standalone-scenarios.json
├───examples
│ |───consumption_budget
│ | └───100-consumption-budget-rg
| | └───configuration.tfvars
│ |───module.tf
│ └───variables.tf
│───modules
│ └───consumption_budget
│ └───resource_group
│ ├───main.tf
│ ├───output.tf
│ ├───resource_group_budget.tf
│ └───variables.tf
│───consumption_budgets.tf
│───main.tf
│───locals.combined_objects.tf
└───locals.tf
.github
- Contains the files needed for automated tests via GitHub Actions.
- Typically a path to the directory containing the
configuration.tfvarsfile is inserted into the 4 files above when one of the following is added:- A new module is created that has a
.tfvarsfile associated - Additional examples are added that have their own
.tfvarsfile.
- A new module is created that has a
examples
- Contains directories that contain the
configuration.tfvarsfile that injects variables into theexamples/variables.tffile -
variables.tfis where the variable (typically an object) is initialized. This variable name corresponds to how it was declared in the.tfvarsfile -
module.tfis where variables are injected and passed into the modules that the landingzone will initialize. This is a centralized module that controls which other modules are created based on the variables it receives from the respective.tfvarsfiles
modules
- Contains the definition of the resources
-
main.tfis where the providers are initialized. Typically at this level, only theaztfmod/azurecafprovider is initialized -
output.tfis where output attributes are declared. Examples include theidwhich can be used in other modules that can be integrated -
resource_group_budget.tfis where the Terraform registry resource is declared together with its attributes. The file name will depend on the resource created -
variables.tfis where the variables are declared. These should correspond to the variables injected from the rootconsumption_budgets.tffile. In this case, depending on your module, the file that injects the variables could be different but should still be found in the root.
consumption_budgets.tf
- Located in the root directory
- This file contains the module that uses a
for_eachiteration to initialize the appropriate number of instances of the resource depending on the setup of theconfiguration.tfvarsfile.
main.tf
- Where the providers are initialized. Typically at this level, the common pattern is to upgrade the version of
azurerm.
locals.combined_objects.tf
- Merges the local state and the remote state to give a combined object
locals.tf
- Its values are directly injected from
examples/module.tf