Learning DevOps
上QQ阅读APP看书,第一时间看更新

Better visibility with the separation of files

When executing Terraform code, all files in the execution directory that have the .tf extension are automatically executed; in our example, we have provider.tf and main.tf. It is good to separate the code into several files in order to improve the readability of the code and its evolution.

Using our example script, we can do better and separate it with the following:

  • Rg.tf, which contains the code for the resource group
  • Network.tf, which contains the code for the VNet and subnet
  • Compute.tf, which contains the code for the network interface, public IP, storage, and virtual machine