Terraform Azurerm_kubernetes_cluster无效或未知密钥:network_profile

时间:2018-09-27 09:46:10

标签: azure networking kubernetes terraform

在为 azurerm_kubernetes_cluster

设置高级网络时,我需要一些帮助。

我一直以此页中的代码为例 https://www.terraform.io/docs/providers/azurerm/r/kubernetes_cluster.html

唯一的区别是,我为此目的而制作了一个模块。剩下的一切都差不多

问题出在

network_profile {
    network_plugin = "azure"
  }

运行Terraform计划后,我收到以下错误:

Error: module.aks.azurerm_kubernetes_cluster.aks: : invalid or unknown key: network_profile

我将很高兴为您提供任何帮助

ask.tf

resource "azurerm_resource_group" "aks" {
  name = “name-rg”
  location = “East US”
}

resource azurerm_network_security_group "aks_nsg" {
  name                = “name-nsg"
  location            = "${azurerm_resource_group.aks.location}"
  resource_group_name = "${azurerm_resource_group.aks.name}"
}

resource "azurerm_virtual_network" "aks_vnet" {
  name                = “name-vnet"
  location            = "${azurerm_resource_group.aks.location}"
  resource_group_name = "${azurerm_resource_group.aks.name}"
  address_space       = ["10.2.0.0/16"]
}

resource "azurerm_subnet" "aks_subnet" {
  name                      = “name-subnet"
  resource_group_name       = "${azurerm_resource_group.aks.name}"
  network_security_group_id = "${azurerm_network_security_group.aks_nsg.id}"
  address_prefix            = "10.2.0.0/24"
  virtual_network_name      = "${azurerm_virtual_network.aks_vnet.name}"
}

resource "azurerm_kubernetes_cluster" "aks" {
  name                = "aks-name"
  location            = "${azurerm_resource_group.aks.location}"
  resource_group_name = "${azurerm_resource_group.aks.name}"
  dns_prefix          = “dns-name”

  linux_profile {
    admin_username = "${var.aks_admin_username}"

  ssh_key {
      key_data = "${var.aks_ssh_public_key_path}"
    }
  }

  agent_pool_profile {
    name            = "default"
    count           = "${var.aks_agent_count}"
    vm_size         = "${var.aks_vm_size}"
    os_type         = "${var.aks_os_type}"
    os_disk_size_gb = "${var.aks_os_disk_size_gb}"
    vnet_subnet_id = "${azurerm_subnet.aks_subnet.id}"
  }

  service_principal {
    client_id     = "${var.aks_client_id}"
    client_secret = "${var.aks_client_secret}"
  }

  network_profile {
    network_plugin     = "azure"
  }
}

更新:

Terraform v0.11.8
+ provider.azurerm v1.5.0          <---- Wrong version, should be v1.15.0

2 个答案:

答案 0 :(得分:0)

  • provider.azurerm v1.5.0 <----版本错误,应为v1.15.0

答案 1 :(得分:0)

检查main.tf,如果已修复提供程序版本,则需要将其取出(请参见下文)并再次进行测试。

provider "azurerm" {
 #version = "=1.5.0"
}

当前应为1.20.0