-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_network_interface_application_gateway_backend_address_pool_association backend_address_pool addressable key #16855
Comments
This comment was marked as duplicate.
This comment was marked as duplicate.
Managed to bypass this issue by below 'hack' that is exploiting the fact that backend_address_pool id (as many other azure resources) is constructed/consists backend's pool name: resource "azurerm_network_interface_application_gateway_backend_address_pool_association" "example" {
network_interface_id = azurerm_network_interface.example.id
ip_configuration_name = "testconfiguration1"
backend_address_pool_id = [for value in tolist(azurerm_application_gateway.network.backend_address_pool.*.id) : value if length(regexall(lower(local.backend_address_pool_name), value)) > 0][0]
} Above code uses conditional for expression that iterates through list of backend_addres_pool id's (created with usage of splat operator) and assigns value of the only element that contains backend_addres_pool_name (used Not ideal, not clean, but working for me... |
Same here. The solution above works but it takes a long time to create. @Loth4r do you have the same problem? |
No such issue on my end. |
Replicated the |
In 3.11.0 they updated the documentation as stated below:
|
Above will most likely work, but in scenario where you have only one backend_address_pool defined on your app gateway. If you have more then in my opinion it can lead to some random results as tolist() function on a set does not guarantee order:
see (https://www.terraform.io/language/functions/tolist) What could improve setting up backend_addres_pool association here would be reconsidering how azurerm_application_gateway component should be exporting backend_address_pool block. Currently it is exporting list of backend_address_pool as follows:
Maybe changing type to map that has a name of backend address pool as a key would do the trick? Then it could look more like below:
|
Neither solutions is working for me:
However, it works if I use:
|
We ran into the ordering issue with tolist(). In order to get around it we created a local variable. backend_nics was the output of the VM NICs we wanted in or backend pool.
Then in the terraform we did this.
There may be a better way, but this worked for us. |
encountered this too. this workaround suggested above worked. tolist(azurerm_application_gateway.network.backend_address_pool).0.id |
You can use one function from terraform as below: resource "azurerm_network_interface_application_gateway_backend_address_pool_association" "nic-assoc" { |
@devanshujoshi139 that only works if there's a single backend address pool. As soon as there are more, that will fail. @GeoffCraigVRU it's probably relevant that the backend address pool ID's are easy to predict. In my case, it was a lot easier to just do this: resource "azurerm_network_interface_application_gateway_backend_address_pool_association" "nic1" {
backend_address_pool_id = "${azurerm_application_gateway.this.id}/backendAddressPools/bapName"
ip_configuration_name = "ipConfigName"
network_interface_id = azurerm_network_interface.vm1nic1.id
} Ideally, even though the Azure API returns the data in an unordered list (which is why the |
Is there an existing issue for this?
Community Note
Terraform Version
1.1.9
AzureRM Provider Version
3.6.0
Affected Resource(s)/Data Source(s)
azurerm_network_interface_application_gateway_backend_address_pool_association
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Application Gateway backend pool association should be made with the virtual machine nic.
Actual Behaviour
States that backend_address_pool does not have addressable keys.
Steps to Reproduce
Terraform plan
Important Factoids
This worked as expected in Azure Provider 2.99.0
References
https://github.com/MicrosoftDocs/azure-dev-docs/issues/770
https://github.com/MicrosoftDocs/azure-dev-docs/issues/752
The text was updated successfully, but these errors were encountered: