KungWaz
KungWaz

Reputation: 1956

Can I create an API app in Azure using Terraform?

According to this answer one should be able to add the "kind" attribute and set its value to "api" in the azurerm_windows_web_app resource, but when I do this I get this error:

Can't configure a value for "kind": its value will be decided automatically based on the result of applying this configuration.

Is there a way to accomplish this in another way using Terraform? I want the resource to specifically be an API app (with the special icon) in Azure.

Upvotes: 0

Views: 234

Answers (1)

Venkat V
Venkat V

Reputation: 7820

Can't configure a value for "kind": its value will be decided automatically based on the result of applying this configuration.

The Kind parameter works with the old azurerm_app_service_plan module but not with the new azurerm_service_plan module. I also encountered the same error when using the new module.

enter image description here

Alternatively, you can create a web app with the Kind parameter using the old azurerm_app_service_plan module in Terraform

Below are the values supported in the Kind operation.

Note: 'Kind: API' is not supported in the old module either.

enter image description here

    provider "azurerm" {
      features {}
    }
    
    resource "azurerm_resource_group" "example" {
      name     = "webapp-rg-2"
      location = "West Europe"
    }
    
    resource "azurerm_app_service_plan" "example" {
      name                = "webapp-appserviceplan"
      location            = azurerm_resource_group.example.location
      resource_group_name = azurerm_resource_group.example.name
      kind                = "App"
      reserved            = true
      sku {
        tier = "Standard"
        size = "S1"
      }
    }
    
    resource "azurerm_windows_web_app" "example" {
      name                = "windows-webapp-test1"
      resource_group_name = azurerm_resource_group.example.name
      location            = azurerm_resource_group.example.location
      service_plan_id     = azurerm_app_service_plan.example.id
     
     site_config {}
    }

Terraform Plan enter image description here

Terraform Apply

enter image description here

Once the Terraform code is run, the web app has been created.

enter image description here

Upvotes: 0

Related Questions