Course outlines for learning terraform.
| expected time | requirements |
|---|---|
| 60 minutes | A computer with Terraform installed. |
Goal: Learn how module dependencies work in Terraform.
Using modules make the root-module much easier to read, so you’ll likely end up writing and/or using modules.
Modules can depend on each other since Terraform 0.13. (August 2020)
You can simply use depends_on for an explicit dependency or refer to module.NAME.OUTPUT.
Have a look at this experiment
network, instance.network directory, create a main.tf to create the network.network module outputs the network id.instance directory, create a main.tf to create the instance.instance module needs a variable to describe the network this instance should live in.instance/main.tf, make sure to use the var.network created in the step above.main.tf in the root-module, calling both the ./network and ./instance module.instance to the module network, by mentioning the module.network.id as input for the instance module.one and two is based on a (hidden, not exposed) artefact. How would you rewrite the code to make this dependency visible?If you need to set an explicit dependency, reconsider if you are doing it wrong.