错误:Terraform Core 版本不受支持

Viv*_*Dev 2 azure terraform

我有一个简单的地形配置,如下所示。

\n
# Terraform settings Block\nterraform {\n  required_version = "~> 1.0.0"\n  required_providers {\n    azurerm = {\n      source  = "hashicorp/azurerm" # https://registry.terraform.io/providers/hashicorp/azurerm/latest\n      version = "~> 3.0"\n    }\n  }\n}\n\nprovider "azurerm" {\n  features { }\n}\n\nresource "azurerm_resource_group" "rg" {\n  name     = var.resource_group_name\n  location = var.resource_group_location\n}\n
Run Code Online (Sandbox Code Playgroud)\n

当我跑步时

\n
terraform init\n
Run Code Online (Sandbox Code Playgroud)\n

我收到以下错误。

\n
\xe2\x95\xb7\n\xe2\x94\x82 Error: Unsupported Terraform Core version\n\xe2\x94\x82\n\xe2\x94\x82   on main.tf line 3, in terraform:\n\xe2\x94\x82    3:   required_version = "~> 1.0.0"\n\xe2\x94\x82\n\xe2\x94\x82 This configuration does not support Terraform version 1.2.2. To proceed, either choose another supported Terraform version or update this version\n\xe2\x94\x82 constraint. Version constraints are normally set for good reason, so updating the constraint may lead to other errors or unexpected behavior.    \n\xe2\x95\xb5\n
Run Code Online (Sandbox Code Playgroud)\n

如果所需版本按以下方式设置,则可以正常工作(将 ~> 更改为 >=)。

\n
required_version = ">= 1.0.0"\n
Run Code Online (Sandbox Code Playgroud)\n

看了这个文档,但不清楚该怎么做。我应该恢复到required_version = ">= 1.0.0"

\n

只是想确保最新的未成年人已就位。另请参阅某处,对于生产,建议使用带有波形符(~)的版本。现在有点迷茫了

\n

Mar*_*cin 6

您已经安装了 TF 版本1.2.2,显然该版本要新得多 1.0.0。如果您想使用这样旧版本的 TF,您必须下载旧版本的 terraform,并使用它来运行脚本。