With the Terraform code written, we now need to run Terraform to deploy our infrastructure.
However, before any execution, it is necessary to first provide authentication with the Azure SP to ensure that Terraform can manage Azure resources.
For this, we can either set the environment variables specific to Terraform to contain the information of the SP created earlier in the Configuring Terraform for Azure section or use the az cli script.
The following script exports the four Terraform environment variables in the Linux OS:
export ARM_SUBSCRIPTION_ID=xxxxx-xxxxx-xxxx-xxxx
export ARM_CLIENT_ID=xxxxx-xxxxx-xxxx-xxxx
export ARM_CLIENT_SECRET=xxxxxxxxxxxxxxxxxx
export ARM_TENANT_ID=xxxxx-xxxxx-xxxx-xxxx
We can also use the az cli script with the login command:
az login
Once authenticated, we can run Terraform.
In our scenario, for example...