在 Terraform Azure 应用服务资源中配置 CORS

Pre*_*onM 5 azure cors azure-virtual-network terraform azure-sdk

我有以下 Terraform 资源用于配置 Azure 应用服务:

resource "azurerm_app_service" "app_service" {
  name                = "Test-App-Service-3479112"
  location            = "${azurerm_resource_group.resource_group.location}"
  resource_group_name = "${azurerm_resource_group.resource_group.name}"
  app_service_plan_id = "${azurerm_app_service_plan.app_service_plan.id}"

  site_config {
    dotnet_framework_version = "v4.0"
    remote_debugging_version = "VS2012"
  }

  app_settings {
    "ASPNETCORE_ENVIRONMENT" = "test"
    "WEBSITE_NODE_DEFAULT_VERSION" = "4.4.7"
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试添加要在我的资源中使用的 CORS 原始值。有没有办法在 Terraform 中添加它,或者如果没有,我该如何在我的 Terraform 文件中配置它(可能使用 Azure SDK)?

RuS*_*uSs 5

全部,

现在可以在这里找到:https : //www.terraform.io/docs/providers/azurerm/r/app_service.html#cors

这是我的例子:

resource "azurerm_app_service" "my-app" {
  name                = "${var.api_name}"
  location            = "${var.location}"
  resource_group_name = "${var.resource_group}"
  app_service_plan_id = "${azurerm_app_service_plan.api_asp.id}"

  site_config {
    cors {
      allowed_origins = ["https://${var.ui_name}${var.dns_suffix}"]
    }
  }

  identity = {
    type = "SystemAssigned"
  }
}
Run Code Online (Sandbox Code Playgroud)

并证明上述方法有效: 在此处输入图片说明