terraform-provider-azapi
terraform-provider-azapi copied to clipboard
azapi_update_resource on serverfarms is having issues due to casing
I'm uncertain if this is an AzApi Issue, or actually an AzureRM issue, but starting here, since it's only being thrown at by azapi_update_resource.
Problem
We have the following Terraform entity:
resource "azapi_update_resource" "service_plan_automatic_scaling" {
type = "Microsoft.Web/serverfarms@2022-09-01"
resource_id = azurerm_service_plan.api_gateway.id
body = jsonencode({
properties = {
elasticScaleEnabled = true
maximumElasticWorkerCount = 10
}
})
depends_on = [
azurerm_service_plan.api_gateway,
]
}
Since upgrading to the latest version of AzureRM & AzApi, we are now getting the following error when attempting to do an apply (the rest of the Terraform has gone through okay, it's just this last bit)
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ azapi_update_resource.service_plan_automatic_scaling, provider
│ "provider[\"registry.terraform.io/azure/azapi\"]" produced an unexpected
│ new value: .resource_id: was
│ cty.StringVal("/subscriptions/XXX/resourceGroups/test-apiGateway/providers/Microsoft.Web/serverFarms/test-apiGateway"),
│ but now
│ cty.StringVal("/subscriptions/XXX/resourceGroups/test-apiGateway/providers/Microsoft.Web/serverfarms/test-apiGateway").
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
For emphasis, the difference is between the serverFarms
vs serverfarms
.
It appears that somewhere in the stack, Terraform is expecting the camel case version, but from what I can tell from Azure documentation, serverfarms
never got the camel case treatment, and is in fact still all lower case serverfarms
Official Docs
Versions
Upgraded from AzureRM 3.78.0
to 3.101.0
Upgrade from AzApi 1.9.0
to 1.13.1
Workaround
We have found a work around that seems to work, though it's obviously not ideal, which is to do a replace on the resource_id;
resource "azapi_update_resource" "service_plan_automatic_scaling" {
type = "Microsoft.Web/serverfarms@2022-09-01"
resource_id = replace(azurerm_service_plan.api_gateway.id, "serverFarms", "serverfarms")
body = jsonencode({
properties = {
elasticScaleEnabled = true
maximumElasticWorkerCount = 10
}
})
depends_on = [
azurerm_service_plan.api_gateway,
]
}
the azurerm provider started outputting serverFarms
starting on 3.88
Hi @markd-spektrix , Thank you for taking time to report this issue!
And thanks @calebak404 for the info!
I'll improve the azapi_update_resource
to ignore the casing in the next version. For now, please use the workaround that you mentioned.
Hi @markd-spektrix ,
Hi @loomkoom ,
Thank you for taking time to report this issue, this feature has been released in the azapi v1.14.0.
I'll close this issue as it's completed, but feel free to reopen it if there's any question.