hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

azurerm_application_gateway rewrite_ruleset not working as expected #27182

Open vamshisiram opened 2 months ago

vamshisiram commented 2 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.9.3

AzureRM Provider Version

3.116.0

Affected Resource(s)/Data Source(s)

azurerm_application_gateway

Terraform Configuration Files

dynamic "rewrite_rule_set" {
    for_each = var.backend_address_pools

    content {
      name = rewrite_rule_set.value.rewrite_rule_set

      rewrite_rule {
        count  = 
        name = rewrite_rule_set.value.rewrite_rule_name
        rule_sequence = rewrite_rule_set.value.rewrite_rule_sequence
        condition {
          pattern = rewrite_rule_set.value.rewrite_rule_pattern
          variable = rewrite_rule_set.value.rewrite_rule_variable
        }
      }
    }

Debug Output/Panic Output

Not able to create code itself.

Unexpected attribute: An attribute named "for_each" is not expected here

Unexpected attribute: An attribute named "count" is not expected here

Expected Behaviour

No response

Actual Behaviour

In azure portal, I create a rewrite set with a rewrite rule under the rule set. Here is a snippet of how it looks in Azure Portal.

image

We use Terraform modules to deploy Azure Application Gateway. Now, I want to include the creation of rewrite rule set with rewrite rules in the same module. Here is sample code i have for creating a single rule set with single rule,

image

but it is complaining when i add for_each or count in the rewrite_rule block, that it is not supported in the module code for writing multiple rules in the same rule_set.

image

And i want the ability to create multiple rule sets with multiple rules in each rule set for each backend pool in the Gateway. Looks like this is not possible when using dynamic. Any thoughts on how to accomplish this?

Steps to Reproduce

attempt to create the code, that's it

Important Factoids

No response

References

No response

teowa commented 2 months ago

Hi @vamshisiram , this should be a question of HCL language usage. GitHub issues in this repository are only intended for bug reports and feature requests. Please ask and answer questions through the Terraform Azure Provider Community Forum. count can only be used under resource level. for this case, you should use nesting dynamic. Thanks.