Introduction to Infrastructure as Code with Terraform
What is Infrastructure as Code and Why is Terraform Useful?
Install Terraform on Mac, Linux, or Windows by downloading the binary or using a package manager (Homebrew or Chocolatey). Then create a Docker container locally by following a quick-start tutorial to check that Terraform installed correctly.
Initialize, plan and apply configuration in a directory to create an Azure resource group. Inspect the Terraform state to discover the group ID once Terraform creates it.
Add tags to an existing Azure resource group to learn how Terraform manages infrastructure changes. Edit Terraform configuration, then plan and apply the change.
Destroy Azure infrastructure managed by Terraform. Evaluate the plan and confirm the destruction.
Create Resource Dependencies
Create an implicit dependency between an Azure virtual network and a resource group using expressions. Read about creating explicit dependencies using a meta-argument.
Define Input Variables
Declare your Azure location, resource tags, and virtual machine credentials as variables. Reference these variables in Terraform configuration. Define them using command line flags, environment variables, .tfvars files or default values.
Query Data with Output Variables
Output the public IP of Azure infrastructure using output variables. Read about using outputs to query specific data from Terraform state.
Store Remote State
Configure Terraform to store state in Terraform Cloud remote backend. Add a remote state block directly to configuration or set an environment variable to load remote state configuration when Terraform initializes.