简体   繁体   中英

How to specify resource provider version in the Terraform using AzureRM provider

I use Azure ARM templates for deploying Azure resources. Now I have been asked to convert a few of the ARM templates into Terraform files.

I am new to terraform world. I just went through some online examples of creating Azure resources using Terraform's AzureRM provider. but, nowhere did I find a way to set the API version for the Azure resource provider.

For example, In the ARM template, we can specify "apiVersion" for any resources but in the Terraform there is no option to choose the API version.

Does anyone know how to choose API Version in Terraform for Azure?

In Terrform we don't speficy the api version for each resource likewise we do in ARM template.

In terraform we only use the AzureRM provider version. If you are not mentioning specific version it will take the latest AzureRM provider version

The Azure Provider can be used to configure infrastructure in Microsoft Azure using the Azure Resource Manager API's.

Like below

    terraform {
      required_providers {
        azurerm = {
          source  = "hashicorp/azurerm"
          version =  "=3.10.0"
        }
      }
    }
    
    provider "azurerm" {
      features {}
    }


data "azurerm_resource_group" "example" {
  name     = "v-rasXXXXree"
  #location = "West Europe"
}

resource "azurerm_virtual_network" "example-2" {
  name                = "peternetwork2"
  resource_group_name = data.azurerm_resource_group.example.name
  address_space       = ["10.0.2.0/24"]
  location            = data.azurerm_resource_group.example.location
}

在此处输入图像描述

For more information please refer this official terarform document

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM