Azure Security Center Automation

This page shows how to write Terraform and Azure Resource Manager for Security Center Automation and write them securely.

azurerm_security_center_automation (Terraform)

The Automation in Security Center can be configured in Terraform with the resource name azurerm_security_center_automation. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L30
 *     }
 *     actions = {
 *       a1 = {
 *         type              = "EventHub"
 *         resource_id       = xx
 *         connection_string = xx
main.tf#L27
resource "azurerm_security_center_automation" "sec_cen_automation" {
  count                               = var.sec_cen_setting_enabled ? 1 : 0
  name                                = var.sec_cen_auto_name
  location                            = azurerm_resource_group.rg.location
  resource_group_name                 = azurerm_resource_group.rg.name
  scopes                              = [data.azurerm_subscription.current_sub.id]

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages Security Center Automation and Continuous Export. This resource supports three types of destination in the action, Logic Apps, Log Analytics and Event Hubs

Tips: Best Practices for The Other Azure Security Center Resources

In addition to the azurerm_security_center_contact, Azure Security Center has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_security_center_contact

Ensure to enable alert notifications

It is better to configure at least one valid contact for the security center. Microsoft will inform you directly in the event of a security incident using emails.

risk-label

azurerm_security_center_subscription_pricing

Ensure to enable alert notifications

It is better to enable Azure Defender, which is a cloud workload protection service for App Services. In addition, It is also able to analyze non-Azure resources, utilizing Azure Arc, including those on-premises and in both AWS and GCP.

Review your Azure Security Center settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Security/automations (Azure Resource Manager)

The automations in Microsoft.Security can be configured in Azure Resource Manager with the resource name Microsoft.Security/automations. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

ExportToLogAnalyticsWorkspaceAuditPolicy.json#L11
        "type": "Microsoft.Security/automations",
        "existenceCondition": {
          "allOf": [
            {
              "field": "name",
              "equals": "ExportToWorkspace"
ExportToEventHubAuditPolicy.json#L11
        "type": "Microsoft.Security/automations",
        "existenceCondition": {
          "allOf": [
            {
              "field": "name",
              "equals": "exportToEventHub"
WorkflowAutomationAlertsAuditPolicy.json#L11
        "type": "Microsoft.Security/automations",
        "existenceCondition": {
          "allOf": [
            {
              "field": "name",
              "notIn": [
WorkflowAutomationRecommendationsAuditPolicy.json#L11
        "type": "Microsoft.Security/automations",
        "existenceCondition": {
          "allOf": [
            {
              "field": "name",
              "notIn": [
Microsoft.Authorization_policyDefinitions-Deploy-ASC-CE.parameters.json#L97
                "type": "Microsoft.Security/automations",
                "name": "ExportToWorkspace",
                "existenceScope": "resourcegroup",
                "ResourceGroupName": "[concat(subscription().displayName, '-asc')]",
                "deploymentScope": "subscription",
                "roleDefinitionIds": [
LZ-ASC-Continous-Export.json#L22
            "type": "Microsoft.Security/automations",
            "apiVersion": "2019-01-01-preview",
            "name": "exportToWorkspace2",
            "location": "[parameters('workspaceRegion')]",
            "dependsOn": [],
            "properties": {
GetAutomationsSubscription_example.json#L13
            "type": "Microsoft.Security/automations",
            "etag": "etag value",
            "location": "Central US",
            "tags": {},
            "properties": {
              "description": "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment of type customAssessment",
Microsoft.Authorization_policyDefinitions-Deploy-ASC-CE.parameters.json#L97
                "type": "Microsoft.Security/automations",
                "name": "ExportToWorkspace",
                "existenceScope": "resourcegroup",
                "ResourceGroupName": "[concat(subscription().displayName, '-asc')]",
                "deploymentScope": "subscription",
                "roleDefinitionIds": [
azuredeploy.json#L48
      "type": "Microsoft.Security/automations",
      "properties": {
        "description": "[format(variables('automationDescription'),'{0}', parameters('subscriptionId'))]",
        "isEnabled": true,
        "actions": [
          {
azuredeploy.json#L48
      "type": "Microsoft.Security/automations",
      "properties": {
        "description": "[format(variables('automationDescription'),'{0}', parameters('subscriptionId'))]",
        "isEnabled": true,
        "actions": [
          {

Frequently asked questions

What is Azure Security Center Automation?

Azure Security Center Automation is a resource for Security Center of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Security Center Automation?

For Terraform, the hassepaul/tgtest and murali198/azure-terraform source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the nkcodegit/Azure-Security-Center, nkcodegit/Azure-Security-Center and nkcodegit/Azure-Security-Center source code examples are useful. See the Azure Resource Manager Example section for further details.