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

  • Learning DevOps
  • Mikael Krief
  • 242字
  • 2021-06-24 12:32:06

Deploying the infrastructure with Terraform

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, we start with an empty Azure subscription without any group resources, but in the real world, our subscription may already contain group resources. 

Before running Terraform, in the Azure portal, check that we do not have a resource group in our subscription:

To run Terraform, we must open a command-line Terminal such as CMD, PowerShell, or Bash and go to the directory where the Terraform code files we wrote are located.

The Terraform code is executed in several steps such as initialization, the preview of changes, and the application of those changes.

Let's look in detail at the execution of these steps next, starting with the initialization step.

主站蜘蛛池模板: 日照市| 中阳县| 靖边县| 肥乡县| 衡山县| 论坛| 广平县| 宣武区| 龙里县| 龙口市| 曲阳县| 马山县| 浦东新区| 墨玉县| 化州市| 交口县| 广汉市| 思南县| 肃宁县| 宁南县| 肃宁县| 洪雅县| 靖江市| 德阳市| 綦江县| 永川市| 万荣县| 五峰| 太仆寺旗| 湟源县| 新化县| 上林县| 吉首市| 即墨市| 芷江| 出国| 六枝特区| 句容市| 屏山县| 拉孜县| 宜兰市|