Writing a Terraform script to deploy Azure infrastructure

To illustrate the use of Terraform to deploy resources in Azure, we will provision a simple Azure architecture with Terraform that is composed of the following:

  • There's a group resource.
  • There's also a network part composed of a virtual network and a subnet.
  • In this subnet, we will create a virtual machine that has a public IP address in order to be publicly available.

For this, in the same directory where we previously created the provider.tf file, we will create a main.tf file with the following code:

  1. Let's start with the code that provides the resource group:
resource "azurerm_resource_group" "rg" {    name = "bookRg"    location = "West Europe"    tags { environment = "Terraform Azure" ...

Get Learning DevOps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.