Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform: Remove deprecated azurerm_app_service resource in favor of azurerm_linux_web_app & azurerm_windows_web_app #53

Open
epopisces opened this issue Nov 20, 2023 · 1 comment
Labels
terraform Items related to the Terraform IaC code
Milestone

Comments

@epopisces
Copy link

epopisces commented Nov 20, 2023

azurerm_app_service is deprecated in version 3.x of the azurerm provider. The recommended guidance is to use the new azurerm_linux_web_app & azurerm_windows_web_app resources. These can be implemented via parallel resources (one for linux, one for windows) enabled/disabled via count with a conditional based on the parent app service resource's type, like so:

resource "azurerm_linux_web_app" "redcap" {
  count                     = var.os_type == "Linux" ? 1 : 0
  ...
}

...
resource "azurerm_windows_web_app" "redcap" {
  count                     = var.os_type != "Linux" ? 1 : 0
  ...
}

Note this does (unfortunately) require all dependent resources to include the same conditional and also use a index, like so:

resource "azurerm_private_endpoint" "web_app" {
  ...

  private_service_connection {
    name                           = "example"
    private_connection_resource_id = var.os_type == "Linux" ? (
      azurerm_linux_web_app.redcap[0].id 
    ) : ( 
      azurerm_windows_web_app.redcap[0].id
    )
    subresource_names              = ["sites"]
    is_manual_connection           = false
  }
  ...

}
@epopisces
Copy link
Author

If this template is only intended to support Linux, the deprecation path is even simpler: simply update azurerm_app_service to azurerm_linux_web_app and change the app_service_plan_id argument to service_plan_id, the other arguments should be fine.

@epopisces epopisces changed the title Remove deprecated azurerm_app_service resource from terraform deployment in favor of azurerm_linux_web_app & azurerm_windows_web_app Terraform: Remove deprecated azurerm_app_service resource in favor of azurerm_linux_web_app & azurerm_windows_web_app Nov 20, 2023
@SvenAelterman SvenAelterman added the terraform Items related to the Terraform IaC code label Nov 25, 2023
@SvenAelterman SvenAelterman added this to the Backlog milestone Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
terraform Items related to the Terraform IaC code
Projects
None yet
Development

No branches or pull requests

2 participants