-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[fixed in 1.42 back in 2.0] azurerm_subnet delegation: If "Actions" is empty Terraform modifies the subnet on each "apply" #5975
Comments
Thanks for opening this issue. Whilst PR #5484 made this field Computed, upon further investigation this field supports specifying values other than the defaults provided by Azure (since these can change over time) and thus we've opted to make this field non-computed so users can specify the values they expect. As such the change to make this field Instead it's possible to remove this diff either by specifying the appropriate values for the Since this should be fixed by updating the Terraform Configuration (either to specify the values for this field, or by using Thanks! |
Thanks for the explanation. While its true that the Azure API allows to configure the actions, the standard behaviour in Azure Portal and CLI when configuring subnet delegations is to assign a default set of actions, in fact I don't see an easy way to modify the actions neither from the Portal nor the CLI. Is it possible to configure azurerm provider to configure the default set of actions in case none is provided like in the Portal/CLI? it will make users life easier. Problem with making use of: lifecycle {
ignore_changes = [
delegation,
]
} It will configure delegations in first subnet deployment but will not remove them if you change the code or re-apply them if someone makes a manual change. |
My approach to mitigate this problem is the following (but it really makes my life more complicated as I have to maintain one more thing in the code). I created a new variable in my network module with all the possible actions mapped to their respective delegations: variable "subnet_delegations_actions" {
type = map(list(string))
default = {
"Microsoft.Web/serverFarms" = ["Microsoft.Network/virtualNetworks/subnets/action"]
"Microsoft.ContainerInstance/containerGroups" = ["Microsoft.Network/virtualNetworks/subnets/action"]
"Microsoft.Netapp/volumes" = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"]
"Microsoft.HardwareSecurityModules/dedicatedHSMs" = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"]
"Microsoft.ServiceFabricMesh/networks" = ["Microsoft.Network/virtualNetworks/subnets/action"]
"Microsoft.Logic/integrationServiceEnvironments" = ["Microsoft.Network/virtualNetworks/subnets/action"]
"Microsoft.Batch/batchAccounts" = ["Microsoft.Network/virtualNetworks/subnets/action"]
"Microsoft.Sql/managedInstances" = ["Microsoft.Network/virtualNetworks/subnets/join/action", "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action", "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"]
"Microsoft.Web/hostingEnvironments" = ["Microsoft.Network/virtualNetworks/subnets/action"]
"Microsoft.BareMetal/CrayServers" = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"]
"Microsoft.Databricks/workspaces" = ["Microsoft.Network/virtualNetworks/subnets/join/action", "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action", "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"]
"Microsoft.BareMetal/AzureVMware" = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"]
"Microsoft.StreamAnalytics/streamingJobs" = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
"Microsoft.DBforPostgreSQL/serversv2" = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
"Microsoft.AzureCosmosDB/clusters" = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
}
} And this is how I make use of it, if a delegation is created then the "actions" are populated with a list with its corresponding actions. dynamic "delegation" {
for_each = contains(keys(var.subnet_delegations), each.key) ? [1] : []
content {
name = "${each.key}-delegation"
service_delegation {
name = var.subnet_delegations[each.key]
actions = var.subnet_delegations_actions[var.subnet_delegations[each.key]]
}
}
} But I'm not very happy having to maintain this variable updated with Azure constant changes.. |
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 👉 [email protected]. Thanks! |
Community Note
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_subnet
Terraform Configuration Files
Expected Behavior
Once the subnet is deployed no more changes should be attempted.
Actual Behavior
Terraform tries to remove the default "actions" each time you apply or plan:
Steps to Reproduce
Create a subnet with delegation and no actions, remember that as per Terraform docs "actions" is optional.
Important Factoids
This bug was happening before azurerm v1.42.0 and was fixed in that version, it came back from the future? original bug report was #5476 fixed in #5484
The text was updated successfully, but these errors were encountered: