You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
terraform plan
azurerm_mssql_server_dns_alias.example: Refreshing state... [id=/subscriptions/REDACTED/resourceGroups/hasan-example/providers/Microsoft.Sql/servers/hasan-example/dnsAliases/example-dns-alias]
╷
│ Error: sql.ServerDNSAliasesClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The requested resource of type 'Microsoft.Sql/servers/dnsAliases' with name 'example-dns-alias' was not found."
│
│ with azurerm_mssql_server_dns_alias.example,
│ on main.tf line 5, in resource "azurerm_mssql_server_dns_alias""example":
│ 5: resource "azurerm_mssql_server_dns_alias""example" {
│
│ sql.ServerDNSAliasesClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned
│ an error. Status=404 Code="ResourceNotFound" Message="The requested resource of type 'Microsoft.Sql/servers/dnsAliases' with name│ 'example-dns-alias' was not found."
╵
Expected Behaviour
terraform plan should notice that resource deleted externally and plan it to be added back.
When you create something in Terraform but delete it manually, Terraform should gracefully handle it. If the API returns an error when the resource doesn't exist, the read function should check to see if the resource is available first. If the resource isn't available, the function should set the ID to an empty string so Terraform "destroys" the resource in state. The following code snippet is an example of how this can be implemented; you do not need to add this to your configuration for this tutorial.
Actual Behaviour
error thrown and requires manual interaction with tfstate file.
Steps to Reproduce
terraform apply with provided manifests above.
Delete alias using azure cli
az sql server dns-alias delete example-dns-alias --resource-group hasan-example --server hasan-example
Run terraform plan
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered:
turkenh
changed the title
azurerm_mssql_server_dns_alias plan fails if resource deleted externally
azurerm_mssql_server_dns_alias plan fails if resource deleted manually
Oct 3, 2022
turkenh
added a commit
to turkenh/terraform-provider-azurerm
that referenced
this issue
Oct 3, 2022
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
v1.2.1
AzureRM Provider Version
3.25.0
Affected Resource(s)/Data Source(s)
azurerm_mssql_server_dns_alias
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
terraform plan should notice that resource deleted externally and plan it to be added back.
https://learn.hashicorp.com/tutorials/terraform/provider-setup#implement-read
Actual Behaviour
error thrown and requires manual interaction with tfstate file.
Steps to Reproduce
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: