我遇到了以下错误消息,但我无法确定我错过了什么。
错误:创建作用域策略分配(作用域:“/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx”策略分配名称:“允许的位置”):400错误提示:策略参数缺少值:策略参数“listOfAllowedLocations”缺少值。
下面是我的Terraform代码
provider "azurerm" {
features {}
}
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.96.0"
}
}
}
resource "azurerm_subscription_policy_assignment" "Allowedlocations2" {
name = "Allowed locations"
subscription_id = var.cust_scope
policy_definition_id = "/providers/Microsoft.Authorization/policyDefinitions/e56962a6-4747-49cd-b67b-bf8b01975c4c"
description = "This policy enables you to restrict the locations your organization can specify when deploying resources."
display_name = "Allowed locations"
metadata = <<METADATA
{
"category": "General"
}
METADATA
parameters = <<PARAMETERS
{
"listOfAllowedLocations": {
"type": "Array",
"metadata": {
"description": "The list of locations that can be specified when deploying resources.",
"strongType": "location",
"displayName": "Allowed locations",
"strongType": "location"
},
"defaultValue": [
"eastus"
],
"allowedValues": [
"eastus",
"eastus2"
]
}
}
PARAMETERS
}
作为一个Terraform初学者,我错过了一个值,但我无法找到它。如果有人知道它是什么以及如何找到它,请告诉我。
azurerm_subscription_policy_assignment.Allowedlocations2: Creating...
╷
│ Error: creating Scoped Policy Assignment (Scope: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
│ Policy Assignment Name: "Allowed locations"): unexpected status 400 with error: **PolicyParametersMissingValue: The policy parameters 'listOfAllowedLocations' are missing a value.**
│
│ with azurerm_subscription_policy_assignment.Allowedlocations2,
│ on main.tf line 65, in resource "azurerm_subscription_policy_assignment" "Allowedlocations2":
│ 65: resource "azurerm_subscription_policy_assignment" "Allowedlocations2" {
│
│ creating Scoped Policy Assignment (Scope: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
│ Policy Assignment Name: "Allowed locations"): unexpected status 400 with error: PolicyParametersMissingValue: The policy parameters 'listOfAllowedLocations' are missing a value.
╵
1条答案
按热度按时间smtd7mpg1#
错误:创建作用域策略分配(作用域:“/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx”策略分配名称:“允许的位置”):400错误提示:策略参数缺少值:策略参数“listOfAllowedLocations”缺少值。
上述错误消息的原因表明,
listOfAllowedLocations
参数在您的策略assignment.it中缺少一个值,似乎您错误地定义了parameters
块。当我尝试在不使用错误格式的
listOfAllowedLocations
的情况下传递它时,我也会得到与您相同的错误。下面是
Terraform code
更新,用于创建策略定义和分配。Terraform适用:
一旦运行,上述代码策略将分配给
subscription
范围,如下所示。