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

Subnet Ids starting with '/' cause resources to always be updated #25832

Closed
1 task done
CampionFabio opened this issue May 2, 2024 · 1 comment · Fixed by #25885
Closed
1 task done

Subnet Ids starting with '/' cause resources to always be updated #25832

CampionFabio opened this issue May 2, 2024 · 1 comment · Fixed by #25885

Comments

@CampionFabio
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 and review the contribution guide to help.

Terraform Version

1.8.2

AzureRM Provider Version

3.101.0

Affected Resource(s)/Data Source(s)

azurerm_linux_web_app

Terraform Configuration Files

resource "azurerm_virtual_network" "theVnet" {
  name                = "theVnet"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  address_space       = "10.0.0.0/16"
  lifecycle {
    ignore_changes = [tags]
  }
}

resource "azurerm_subnet" "theSubNet" {
  name                 = "theSubNet"
  resource_group_name  = azurerm_resource_group.rg.name
  virtual_network_name = azurerm_virtual_network.theVnet.name
  address_prefixes     = "10.0.0.0/24"
  service_endpoints = [
    "Microsoft.Web",
    "Microsoft.Sql",
    "Microsoft.AzureCosmosDB"
  ]

  delegation {
    name = "Microsoft.Web.serverFarm"
    service_delegation {
      actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
      name    = "Microsoft.Web/serverFarms"
    }
  }
}


resource "azurerm_linux_web_app" "myWebApp" {
  name                = "myWebApp"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  service_plan_id     = azurerm_service_plan.aPlan.id
  https_only          = false

  client_affinity_enabled = true
    application_stack {
      dotnet_version = "6.0"
    }
    minimum_tls_version = "1.2"
  }

  virtual_network_subnet_id = azurerm_subnet.theSubNet.id
  lifecycle {
    ignore_changes = [
      tags,
      logs
    ]
  }
}

Debug Output/Panic Output

# azurerm_linux_web_app.myWebApp will be updated in-place
  ~ resource "azurerm_linux_web_app" "myWebApp" {
        id                                             = "/subscriptions/<subsId>/resourceGroups/<rgName>/providers/Microsoft.Web/sites/myWebApp"
        name                                           = "myWebApp"
      ~ virtual_network_subnet_id                      = "/subscriptions/<subsId>/resourceGroups/<rgName>/providers/Microsoft.Network/virtualNetworks/<vnetNAme>/subnets/<subVnetName>" -> "subscriptions/<subsId>/resourceGroups/<rgName>/providers/Microsoft.Network/virtualNetworks/<vnetNAme>/subnets/<subVnetName>"

Expected Behaviour

There should not be an update

Actual Behaviour

it seems that because of the "/" in front of the subnet Id the resource "azurerm_linux_web_app.myWebApp" is always updated

Steps to Reproduce

run terraform apply

Important Factoids

No response

References

No response

tombuildsstuff added a commit that referenced this issue May 7, 2024
…bnet_id`

This fixes #25832 by ensuring that the Subnet ID is recased
meaning that it'll be in the correct format.

From our side since we're validating the user input for this field, it's hard for us to write a test-case for this one since
it'd be caught by the validation - but this is caused by user input for this field (provisioned through an ARM Template etc)
providing this value without the prefix '/', which the API should be requiring (but isn't).
@rcskosir rcskosir added the bug label May 9, 2024
@rcskosir
Copy link
Contributor

Thank you for taking the time to open this issue. Please subscribe to PR #25885 created for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants