Terraform: Error: Error parsing App Service Resource ID
Terraform: Error: Error parsing App Service Resource ID
这是this question
的延续
resource "azurerm_app_service_slot" "app_service_slot_template" {
for_each = {for sl in "${var.app_service_slots}" : sl.name => sl }
app_service_name = "${var.mandatory_prefix}-${var.app_service_name}"
resource_group_name = "${var.resource_group_name}"
app_service_plan_id = "${data.azurerm_app_service_plan.service_plan.id}"
location = "${var.resource_location}"
https_only = true
name = "${each.value["name"]}"
dynamic "site_config" {
for_each = "${var.site_config}"
content {
min_tls_version = lookup(site_config.value, "min_tls_version", null)
python_version = lookup(site_config.value, "python_version", null)
java_version = lookup(site_config.value, "java_version", null)
always_on = lookup(site_config.value, "always_on", null)
app_command_line = lookup(site_config.value, "app_command_line", null)
dotnet_framework_version = lookup(site_config.value, "dotnet_framework_version", null)
}
}
dynamic "connection_string" {
for_each = "${each.value["connection_strings"]}"
content {
name = "${connection_string.value["name"]}"
type = "${connection_string.value["type"]}"
value = "${connection_string.value["value"]}"
}
}
app_settings = "${merge(each.value["app_settings"], local.additional_app_settings)}"
}
# Get the Id of the subnet
data "azurerm_subnet" "azurerm_subnet_template" {
name = "${var.subnet_name}"
virtual_network_name = "${var.virtual_network_name}"
resource_group_name = "${var.vnet_resource_group_name}"
}
resource "azurerm_app_service_virtual_network_swift_connection" "azureapp_vnet_integration_for_slot" {
for_each = {for sl in "${azurerm_app_service_slot.app_service_slot_template}" : sl.name => sl }
app_service_id = "${each.value.id}"
subnet_id = "${data.azurerm_subnet.azurerm_subnet_template.id}"
depends_on = [azurerm_app_service_slot.app_service_slot_template]
}
这在 Terraform 计划上完美运行,但是在应用期间失败并出现以下错误
Error: Error parsing App Service Resource ID
on .terraform/modules/generic_app_service/main.tf line 235, in
resource "azurerm_app_service_virtual_network_swift_connection"
"azureapp_vnet_integration_for_slot": 235: resource
"azurerm_app_service_virtual_network_swift_connection"
"azureapp_vnet_integration_for_slot" {
我可以从计划输出中确认 app_service_id 是 getting/passing Azure 插槽的正确资源 ID,但不知道为什么它会抱怨应用服务资源 ID
app_service_id 的文档写道:
The ID of the App Service or Function App to associate to the VNet. Changing this forces a new resource to be created.
所以它应该是 azurerm_app_service
或 azurerm_function_app
的 ID。但是您正在尝试使用 azurerm_app_service_slot
,这是一种不同的资源。
这是this question
的延续resource "azurerm_app_service_slot" "app_service_slot_template" {
for_each = {for sl in "${var.app_service_slots}" : sl.name => sl }
app_service_name = "${var.mandatory_prefix}-${var.app_service_name}"
resource_group_name = "${var.resource_group_name}"
app_service_plan_id = "${data.azurerm_app_service_plan.service_plan.id}"
location = "${var.resource_location}"
https_only = true
name = "${each.value["name"]}"
dynamic "site_config" {
for_each = "${var.site_config}"
content {
min_tls_version = lookup(site_config.value, "min_tls_version", null)
python_version = lookup(site_config.value, "python_version", null)
java_version = lookup(site_config.value, "java_version", null)
always_on = lookup(site_config.value, "always_on", null)
app_command_line = lookup(site_config.value, "app_command_line", null)
dotnet_framework_version = lookup(site_config.value, "dotnet_framework_version", null)
}
}
dynamic "connection_string" {
for_each = "${each.value["connection_strings"]}"
content {
name = "${connection_string.value["name"]}"
type = "${connection_string.value["type"]}"
value = "${connection_string.value["value"]}"
}
}
app_settings = "${merge(each.value["app_settings"], local.additional_app_settings)}"
}
# Get the Id of the subnet
data "azurerm_subnet" "azurerm_subnet_template" {
name = "${var.subnet_name}"
virtual_network_name = "${var.virtual_network_name}"
resource_group_name = "${var.vnet_resource_group_name}"
}
resource "azurerm_app_service_virtual_network_swift_connection" "azureapp_vnet_integration_for_slot" {
for_each = {for sl in "${azurerm_app_service_slot.app_service_slot_template}" : sl.name => sl }
app_service_id = "${each.value.id}"
subnet_id = "${data.azurerm_subnet.azurerm_subnet_template.id}"
depends_on = [azurerm_app_service_slot.app_service_slot_template]
}
这在 Terraform 计划上完美运行,但是在应用期间失败并出现以下错误
Error: Error parsing App Service Resource ID
on .terraform/modules/generic_app_service/main.tf line 235, in resource "azurerm_app_service_virtual_network_swift_connection" "azureapp_vnet_integration_for_slot": 235: resource "azurerm_app_service_virtual_network_swift_connection" "azureapp_vnet_integration_for_slot" {
我可以从计划输出中确认 app_service_id 是 getting/passing Azure 插槽的正确资源 ID,但不知道为什么它会抱怨应用服务资源 ID
app_service_id 的文档写道:
The ID of the App Service or Function App to associate to the VNet. Changing this forces a new resource to be created.
所以它应该是 azurerm_app_service
或 azurerm_function_app
的 ID。但是您正在尝试使用 azurerm_app_service_slot
,这是一种不同的资源。