Closed 0x7f closed 4 years ago
There is another workaround, add this to the subnet:
lifecycle {
ignore_changes = ["route_table_id"]
}
👋
To give an update here, the association between a Subnet and a Route Table in the Azure Provider is moving from the azurerm_subnet
resource to the azurerm_subnet_route_table_association
resource - to not break compatibility both fields can currently be used for this purpose, however in the upcoming version 2.0 of the Azure Provider the route_table_id
field will be dropped from the azurerm_subnet
resource. As such this'll be fixed by 2.0 and I've added this to that milestone to ensure it's tracked/closed out as needed - but for the moment it should be possible to work around this using the ignore_changes
suggestion mentioned by @WebSpider above.
Thanks!
This has been released in version 2.0.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:
provider "azurerm" {
version = "~> 2.0.0"
}
# ... other configuration ...
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!
Community Note
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_kubernetes_cluster
azurerm_virtual_network
azurerm_route_table
Terraform Configuration Files
Debug Output
https://gist.github.com/0x7f/2775e85bb6e07d9dece4644919d3f1e6
Expected Behavior
Since release 2019-06-18, when creating an AKS cluster and providing a custom subnet (with no route table assigned), the auto-generated route table will be assigned to the provided subnet. When running
terraform apply
(or plan) again, the route table is not disassociated from the subnet and the cluster's internal network keeps working.Actual Behavior
On first run of
terraform apply
, the AKS cluster is created and its route table is automatically assigned to the provided subnet (which is also managed by terraform). But when runningterraform apply
again, the route table is planned to be removed from the subnet.I totally understand why it is removed. There is no route table configured in the subnet. But I also can not reference AKS' route table in the subnet, because it would create a cyclic dependency (apart from the fact that the AKS resource is not exporting the route table id).
Right now there are only two options to get around this:
provisioner "local-exec"
to theazurerm_kubernetes_cluster
resource which exports the subnet details via azure cli so you can use it in other places (e.g. configure PostgreSQL firewall). This has drawbacks as well and is hacky.Both options are not ideal. Right now, we are going with the first one. I'd like to have expected behavior though. Do you see a way how the subnet can keep the auto-assigned route table?
Steps to Reproduce
Use tf file posted above and then run
terraform apply
twice.Important Factoids
Nothing particular.
References
Did search for existing/related issues and PRs, but did not find any.