To begin, we will use a Terraform configuration that allows us to provision one Azure App Service, which is in a main.tf file and of which the following is an extract:
resource "azurerm_app_service" "app" {
name = "${var.app_name}-${var.environement}"
location = azurerm_resource_group.rg-app.location
resource_group_name = azurerm_resource_group.rg-app.name
app_service_plan_id = azurerm_app_service_plan.plan-app.id
}
The purpose of this recipe is to apply and modify this Terraform configuration to provision N Azure App Service instances identical to the one already described in the base code, with just a slight difference in the names, which use an incremental index number starting at 1.
The source code of this recipe is available at https://github.com/PacktPublishing/Terraform-Cookbook/tree/master/CHAP03/count.