官术网_书友最值得收藏!

Configuring the Terraform provider

Once the Azure SP has been created, we will configure our Terraform code to connect to Azure with this SP. For this, follow these steps:

  1. In a directory of your choice, create a new filename, provider.tf (extension.tf corresponds to Terraform files), which contains the following code:
provider "azurerm" {
subscription_id = "<subscription ID>"
client_id = "<Client ID>"
client_secret = "<Client Secret>"
tenant_id = "<Tenant Id>"
}

In this code, we indicate that the provider we are using is azurerm and that the authentication information to Azure is the service principal created. However, for security reasons, it is not advisable to put identification information in code, knowing that this code may be accessible by other people.

  1. We will, therefore, improve the previous code by replacing it with this one:
provider "azurerm" {}
  1. So, we delete the credentials in the Terraform code and we will pass the identification values to specific Terraform environment variables:
    • ARM_SUBSCRIPTION_ID
    • ARM_CLIENT_ID
    • ARM_CLIENT_SECRET
    • ARM_TENANT_ID
We will see how to set these environment variables later in this chapter, in the Deploy the infrastructure section.

As a result, the Terraform code no longer contains any identification information.

We have just seen how to configure Terraform for Azure authentication. We will now explain how to quickly configure Terraform to perform local development and testing.

主站蜘蛛池模板: 闽清县| 鄂伦春自治旗| 紫云| 呼图壁县| 双辽市| 洪湖市| 泌阳县| 桐柏县| 夏邑县| 枣庄市| 涞水县| 镇坪县| 乡城县| 土默特左旗| 霍邱县| 隆林| 理塘县| 大厂| 岑溪市| 西丰县| 迭部县| 马鞍山市| 井研县| 岱山县| 习水县| 莲花县| 枣庄市| 荥经县| 平遥县| 寿宁县| 东山县| 鹰潭市| 襄樊市| 罗江县| 广安市| 永仁县| 精河县| 延庆县| 成安县| 敖汉旗| 安达市|