terraform-provider-azurerm: azurerm_sql_database.webdb: Error setting database threat detection policy
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Hello, When i try to apply threat_detection_policy on sql-azure database, i reach an issue.
Terraform Version
terraform -v
Terraform v0.11.7
+ provider.azurerm v1.15.0
Affected Resource(s)
- azurerm_sql_database
Terraform Configuration Files
resource "azurerm_sql_database" "webdb" {
name = "sql-${random_id.sqlnameId.hex}-web-db"
resource_group_name = "${azurerm_resource_group.mainRG.name}"
location = "${azurerm_resource_group.mainRG.location}"
server_name = "${azurerm_sql_server.srv_sql.name}"
edition = "Standard"
threat_detection_policy {
state = "Enabled"
}
}
Debug Output
azurerm_sql_database.webdb: Error setting database threat detection policy: sql.DatabaseThreatDetectionPoliciesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 – Original Error: json: cannot unmarshal array into Go struct field serviceError2.details of type map[string]interface {}
Steps to Reproduce
terraform apply
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 18
- Comments: 15 (1 by maintainers)
Hello everyone.
While building an Azure SQL Module I stumbled upon the same errors this issue details. But for one thing, even when populating my email_addresses variable with a list, I still encounter the issue.
Config: Terraform v0.12.2
variable “email_addresses” { description = “A list of email addresses which alerts should be sent to.” type = list(any) }
resource “azurerm_sql_database” “sql” { …
}
system.auto.tfvars email_addresses = [“asdf@asdf.com”,]
error: Error: Error setting database threat detection policy: sql.DatabaseThreatDetectionPoliciesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 – Original Error: json: cannot unmarshal array into Go struct field serviceError2.details of type map[string]interface {}
Like @chfrodin, I am also running into this same error still. Any updates on this??
Hello dude,
I solved it, with this version and with this code :
Tell me if it’s works for you.
I also have this issue on the following versions: Terraform v0.11.10
Thanks for the info.
After some testing, I found that the field giving errors is
email_addresses. Lack of this field throws an error. There’s no way to implement Threat Detection Policy without this field being filled. However, documentation states that it’s optional.Either documentation should be changed, or some fix is needed.
As a byproduct of this issue, there should also be a fix for error management for this setting. Main problem we had is that the error is not being thrown correctly. There’s no descriptive error message because there’s an unmarshal error with
sql.DatabaseThreatDetectionPoliciesClient#CreateOrUpdate.