hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Linux web app's api_definition_url doesn't accept relative path #22041

Open adn-K987 opened 1 year ago

adn-K987 commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.7

AzureRM Provider Version

3.59.0

Affected Resource(s)/Data Source(s)

azurerm_linux_web_app

Terraform Configuration Files

terraform {
  required_version = "~>1.3.7"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~>3.59.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_api_management" "example" {
  name                = "example-apim"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  publisher_name      = "My Company"
  publisher_email     = "company@terraform.io"

  sku_name = "Developer_1"
}

resource "azurerm_api_management_api" "example" {
  api_management_name = azurerm_api_management.example.name
  resource_group_name = azurerm_resource_group.example.name

  name         = "example"
  display_name = "example"
  path         = "example"

  protocols             = ["https"]
  revision              = "1"
  subscription_required = false
}

resource "azurerm_service_plan" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  os_type             = "Linux"
  sku_name            = "P1v2"
}

resource "azurerm_linux_web_app" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_service_plan.example.location
  service_plan_id     = azurerm_service_plan.example.id

  site_config {
    api_definition_url    = "api/v3/api-docs.yaml" #tried also with /api/v3/api-docs.yaml
    api_management_api_id = azurerm_api_management_api.example.id
  }
}

Debug Output/Panic Output

module.app-service.azurerm_linux_web_app.backend_api: Refreshing state... [id=/subscriptions/xxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.Web/sites/xxxxxxxxxxx]
╷
│ Error: expected "site_config.0.api_definition_url" to have a host, got api/v3/api-docs.yaml
│ 
│   with module.app-service.azurerm_linux_web_app.example,
│   on modules/app-service/main.tf line 75, in resource "azurerm_linux_web_app" "example":
│   75:     api_definition_url    = "api/v3/api-docs.yaml"
│ 
╵
Error: Process completed with exit code 1.

Expected Behaviour

Resource created with API definition URL pointing to relative path.

Actual Behaviour

Deployment fails because validation expects URL format only.

module.app-service.azurerm_linux_web_app.backend_api: Refreshing state... [id=/subscriptions/xxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.Web/sites/xxxxxxxxxxx] ╷ │ Error: expected "site_config.0.api_definition_url" to have a host, got api/v3/api-docs.yaml │ │ with module.app-service.azurerm_linux_web_app.example, │ on modules/app-service/main.tf line 75, in resource "azurerm_linux_web_app" "example": │ 75: api_definition_url = "api/v3/api-docs.yaml" │ ╵ Error: Process completed with exit code 1.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

adn-K987 commented 1 year ago

To verify that relative paths should be accepted I created the App Service in the Azure Portal, and it worked. According to the field description relative paths are acceptable. image