Skip to content

azurermMonitorActionGroup

Manages an Action Group within Azure Monitor.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "monitoring-resources",
  }
);
const dataAzurermClientConfigCurrent =
  new azurerm.dataAzurermClientConfig.DataAzurermClientConfig(
    this,
    "current",
    {}
  );
const azurermLogAnalyticsWorkspaceExample =
  new azurerm.logAnalyticsWorkspace.LogAnalyticsWorkspace(this, "example_2", {
    location: azurermResourceGroupExample.location,
    name: "workspace-01",
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLogAnalyticsWorkspaceExample.overrideLogicalId("example");
const azurermMonitorActionGroupExample =
  new azurerm.monitorActionGroup.MonitorActionGroup(this, "example_3", {
    arm_role_receiver: [
      {
        name: "armroleaction",
        role_id: "de139f84-1756-47ae-9be6-808fbbe84772",
        use_common_alert_schema: true,
      },
    ],
    automation_runbook_receiver: [
      {
        automation_account_id:
          "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-runbooks/providers/microsoft.automation/automationaccounts/aaa001",
        is_global_runbook: true,
        name: "action_name_1",
        runbook_name: "my runbook",
        service_uri:
          "https://s13events.azure-automation.net/webhooks?token=randomtoken",
        use_common_alert_schema: true,
        webhook_resource_id:
          "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-runbooks/providers/microsoft.automation/automationaccounts/aaa001/webhooks/webhook_alert",
      },
    ],
    azure_app_push_receiver: [
      {
        email_address: "admin@contoso.com",
        name: "pushtoadmin",
      },
    ],
    azure_function_receiver: [
      {
        function_app_resource_id:
          "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-funcapp/providers/Microsoft.Web/sites/funcapp",
        function_name: "myfunc",
        http_trigger_url: "https://example.com/trigger",
        name: "funcaction",
        use_common_alert_schema: true,
      },
    ],
    email_receiver: [
      {
        email_address: "admin@contoso.com",
        name: "sendtoadmin",
      },
      {
        email_address: "devops@contoso.com",
        name: "sendtodevops",
        use_common_alert_schema: true,
      },
    ],
    event_hub_receiver: [
      {
        event_hub_name: "eventhub1",
        event_hub_namespace: "eventhubnamespace",
        name: "sendtoeventhub",
        subscription_id: "00000000-0000-0000-0000-000000000000",
        use_common_alert_schema: false,
      },
    ],
    itsm_receiver: [
      {
        connection_id: "53de6956-42b4-41ba-be3c-b154cdf17b13",
        name: "createorupdateticket",
        region: "southcentralus",
        ticket_configuration:
          '{"PayloadRevision":0,"WorkItemType":"Incident","UseTemplate":false,"WorkItemData":"{}","CreateOneWIPerCI":false}',
        workspace_id: `\${${dataAzurermClientConfigCurrent.subscriptionId}}|\${${azurermLogAnalyticsWorkspaceExample.workspaceId}}`,
      },
    ],
    logic_app_receiver: [
      {
        callback_url: "https://logicapptriggerurl/...",
        name: "logicappaction",
        resource_id:
          "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-logicapp/providers/Microsoft.Logic/workflows/logicapp",
        use_common_alert_schema: true,
      },
    ],
    name: "CriticalAlertsAction",
    resource_group_name: azurermResourceGroupExample.name,
    short_name: "p0action",
    sms_receiver: [
      {
        country_code: "1",
        name: "oncallmsg",
        phone_number: "1231231234",
      },
    ],
    voice_receiver: [
      {
        country_code: "86",
        name: "remotesupport",
        phone_number: "13888888888",
      },
    ],
    webhook_receiver: [
      {
        name: "callmyapiaswell",
        service_uri: "http://example.com/alert",
        use_common_alert_schema: true,
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMonitorActionGroupExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the Action Group. Changing this forces a new resource to be created.
  • resourceGroupName - (Required) The name of the resource group in which to create the Action Group instance. Changing this forces a new resource to be created.
  • shortName - (Required) The short name of the action group. This will be used in SMS messages.
  • enabled - (Optional) Whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. Defaults to true.
  • armRoleReceiver - (Optional) One or more armRoleReceiver blocks as defined below.
  • automationRunbookReceiver - (Optional) One or more automationRunbookReceiver blocks as defined below.
  • azureAppPushReceiver - (Optional) One or more azureAppPushReceiver blocks as defined below.
  • azureFunctionReceiver - (Optional) One or more azureFunctionReceiver blocks as defined below.
  • emailReceiver - (Optional) One or more emailReceiver blocks as defined below.
  • eventHubReceiver - (Optional) One or more eventHubReceiver blocks as defined below.
  • itsmReceiver - (Optional) One or more itsmReceiver blocks as defined below.
  • location - (Optional) The Azure Region where the Action Group should exist. Changing this forces a new Action Group to be created. Defaults to global.
  • logicAppReceiver - (Optional) One or more logicAppReceiver blocks as defined below.
  • smsReceiver - (Optional) One or more smsReceiver blocks as defined below.
  • voiceReceiver - (Optional) One or more voiceReceiver blocks as defined below.
  • webhookReceiver - (Optional) One or more webhookReceiver blocks as defined below.
  • tags - (Optional) A mapping of tags to assign to the resource.

The armRoleReceiver block supports the following:

  • name - (Required) The name of the ARM role receiver.
  • roleId - (Required) The arm role id.
  • useCommonAlertSchema - (Optional) Enables or disables the common alert schema.

The automationRunbookReceiver block supports the following:

  • name - (Required) The name of the automation runbook receiver.
  • automationAccountId - (Required) The automation account ID which holds this runbook and authenticates to Azure resources.
  • runbookName - (Required) The name for this runbook.
  • webhookResourceId - (Required) The resource id for webhook linked to this runbook.
  • isGlobalRunbook - (Required) Indicates whether this instance is global runbook.
  • serviceUri - (Required) The URI where webhooks should be sent.
  • useCommonAlertSchema - (Optional) Enables or disables the common alert schema.

The azureAppPushReceiver block supports the following:

  • name - (Required) The name of the Azure app push receiver.
  • emailAddress - (Required) The email address of the user signed into the mobile app who will receive push notifications from this receiver.

The azureFunctionReceiver block supports the following:

  • name - (Required) The name of the Azure Function receiver.
  • functionAppResourceId - (Required) The Azure resource ID of the function app.
  • functionName - (Required) The function name in the function app.
  • httpTriggerUrl - (Required) The HTTP trigger url where HTTP request sent to.
  • useCommonAlertSchema - (Optional) Enables or disables the common alert schema.

The emailReceiver block supports the following:

  • name - (Required) The name of the email receiver. Names must be unique (case-insensitive) across all receivers within an action group.
  • emailAddress - (Required) The email address of this receiver.
  • useCommonAlertSchema - (Optional) Enables or disables the common alert schema.

The eventHubReceiver block supports the following:

  • name - (Required) The name of the EventHub Receiver, must be unique within action group.
  • eventHubId - (Optional) The resource ID of the respective Event Hub.
  • eventHubName - (Optional) The name of the specific Event Hub queue.
  • eventHubNamespace - (Optional) The namespace name of the Event Hub.
  • subscriptionId - (Optional) The ID for the subscription containing this Event Hub. Default to the subscription ID of the Action Group.

\~> NOTE: eventHubId is deprecated in version 3.0 and will be removed in version 4.0 of the AzureRM Provider. Please use eventHubName, eventHubName,and subscriptionId instead. And eventHubName, eventHubName will be required properties in version 4.0.

  • tenantId - (Optional) The Tenant ID for the subscription containing this Event Hub.
  • useCommonAlertSchema - (Optional) Indicates whether to use common alert schema.

The itsmReceiver block supports the following:

  • name - (Required) The name of the ITSM receiver.
  • workspaceId - (Required) The Azure Log Analytics workspace ID where this connection is defined. Format is <subscriptionId>|<workspaceId>, for example 00000000000000000000000000000000|00000000000000000000000000000000.
  • connectionId - (Required) The unique connection identifier of the ITSM connection.
  • ticketConfiguration - (Required) A JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well.
  • region - (Required) The region of the workspace.

-> NOTE ticketConfiguration should be JSON blob with payloadRevision and workItemType keys (e.g., ticketConfiguration="{\"payloadRevision\":0,\"workItemType\":\"incident\"}"), and ticketConfiguration="{}" will return an error, see more at this REST API issue


The logicAppReceiver block supports the following:

  • name - (Required) The name of the logic app receiver.
  • resourceId - (Required) The Azure resource ID of the logic app.
  • callbackUrl - (Required) The callback url where HTTP request sent to.
  • useCommonAlertSchema - (Optional) Enables or disables the common alert schema.

The smsReceiver block supports the following:

  • name - (Required) The name of the SMS receiver. Names must be unique (case-insensitive) across all receivers within an action group.
  • countryCode - (Required) The country code of the SMS receiver.
  • phoneNumber - (Required) The phone number of the SMS receiver.

The voiceReceiver block supports the following:

  • name - (Required) The name of the voice receiver.
  • countryCode - (Required) The country code of the voice receiver.
  • phoneNumber - (Required) The phone number of the voice receiver.

The webhookReceiver block supports the following:

  • name - (Required) The name of the webhook receiver. Names must be unique (case-insensitive) across all receivers within an action group.
  • serviceUri - (Required) The URI where webhooks should be sent.
  • useCommonAlertSchema - (Optional) Enables or disables the common alert schema.
  • aadAuth - (Optional) The aadAuth block as defined below

\~> NOTE: Before adding a secure webhook receiver by setting aadAuth, please read the configuration instruction of the AAD application.


The aadAuth block supports the following:.

  • objectId - (Required) The webhook application object Id for AAD auth.
  • identifierUri - (Optional) The identifier URI for AAD auth.
  • tenantId - (Optional) The tenant id for AAD auth.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Action Group.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Action Group.
  • update - (Defaults to 30 minutes) Used when updating the Action Group.
  • read - (Defaults to 5 minutes) Used when retrieving the Action Group.
  • delete - (Defaults to 30 minutes) Used when deleting the Action Group.

Import

Action Groups can be imported using the resourceId, e.g.

terraform import azurerm_monitor_action_group.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Insights/actionGroups/myagname