Hello Friends, please, I would like to ask if a situation like mine has already happened.
In the context of Azure Application Gateway, I need my Dynamic tile to access a list within an object that is within that object there is another list of objects. It sounds complex, but, for example, it would be in the case of a single call creating multiple “backend_http_settings” within a Backend_Address_Pool.
Terraform Version
Terraform v0.12.24
+ provider.azurerm v1.44.0
+ provider.template v2.1.2
Terraform Configuration Files
provider "azurerm" {
version = "1.44"
{...}
terraform {
required_version = ">= 0.12"
{...}
}
Steps to Reproduce
terraform init
terraform -target="module.indices_app_gateway"
My Variable:
variable "backend_virtualmachines" {
default = []
}
My consumption of the variable:
module "my_application_gateway" {
...
...
backend_virtualmachines = [
{
#Backend Pool
backend_name = "<name backend address pool>"
ip_addresses = [module.virtual_machines.load_balance_public_ip.0.ip_address]
#HTTP Settings
appg_http_settings = [
{
name_http_settings = "<name_http_settings>"
port = 80
protocol = "Http"
cookie_based_affinity = "Disabled"
hostname = "<hostname>"
request_timeout = 20
probe_name = ""
trusted_root_certificate_names = [""]
},
{
name_http_settings = "<name_https_settings>"
port = 443
protocol = "Http"
cookie_based_affinity = "Disabled"
hostname = "<hostname>"
request_timeout = 20
probe_name = ""
trusted_root_certificate_names = ["<trusted_certificate>"]
},
]
...
...
My code.tf
resource "azurerm_application_gateway" "application_gateway" {
...
...
# HTTP Settings
dynamic "backend_http_settings" {
for_each = length(var.backend_virtualmachines) == 0 ? [] : [for c in var.backend_virtualmachines : {
for_each = [for xc in c.appg_http_settings : {
name = xc.name_http_settings
port = xc.port
protocol = xc.protocol
cookie_based_affinity = xc.cookie_based_affinity
host_name = xc.hostname
request_timeout = xc.request_timeout
probe_name = xc.probe_name
trusted_root_certificate_names = xc.trusted_root_certificate_names
}]
}]
content {
name = backend_http_settings.value.name
port = backend_http_settings.value.port
protocol = backend_http_settings.value.protocol
cookie_based_affinity = backend_http_settings.value.cookie_based_affinity
host_name = backend_http_settings.value.host_name
affinity_cookie_name = "ApplicationGatewayAffinity"
request_timeout = backend_http_settings.value.request_timeout
probe_name = backend_http_settings.value.probe_name
trusted_root_certificate_names = backend_http_settings.value.trusted_root_certificate_names
}
...
...
Terraform Crash
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.
When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.
SECURITY WARNING: the "crash.log" file that was created may contain
sensitive information that must be redacted before it is safe to share
on the issue tracker.
[1]: https://github.com/hashicorp/terraform/issues
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Other Code
My other code2.tf
resource "azurerm_application_gateway" "application_gateway" {
...
...
# HTTP Settings
dynamic "backend_http_settings" {
for_each = length(var.backend_virtualmachines) == 0 ? [] : [for c in var.backend_virtualmachines : {
name = c.appg_http_settings.name_http_settings
port = c.appg_http_settings.port
protocol = c.appg_http_settings.protocol
cookie_based_affinity = c.appg_http_settings.cookie_based_affinity
host_name = c.appg_http_settings.hostname
request_timeout = c.appg_http_settings.request_timeout
probe_name = c.appg_http_settings.probe_name
trusted_root_certificate_names = c.appg_http_settings.trusted_root_certificate_names
}]
content {
name = backend_http_settings.value.name
port = backend_http_settings.value.port
protocol = backend_http_settings.value.protocol
cookie_based_affinity = backend_http_settings.value.cookie_based_affinity
host_name = backend_http_settings.value.host_name
affinity_cookie_name = "ApplicationGatewayAffinity"
request_timeout = backend_http_settings.value.request_timeout
probe_name = backend_http_settings.value.probe_name
trusted_root_certificate_names = backend_http_settings.value.trusted_root_certificate_names
}
...
...
Terraform Error (in code2.tf)
Error: Unsupported attribute
on ..\..\..\modules\application_gateway\code2.tf line 101, in resource "azurerm_application_gateway" "application_gateway":
101: name = c.appg_http_settings.name_http_settings
This object does not have an attribute named "appg_http_settings".
This value does not have any attributes.