How to Avoid Full Redeployment of Azure Application Gateway with Terraform?

November 1, 2025 5 answers
Asked by CuriousCat123
I'm currently managing an Azure Application Gateway (WAF_v2) using Terraform with the azurerm provider. I've noticed that whenever I update the configuration, especially when adding new components like backend address pools, HTTP listeners, probes, or routing rules, Terraform ends up proposing a complete redeployment of the entire Application Gateway. This means it plans to destroy and recreate the whole gateway instead of just making incremental changes. I've tried using for_each within the azurerm_application_gateway resource to manage these blocks dynamically, but it doesn't resolve the issue. This repeated full redeployment leads to extended downtimes for my production workloads whenever I want to modify or add specific parts. Has anyone figured out a way to prevent this behavior and make changes without causing the entire Application Gateway to redeploy in Terraform?

Answers

DevDude92
You might want to try using the ignore_changes argument. It can help you avoid the replacement of the whole resource when you modify certain attributes. Just remember that itโ€™s useful to prevent unwanted behavior for specific settings you change.
Reply to this answer
CodeExplorer88
You might be facing a known issue mentioned here: https://github.com/hashicorp/terraform-provider-azurerm/issues/16136#issuecomment-2658678703. It suggests that while it shows everything is being recreated, it shouldn't truly do that if set up correctly. It really complicates the resource's usability.
Reply to this answer
ConfigWizard
Whoever designed the Azure Application Gateway configuration without sub-resources seems to have overlooked usability. This approach can lead to excessive redeployments that are frustrating.
Reply to this answer
TechGuru77
Can you share your code? Adding or removing those blocks shouldn't cause the entire application gateway to redeploy. Normally, Terraform handles these changes better. Just a heads-up, the way Terraform structures certain properties as Sets can lead to this issue, as it doesn't manage the order of elements. When anything is added or removed, it views it as a total change and ends up recreating everything instead of just updating what's needed.
Reply to this answer
SkepticalDev
If youโ€™re using lists, I recommend switching to maps. They can provide more stability and prevent issues with changes triggering full redeploys.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions