Support for separate frontend_port, backend_address_pool, etc. resources in azurerm_application_gateway #15745
Labels
duplicate
service/application-gateway
upstream/microsoft
Indicates that there's an upstream issue blocking this issue/PR
Community Note
Description
Currently, the
azurerm_application_gateway
resource has multiple blocks of configuration inside of it; for example, abackend_address_pool
. These can be created dynamically as one would expect using thedynamic
syntax, but this is difficult. The end result of this is that the attributes that are exported by the resource for those configuration items are almost all lists/arrays, and accessing information inside of them uses the highly brittle (and incredibly difficult to address meaningfully) array notation, e.g.,backend_address_pool[0]
.Examining the actual resources Azure's resource explorer, we can see that within an Application Gateway resource each of these blocks actually has not only a unique resource ID (meaning we "should" be able to create an associated Terraform resource), but also a unique type; for example, a
backend_address_pool
looks like this:The reason this would be highly beneficial is because when developing a module, it is extremely difficult to create sufficient abstraction between the "bare" Terraform config required for this and a more desirable one in a way that is not brittle (see comment above about only being able to reference these dynamic blocks by array notation).
I have focused on the
backend_address_pool
configuration block, though this could be for most of the configuration blocks in theazurerm_application_gateway
resource. Forbackend_address_pool
specifically, we do haveazurerm_network_interface_application_gateway_backend_address_pool_association
, but this requires passing in abackend_address_pool
ID, which as mentioned cannot be retrieved without knowing its position in the array. For complex configurations, this is difficult, if not impossible. Not to mention thatazurerm_network_interface_application_gateway_backend_address_pool_association
uses a weird, Terraform-only ID (e.g.,{networkInterfaceId}/ipConfigurations/{ipConfigurationName}|{backendAddressPoolId}
) which is probably unnecessary given that there are actual IDs available for these resources from the API.This sort of pattern exists in other
azurerm
resources; for example,azurerm_network_security_group
has support for inlinesecurity_rule
blocks, but alsoazurerm_network_security_rule
resources exist which functionally do the same thing but are far easier to code modules for since they will get an actual ID that is easy to reference, especially when created dynamically with afor_each
.ALTERNATIVELY, having these blocks at least export more than just their IDs would be useful (e.g., in
request_routing_rule
we needbackend_address_pool_name
, but thebackend_address_pool
attribute does not export aname
attribute. OR, changing the various*_name
's in the blocks to*_id
's, or supporting both.New or Affected Resource(s)
azurerm_application_gateway
azurerm_application_gateway_frontend_port
(new)azurerm_application_gateway_backend_address_pool
(new)azurerm_application_gateway_gateway_ip_configuration
(new)azurerm_application_gateway_frontend_ip_configuration
(new)azurerm_application_gateway_backend_http_settings
(new)azurerm_application_gateway_http_listener
(new)azurerm_application_gateway_request_routing_rule
(new)Potential Terraform Configuration
References
The API documentation would suggest this is possible: https://docs.microsoft.com/en-us/rest/api/application-gateway/application-gateways
The text was updated successfully, but these errors were encountered: