Manages the Vulnerability Assessment for a MS SQL Server.
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_mssql_server" "example" {
name = "mysqlserver"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
version = "12.0"
administrator_login = "4dm1n157r470r"
administrator_login_password = "4-v3ry-53cr37-p455w0rd"
}
resource "azurerm_storage_account" "example" {
name = "accteststorageaccount"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "GRS"
}
resource "azurerm_storage_container" "example" {
name = "accteststoragecontainer"
storage_account_name = azurerm_storage_account.example.name
container_access_type = "private"
}
resource "azurerm_mssql_server_security_alert_policy" "example" {
resource_group_name = azurerm_resource_group.example.name
server_name = azurerm_mssql_server.example.name
state = "Enabled"
}
resource "azurerm_mssql_server_vulnerability_assessment" "example" {
server_security_alert_policy_id = azurerm_mssql_server_security_alert_policy.example.id
storage_container_path = "${azurerm_storage_account.example.primary_blob_endpoint}${azurerm_storage_container.example.name}/"
storage_account_access_key = azurerm_storage_account.example.primary_access_key
recurring_scans {
enabled = true
email_subscription_admins = true
emails = [
"email@example1.com",
"email@example2.com"
]
}
}
The following arguments are supported:
server_security_alert_policy_id
- (Required) The id of the security alert policy of the MS SQL Server. Changing this forces a new resource to be created.
storage_container_path
- (Required) A blob storage container path to hold the scan results (e.g. https://example.blob.core.windows.net/VaScans/).
storage_account_access_key
- (Optional) Specifies the identifier key of the storage account for vulnerability assessment scan results. If storage_container_sas_key
isn't specified, storage_account_access_key
is required.
storage_container_sas_key
- (Optional) A shared access signature (SAS Key) that has write access to the blob container specified in storage_container_path
parameter. If storage_account_access_key
isn't specified, storage_container_sas_key
is required.recurring_scans
- (Optional) The recurring scans settings. The recurring_scans
block supports fields documented below.The recurring_scans
block supports the following:
enabled
- (Optional) Boolean flag which specifies if recurring scans is enabled or disabled. Defaults to false
.email_subscription_admins
- (Optional) Boolean flag which specifies if the schedule scan notification will be sent to the subscription administrators. Defaults to false
.emails
- (Optional) Specifies an array of email addresses to which the scan notification is sent.In addition to the Arguments listed above - the following Attributes are exported:
id
- The ID of the MS SQL Server Vulnerability Assessment.The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the MSSQL Server Vulnerability Assessment.update
- (Defaults to 30 minutes) Used when updating the MSSQL Server Vulnerability Assessment.read
- (Defaults to 5 minutes) Used when retrieving the MSSQL Server Vulnerability Assessment.delete
- (Defaults to 30 minutes) Used when deleting the MSSQL Server Vulnerability Assessment.MS SQL Server Vulnerability Assessment can be imported using the resource id
, e.g.
terraform import azurerm_mssql_server_vulnerability_assessment.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/acceptanceTestResourceGroup1/providers/Microsoft.Sql/servers/mssqlserver/vulnerabilityAssessments/Default