hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.65k forks source link

Support for azure sql database audit policy #5929

Closed lotaezhao closed 4 years ago

lotaezhao commented 4 years ago

Community Note

Description

There is currently no support to configure azure sql database audit-policy settings in Terraform. Please can this added as it's a pretty standard requirement within enterprises to need auditing switched on. Sql databases are one of of the most fundamental resources so we should have full feature support. This can be enabled both on individual databases and at the server level. I'm talking about the database level but might as well add support for sql server level as well.

New or Affected Resource(s)

azurerm_sql_database azurerm_sql_server

Potential Terraform Configuration

Basing this off of the 'az sql db audit-policy update' command, proposed configuration could be a new 'audit_policy' block with the following attributes.

resource "azurerm_sql_database" "example" {
  name                = "mysqldatabase"
  resource_group_name = azurerm_resource_group.example.name
  location            = "West US"
  server_name         = azurerm_sql_server.example.name

  audit_policy {
    actions                        = example_actions
    retention_days                 = 30
    state                          = enabled
    storage_account                = example_storage_account
    storage_endpoint               = example_storage endpoint
    storage_key                    = example_storage_key
    log_analytics_workspace_id     = example_log_analytics_workspace_id
    eventhub_authorization_rule_id = example_authorization_rule_id
  }

  tags = {
    environment = "production"
  }
}

References

This is the same configuration as provided by the Az Cli command 'az sql db audit-policy update' which is what I currently have to use in order to configure this setting: https://docs.microsoft.com/en-us/cli/azure/sql/db/audit-policy?view=azure-cli-latest

rohrerb commented 4 years ago

@katbyte any chance this could be done on the SQL level as well and if possible broke out to its own resource?

yupwei68 commented 4 years ago

Hi @lotaezhao ,thanks for opening this issue. Blob Auditing Policies are supported now on azurerm_sql_database and azurerm_sql_server. Hi @katbyte we may be able to close this issue.

tombuildsstuff commented 4 years ago

Appears the documentation is missing for the extended_auditing_policy block; so this wants fixing prior to closing this https://www.terraform.io/docs/providers/azurerm/r/sql_database.html

ghost commented 4 years ago

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!