Terraform output, state, console, and graphs
While we understand that Terraform uses state files to manage resources, let’s look at some advanced commands to help us appreciate and make more sense of the Terraform state concept.
To access the resources for this section, cd
into the following:
$ cd ~/modern-devops/ch8/terraform-workspaces/
Now, let’s go ahead and look at our first command – terraform output
.
terraform output
So far, we’ve looked at variables but haven’t yet discussed outputs. Terraform outputs are return values of a Terraform configuration that allow users to export configuration to users or any modules that might use the current module.
Let’s go with the last example and add an output variable that exports the private IP of the network interface attached to the VM in the outputs.tf
file:
output "vm_ip_addr" { value = azurerm_network_interface.main.private_ip_address }
Now, let’...