azurerm_linux_function_app zip deploy failures do not result in a tainted resource #24517
Closed
1 task done
Labels
Milestone
Is there an existing issue for this?
Community Note
Terraform Version
1.5.7
AzureRM Provider Version
3.86.0
Affected Resource(s)/Data Source(s)
azurerm_linux_function_app
Terraform Configuration Files
Use the
azurerm_linux_function_app
resource with thezip_deploy_file
argument and remote build settings:Debug Output/Panic Output
When a value for
zip_deploy_file
is provided and the zip deploy fails (in our case, due to transient Azure network issues described below), theazurerm_linux_function_app
resource does not get tainted, and fails to create, according theterraform apply
output. Some examples of transient errors we've seen from Azure during zip deployments:and
terraform apply
fails as a result of the above errors, however the function app is still created on Azure. This means that the resource exists in Azure and is not being tracked by terraform state. Subsequentterraform apply
runs then fail with:Expected Behaviour
When a zip_deploy_file is provided and the zip deploy fails, terraform-provider-azurerm should taint the
azurerm_linux_function_app
resource, since Azure still creates the function app. Tainting the resource ensures that theazurerm_linux_function_app
resource is properly tracked in terraform state, and is marked for destruction and re-creation on the nextterraform apply
run.Actual Behaviour
When the
zip_deploy_file
argument is used withazurerm_linux_function_app
and the zip deployment fails, the creation of azurerm_linux_function_app is considered failed during aterraform apply
and the resource is not tracked in terraform state. However, the function app has been created in Azure, even though the zip deploy failed. Subsequentterraform apply
runs fail due to the resource already existing.The broken function app must then be manually deleted outside of Terraform to resolve the "resource already exists" issue.
Steps to Reproduce
azurerm_linux_function_app
resource and provide a deployment zip file,zip_file_deploy
terraform apply
terraform apply
has failed, Azure has still created the function appterraform apply
again and see that the created azurerm_linux_function_app is not being tracked by terraform state, hit a "resource already exists" errorImportant Factoids
Workaround: Use a provisioner local-exec command to run a zip deployment, since creation-time provisioners mark resources as tainted upon failure
References
No response
The text was updated successfully, but these errors were encountered: