Provisioning multiple resources with the count meta-argument
In many corporate scenarios, there is a need to provide infrastructure and to consider 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.
The challenges we will have to face are as follows:
- Writing Terraform configuration that does not require duplicate code for each instance of the 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_linux_web_app...