特点块地形

clo*_*cop 8 terraform azure-devops

terraform init 成功初始化但卡在 terraform 计划上。

该错误与功能块有关。我不确定在哪里添加功能块:

功能块不足(源代码不可用) 至少需要 1 个“功能”块。

我的配置看起来像

terraform {
  required_version = ">= 0.11"

  backend "azurerm" {
    features {}
   }
 }
Run Code Online (Sandbox Code Playgroud)

我尝试删除和添加功能块作为 github 页面

Pat*_*ick 29

该消息的另一个原因可能是正在使用指定的提供程序:

\n
provider "azurerm" {\n  alias = "some_name" # <- here\n  features {}\n}\n
Run Code Online (Sandbox Code Playgroud)\n

但未在资源上指定:

\n
resource "azurerm_resource_group" "example" {\n  # might this block is missing\n  # -> provider = azurerm.some_name\n  name     = var.rg_name\n  location = var.region\n}\n
Run Code Online (Sandbox Code Playgroud)\n

错误信息:

\n
terraform plan\n\xe2\x95\xb7\n\xe2\x94\x82 Error: Insufficient features blocks\n\xe2\x94\x82\n\xe2\x94\x82   on <empty> line 0:\n\xe2\x94\x82   (source code not available)\n\xe2\x94\x82\n\xe2\x94\x82 At least 1 "features" blocks are required.\n
Run Code Online (Sandbox Code Playgroud)\n

  • 哇这个错误绝对是一个谜!感谢您澄清这一点 (2认同)
  • 节省了我数小时的调试时间。谢谢! (2认同)

clo*_*cop 15

当您运行 terraform 的更新版本时,您需要定义下面定义的另一个块

provider "azurerm" { features {} }

谢谢@ SomeGuyOnAComputer


cod*_*des 6

在 Terraform >= 0.13 中,示例如下versions.tf(请注意提供程序配置位于单独的块中):

# versions.tf
terraform {
  required_providers {
    azurerm = {
      # ...
    }
  }
  required_version = ">= 0.13"
}

# This block goes outside of the required_providers block!
provider "azurerm" {
  features {}
}

Run Code Online (Sandbox Code Playgroud)