Open tony-harverson-moonpig opened 1 year ago
Hi @tony-harverson-moonpig , Thank you for reporting this. Actually, the provider designed it so that the ID of the data source prioritizes user input over API response. Is there specific reasion for using a different cased name instead of the correct one?
Hi @wuxu92. No, we don't have a specific reason for using different capitalisation. We discovered this when an input was mistakenly capitalised differently to the actual subnet id, and we've fixed our issue by correcting the casing of the inputs.
The current behaviour seems confusing for a data source - I think most engineers would expect the data source to return the id as it exists in the api when looking it up. Especially as using the mis-cased id as an input to other resources may cause issues.
@tony-harverson-moonpig thank you for clarifying! As far as I know, the resource ID from Azure API can vary between services and sometimes the API does not return the ID capitalized correctly/expectedly. I believe this is why the provider prefers to use user input to construct the data source ID (There are still some of data sources use the ID returned from API but most of them are not).
Is there an existing issue for this?
Community Note
Terraform Version
1.6.3
AzureRM Provider Version
3.80.0
Affected Resource(s)/Data Source(s)
data "azurerm_subnet"
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Note the capitalisation of the Resource group name and the subnet name id is as returned from the rest api, not based on the capitalisation of the inputs.
Actual Behaviour
The subnet id returned from the data lookup is capitalised based on the input parameters, not the id as returned by the azure api. This has caused us issues when the id is used as an input to resources like application gateway's network configurataion, resulting in a never-settling terraform plan, because the subnet id returned from the azure api is returned with the actual capitalisation of the object id..
Steps to Reproduce
Create a resource group called spike containing a virtual network callled "TestNetwork" containing a subnet called "lowercase".
Terraform plan
Important Factoids
No response
References
No response