![](/img/trans.png)
[英]how to use Loops in Terraform to deploy 2 different azure resources
[英]How to get round Plugin Errors when deploying Azure resources using Terraform?
我收到以下錯誤
│ 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、提供商和 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
我試過的……
在 inte.net 上進行研究,它說這只發生在 Azure 門戶中的 Azure CLI 中..我已經在 Visual Studio Code 和 Powershell 上嘗試過我自己的機器..但我得到了相同的結果..我什至嘗試將https://registry.terraform.io/providers/hashicorp/azurerm/latest作為源而不是通常的“hashicorp/azurerm”,但這也引發了錯誤
我真的被困住了……任何指導都會很感激……我一整天都在使用相同的方法愉快地部署 Azure 資源……但出於某種原因……它只是不喜歡這個……
這可能是由於您的 Az CLI session 出現問題,您可能需要使用az login
重新登錄。
您可以通過運行需要與資源交互的 Az CLI 命令(而不僅僅是az account show
)來確認這是否是問題所在。 這就是我確定問題的方式:
$ az vm list -g 我的資源組
AADSTS700082:由於不活動,刷新令牌已過期。 該令牌於 2021-06-27T00:13:23.1948087Z 發布,並在 90.00:00:00 處於非活動狀態。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.