Skip to content
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

Application Gateway bug on backend_http_settings causes constant updates #16695

Closed
1 task done
evandeworp opened this issue May 6, 2022 · 2 comments · Fixed by #17162
Closed
1 task done

Application Gateway bug on backend_http_settings causes constant updates #16695

evandeworp opened this issue May 6, 2022 · 2 comments · Fixed by #17162

Comments

@evandeworp
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

1.1.9

AzureRM Provider Version

3.5.0

Affected Resource(s)/Data Source(s)

azurerm_application_gateway

Terraform Configuration Files

// Following code is the example from https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_gateway.
// It's unchanged except the single line "request_timeout       = 60" is commented out

// Configure the Azure provider
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "= 3.5.0"
    }
  }

  required_version = "= 1.1.9"
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "Central US"
}

resource "azurerm_virtual_network" "example" {
  name                = "example-network"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  address_space       = ["10.254.0.0/16"]
}

resource "azurerm_subnet" "frontend" {
  name                 = "frontend"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.254.0.0/24"]
}

resource "azurerm_subnet" "backend" {
  name                 = "backend"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.254.2.0/24"]
}

resource "azurerm_public_ip" "example" {
  name                = "example-pip"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  allocation_method   = "Dynamic"
}

# since these variables are re-used - a locals block makes this more maintainable
locals {
  backend_address_pool_name      = "${azurerm_virtual_network.example.name}-beap"
  frontend_port_name             = "${azurerm_virtual_network.example.name}-feport"
  frontend_ip_configuration_name = "${azurerm_virtual_network.example.name}-feip"
  http_setting_name              = "${azurerm_virtual_network.example.name}-be-htst"
  listener_name                  = "${azurerm_virtual_network.example.name}-httplstn"
  request_routing_rule_name      = "${azurerm_virtual_network.example.name}-rqrt"
  redirect_configuration_name    = "${azurerm_virtual_network.example.name}-rdrcfg"
}

resource "azurerm_application_gateway" "network" {
  name                = "example-appgateway"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location

  sku {
    name     = "Standard_Small"
    tier     = "Standard"
    capacity = 2
  }

  gateway_ip_configuration {
    name      = "my-gateway-ip-configuration"
    subnet_id = azurerm_subnet.frontend.id
  }

  frontend_port {
    name = local.frontend_port_name
    port = 80
  }

  frontend_ip_configuration {
    name                 = local.frontend_ip_configuration_name
    public_ip_address_id = azurerm_public_ip.example.id
  }

  backend_address_pool {
    name = local.backend_address_pool_name
  }

  backend_http_settings {
    name                  = local.http_setting_name
    cookie_based_affinity = "Disabled"
    path                  = "/path1/"
    port                  = 80
    protocol              = "Http"
    //request_timeout       = 60
  }

  http_listener {
    name                           = local.listener_name
    frontend_ip_configuration_name = local.frontend_ip_configuration_name
    frontend_port_name             = local.frontend_port_name
    protocol                       = "Http"
  }

  request_routing_rule {
    name                       = local.request_routing_rule_name
    rule_type                  = "Basic"
    http_listener_name         = local.listener_name
    backend_address_pool_name  = local.backend_address_pool_name
    backend_http_settings_name = local.http_setting_name
  }
}

Debug Output/Panic Output

N/A

Expected Behaviour

  1. According to the documentation https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_gateway, this should happen:
│ Error: Missing required argument
│
│   on bug.tf line 91, in resource "azurerm_application_gateway" "network":
│   91:   backend_http_settings {
│
│ The argument "request_timeout" is required, but no definition was found.
  1. According to https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/network/application_gateway_resource.go, this should happen:
  • Apply the attached terraform and all the resources will create successfully.
  • Immediately rerun the attached terraform and output should be "Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed."

Actual Behaviour

  1. Apply the attached terraform and all the resources create successfully with no error regarding the missing "request_timeout"
  2. Immediately re-apply the attached terraform and Terraform will want to recreate the backend_http_settings even though nothing has changed (except of course azurerm thinks request_timeout needs to be changed).
  3. Repeat the terraform apply and Terraform will want to recreate the backend_http_settings and so on and so on forever.
  # azurerm_application_gateway.network will be updated in-place
  ~ resource "azurerm_application_gateway" "network" {
        id                                = "/subscriptions/676688c8-2d93-4721-9cd0-19072f82bca8/resourceGroups/example-resources/providers/Microsoft.Network/applicationGateways/example-appgateway"
        name                              = "example-appgateway"
        tags                              = {}
        # (7 unchanged attributes hidden)


      - backend_http_settings {
          - cookie_based_affinity               = "Disabled" -> null
          - id                                  = "/subscriptions/676688c8-2d93-4721-9cd0-19072f82bca8/resourceGroups/example-resources/providers/Microsoft.Network/applicationGateways/example-appgateway/backendHttpSettingsCollection/example-network-be-htst" -> null
          - name                                = "example-network-be-htst" -> null
          - path                                = "/path1/" -> null
          - pick_host_name_from_backend_address = false -> null
          - port                                = 80 -> null
          - protocol                            = "Http" -> null
          - request_timeout                     = 30 -> null
          - trusted_root_certificate_names      = [] -> null
        }
      + backend_http_settings {
          + cookie_based_affinity               = "Disabled"
          + id                                  = (known after apply)
          + name                                = "example-network-be-htst"
          + path                                = "/path1/"
          + pick_host_name_from_backend_address = false
          + port                                = 80
          + probe_id                            = (known after apply)
          + protocol                            = "Http"
          + request_timeout                     = 60
          + trusted_root_certificate_names      = []
        }

        # (8 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

terraform apply
terraform apply

Important Factoids

No response

References

No response

@github-actions
Copy link

This functionality has been released in v3.10.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants