Open lhaatveit opened 4 years ago
I'm having the same issue. The error shows up when the resource needs to be recreated due to a change that can't be done in-place. In my case, I'm seeing the same problem with PostgreSQL:
Error: retrieving PostgreSQL Server "*******" (Resource Group "*******"): postgresql.ServersClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code
="ResourceNotFound" Message="The Resource 'Microsoft.DBforPostgreSQL/servers/*******' under resource group '*******' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
Although the error, the resource is still created, but all the resources depending on it aren't (like for example a private endpoint in my case). After import
the resource and re-execution of terraform apply
, it completes without problems.
Any updates on this? We do have the same error with Terraform 1.7.4, azurerm 3.92.0.
I am seeing this issue 3.83.0 and 3.96.0 of the provider so it is far from a legacy issue.
We do not use taint to recreate as it is deprecated, instead we use the Terraform CLI with the -replace argument. The database does indeed get deleted but terraform seems to time out waiting for the resource to recreate and reports a 404 error within the next 2 minutes of waiting for the resource to be created. The database successfully creates after another 30 seconds of waiting.
So the command that we use works for all the other resources we have tested but not the database. It looks like this:
terraform apply -replace="module.myModule[\"myIndex\"].azurerm_mssql_database.mydb" --auto-approve
The most relevant part of the error message is this:
Database Name: "myDatabaseName"): unexpected status 404 with error: ResourceNotFound: The Resource 'Microsoft.Sql/servers/serverName/databases/myDatabaseName' under resource group 'ResourceGroupName' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
It is worth noting that the resource supports custom timeouts which are not honoured and the default timeouts are very high already.
Community Note
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_mssql_server
Terraform Configuration Files
Debug Output
https://gist.github.com/lhaatveit/3bac422cdd7e311d006281c5b1454714
Expected Behavior
The database should successfully be destroy and re-created.
Actual Behavior
The database is destroyed and recreated, but Terraform fails with the following error:
Steps to Reproduce
terraform apply
terraform taint azurerm_mssql_database.test
terraform apply
Important Factoids
The same issue also appears intermittently when using a database with a dedicated SKU, but it appears consistently when the database belongs to an elastic pool.