【问题标题】:Azure Terraform initial setupAzure Terraform 初始设置
【发布时间】:2020-05-01 13:30:41
【问题描述】:

我之前成功地使用过 Terraform for AWS。现在我正在尝试使用 Azure 并面临一些挑战。我已使用 Azure CLI 成功验证了我的 azure 帐户。当我运行基本的 terraform 提供程序 arm .tf 并执行 terraform init 时,它就可以工作了。但是,当我输入任何其他代码(如容器创建或 blob 创建 .tfs)时,init 无法正常工作并给我以下消息:

没有可用的提供者“azure”插件与此 Terraform 版本兼容。

错误:没有可用的版本与此版本的 Terraform 兼容

地形版本:

bash-3.2$ terraform -v
Terraform v0.12.19
+ provider.azurerm v1.38.0

我使用了 1.38.0 版本并尝试了许多其他版本,但它仍然继续给我错误。

【问题讨论】:

  • 您的 Terraform 代码是什么样的?
  • bash-3.2$ cat main.tf provider "azurerm" { version = "~> 1.27" } bash-3.2$ cat container.tf resource "azure_storage_container" "stor-cont" { name = " terraform-storage-container" container_access_type = "blob" storage_service_name = "abcycentralstorage" }
  • 您应该编辑您的问题以将其包含在格式化的代码块中。但无论如何,这是一个简单的错字。那应该是azurerm_storage_container
  • 感谢您的回复。将资源从 azure_storage_container 更改为 azurerm_storage_container 使其工作。我还必须做另一项更改 - 从“storage_service_name”到“storage_account_name”。
  • 对上述内容的快速跟进是,我从以下位置获取了模板:terraform.io/docs/providers/azure/r/storage_container.html,但使用 azurerm 时的语法似乎不同。我应该寻找其他地方来获得准确的语法吗?

标签: azure terraform terraform-provider-azure


【解决方案1】:

它们是不同 Azure 模型的两个提供者。

Azure Service Management Provider模型是Azure中的经典模型,现在不推荐使用。它提供格式为azure_xxx 的资源。

Azure Resource Manager Provider模型是调用ARM的Resource Manager模型,推荐使用,支持良好。它提供格式为azurerm_xxx的资源。

您还可以在文档Azure Resource Manager vs. classic deployment: Understand deployment models and the state of your resources 中了解有关 ASM 和 ARM 模型的更多信息。

【讨论】:

  • @azdevad1 太好了,那你可以接受它作为答案。
猜你喜欢
  • 2018-06-03
  • 2021-06-26
  • 1970-01-01
  • 2013-10-12
  • 2019-12-22
  • 2020-03-20
  • 2022-10-05
  • 2016-02-15
  • 2019-01-23
相关资源
最近更新 更多