【发布时间】:2021-10-28 14:23:58
【问题描述】:
我收到以下错误
│ Error: Plugin error
│
│ with provider["registry.terraform.io/hashicorp/azurerm"],
│ on nsg.tf line 13, in provider "azurerm":
│ 13: provider "azurerm" {
│
│ The plugin returned an unexpected error from plugin.(*GRPCProvider).ConfigureProvider: rpc error: code = Internal desc = grpc: error while marshaling: string field
│ contains invalid UTF-8
当我尝试对以下代码执行 Terraform 计划时
# Configure the Microsoft Azure Provider
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.74.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
}
resource "azurerm_network_security_group" "nsg" {
name = "TestNSG"
location = "East US"
resource_group_name = "TFResourcegroup"
}
resource "azurerm_network_security_rule" "example1" {
name = "Web80"
priority = 1001
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "TFResourcegroup"
network_security_group_name = azurerm_network_security_group.nsg.name
}
resource "azurerm_network_security_rule" "example2" {
name = "Web8080"
priority = 1000
direction = "Inbound"
access = "Deny"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "8080"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "TFResourcegroup"
network_security_group_name = azurerm_network_security_group.nsg.name
}
resource "azurerm_network_security_rule" "example3" {
name = "WebOUT"
priority = 1000
direction = "Outbound"
access = "Deny"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "TFResourcegroup"
network_security_group_name = azurerm_network_security_group.nsg.name
}
这些是我的 terraform、provider 和 Azure 版本
PS C:\russ\nsg> terraform --version
Terraform v1.0.4
on windows_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.74.0
PS C:\russ\nsg> az --version
azure-cli 2.27.2
我试过的.....
在互联网上进行研究,它说这只发生在 Azure 门户的 Azure CLI 中。我已经在我自己的机器上的 Visual Studio Code 和 Powershell 上尝试过它。但我得到了相同的结果。我甚至尝试将https://registry.terraform.io/providers/hashicorp/azurerm/latest 作为来源而不是通常的“hashicorp/azurerm”,但这也引发了错误
我真的被困住了...任何指导都会很感激... ...
【问题讨论】:
-
嗨,我有点怀疑了这个..我尝试在 Bash 而不是 Powershell 中运行它,它运行良好...有人知道为什么这可能是案例?
-
您找到其他解决方案了吗?我也有同样的问题。
标签: azure terraform-provider-azure