In corporate scenarios, there is a need to provide infrastructure and to take into account the so-called horizontal scalability, that is, N identical resources that will reduce the load on individual resources (such as compute instances) and the application as a whole.
The challenge we will have to face is as follows:
-
Writing Terraform configuration that does not require duplicate code for each instance of identical resources to be provisioned
-
Being able to rapidly increase or reduce the number of instances of these resources
We will see in this recipe how Terraform makes it possible to provision N instances of resources quickly and without the duplication of code.
Getting ready
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 ...