Closed ivanthelad closed 7 months ago
Hi @ivanthelad thanks for opening this. I would like to clarify that Terraform provider implements CRUD for Azure resources by calling the Azure Rest API. According to the description of useFromLocation
in the latest API , it's value should be either 'default' or valid Azure region identifier. Also, when default
is configured, the API returns success and can be displayed normally on the Azure Portal.
For the above reasons, I recommend opening an issue on the Azure Rest API repo to confirm whether this is an API documentation issue.
In addition, if you could provide public documentation or fully explain that its value must be Default
, it would be of great help to us in solving this issue.
Thanks for taking the time to open this issue. It looks like the behavior you requested is not supported by the underlying Azure API so I am going to label this issue as such and close it for now. If you create a request on Azure/azure-rest-api-specs, feel free to add the link here. When it gets added, we can reopen this request or you can create a new one.
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.
Is there an existing issue for this?
Community Note
Terraform Version
1.5.7
AzureRM Provider Version
3.77.0
Affected Resource(s)/Data Source(s)
azurerm_api_management_redis_cache
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
That cache_location with value 'Default' should be considered case sensitive. azurerm_api_management_redis_cache should not accept 'default' as a value.
Actual Behaviour
That cache_location with value 'Default' value fails comparison check against "default" and is instead passed to be validated as a real region. This will result in failure and forces users to configure 'default' instead. when 'default' is used APIM cannot reference it
this line should be changed https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/apimanagement/validate/redis_cache_location.go#L19
instead its passed to this line which continues the validation against the RP's available locations https://github.com/hashicorp/terraform-provider-azurerm/blob/597c2219cdbd16d28e0473c560d6ba8b494e3898/internal/services/apimanagement/validate/redis_cache_location.go#L23
The consequence of this behaviour the terraform provider, using the ARM API creates an External cache entry named with cacheLocation called 'default'. APIM relies on the name "Default" and results in the the cache not been found by the local gateway. The current implementation basically means you cannot provision a default cache via terraform and always need create a cach named "Default" via the ARM API
note: The ARM apim should be more strict regarding its validation so it does not accept any string as a name. it should be Default or a valid region
Steps to Reproduce
terraform plan against the above code snippet
Important Factoids
No response
References
to fix this the following line https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/apimanagement/validate/redis_cache_location.go#L19 should be changed to
`package validate
import ( "fmt" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "strings" )
func RedisCacheLocation(input interface{}, key string) (warnings []string, errors []error) { v, ok := input.(string) if !ok { errors = append(errors, fmt.Errorf("expected %q to be a string", key)) return }
if v == "Default" { return warnings, errors }
return location.EnhancedValidate(v, key) } `
Additionally, the original issue was https://github.com/hashicorp/terraform-provider-azurerm/issues/23675
This issue allowed fix basically allows user to provision a default cache regardless if its Default or default and always provisions.a cache location called 'default'. after further tests, the TF provider should perform a strict comparison on "Default"