I'm working with an Azure Application Gateway (WAF_v2) using Terraform and I've encountered an issue. Every time I try to update the configuration by adding new blocks like backend_address_pool, http_listener, probe, or request_routing_rule, Terraform insists on completely redeploying the entire Application Gateway. I thought using for_each within the azurerm_application_gateway resource would help, but it didn't fix the issue. This full redeployment leads to long downtimes for my production workloads. I'm looking for solutions or workarounds to modify specific components without triggering a full redeploy. Has anyone found a way to address this issue with Terraform?
5 Answers
It sounds like a frustrating situation! Typically, adding or removing blocks shouldn’t trigger a full redeploy. Can you share a bit of your code? It might help to pinpoint the issue. Just so you know, Terraform treats certain attributes as sets, which can complicate things. When you change one item in the set, it thinks the whole list has changed and tries to remove and add them again, hence the redeploy. Keep an eye on the order of your resources and be mindful of those attributes!
I'd recommend considering a switch to maps instead of lists. Using lists can lead to those kinds of unwanted changes since Terraform manages them differently. Maps generally provide a more stable way to handle dynamic sets of resources.
Definitely hit a wall with these configurations. It's frustrating when the design doesn’t support sub-resources properly. It makes using the Application Gateway a bit of a hassle.
You might be facing a known issue here: [GitHub issue link]. Even though it shouldn't trigger a full redeploy, it can lead to a confusing plan that makes it seem like it will. It's definitely been a headache with the way these resources are currently structured.
Have you tried using the `ignore_changes` argument? This can help avoid resource replacements if certain attributes change unexpectedly. You can specify which attributes to ignore, that way it won't destroy and recreate the resource every time you make a minor adjustment.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically