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

0
28
Asked By CuriousCat123 On

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?

5 Answers

Answered By SkepticalDev On

If you’re using lists, I recommend switching to maps. They can provide more stability and prevent issues with changes triggering full redeploys.

Answered By TechGuru77 On

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.

Answered By ConfigWizard On

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.

Answered By CodeExplorer88 On

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.

Answered By DevDude92 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.