Skip to content

azurermEventgridSystemTopicEventSubscription

Manages an EventGrid System Topic Event Subscription.

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: "example-rg",
  }
);
const azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_1",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    location: azurermResourceGroupExample.location,
    name: "examplestorageaccount",
    resource_group_name: azurermResourceGroupExample.name,
    tags: {
      environment: "staging",
    },
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermStorageQueueExample = new azurerm.storageQueue.StorageQueue(
  this,
  "example_2",
  {
    name: "examplestoragequeue",
    storage_account_name: azurermStorageAccountExample.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.*/
azurermStorageQueueExample.overrideLogicalId("example");
const azurermEventgridSystemTopicExample =
  new azurerm.eventgridSystemTopic.EventgridSystemTopic(this, "example_3", {
    location: "Global",
    name: "example-system-topic",
    resource_group_name: azurermResourceGroupExample.name,
    source_arm_resource_id: azurermResourceGroupExample.id,
    topic_type: "Microsoft.Resources.ResourceGroups",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermEventgridSystemTopicExample.overrideLogicalId("example");
const azurermEventgridSystemTopicEventSubscriptionExample =
  new azurerm.eventgridSystemTopicEventSubscription.EventgridSystemTopicEventSubscription(
    this,
    "example_4",
    {
      name: "example-event-subscription",
      resource_group_name: azurermResourceGroupExample.name,
      storage_queue_endpoint: [
        {
          queue_name: azurermStorageQueueExample.name,
          storage_account_id: azurermStorageAccountExample.id,
        },
      ],
      system_topic: azurermEventgridSystemTopicExample.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.*/
azurermEventgridSystemTopicEventSubscriptionExample.overrideLogicalId(
  "example"
);

Arguments Reference

The following arguments are supported:

  • name - (Required) The name which should be used for this Event Subscription. Changing this forces a new Event Subscription to be created.

  • systemTopic - (Required) The System Topic where the Event Subscription should be created in. Changing this forces a new Event Subscription to be created.

  • resourceGroupName - (Required) The name of the Resource Group where the System Topic exists. Changing this forces a new Event Subscription to be created.

  • expirationTimeUtc - (Optional) Specifies the expiration time of the event subscription (Datetime Format rfc3339).

  • eventDeliverySchema - (Optional) Specifies the event delivery schema for the event subscription. Possible values include: eventGridSchema, cloudEventSchemaV10, customInputSchema. Defaults to eventGridSchema. Changing this forces a new resource to be created.

  • azureFunctionEndpoint - (Optional) An azureFunctionEndpoint block as defined below.

  • eventhubEndpointId - (Optional) Specifies the id where the Event Hub is located.

  • hybridConnectionEndpointId - (Optional) Specifies the id where the Hybrid Connection is located.

  • serviceBusQueueEndpointId - (Optional) Specifies the id where the Service Bus Queue is located.

  • serviceBusTopicEndpointId - (Optional) Specifies the id where the Service Bus Topic is located.

  • storageQueueEndpoint - (Optional) A storageQueueEndpoint block as defined below.

  • webhookEndpoint - (Optional) A webhookEndpoint block as defined below.

\~> NOTE: One of azureFunctionEndpoint, eventhubEndpointId, hybridConnectionEndpoint, hybridConnectionEndpointId, serviceBusQueueEndpointId, serviceBusTopicEndpointId, storageQueueEndpoint or webhookEndpoint must be specified.

  • includedEventTypes - (Optional) A list of applicable event types that need to be part of the event subscription.

  • subjectFilter - (Optional) A subjectFilter block as defined below.

  • advancedFilter - (Optional) A advancedFilter block as defined below.

  • deliveryIdentity - (Optional) A deliveryIdentity block as defined below.

  • deliveryProperty - (Optional) One or more deliveryProperty blocks as defined below.

  • deadLetterIdentity - (Optional) A deadLetterIdentity block as defined below.

-> Note: storageBlobDeadLetterDestination must be specified when a deadLetterIdentity is specified

  • storageBlobDeadLetterDestination - (Optional) A storageBlobDeadLetterDestination block as defined below.

  • retryPolicy - (Optional) A retryPolicy block as defined below.

  • labels - (Optional) A list of labels to assign to the event subscription.

  • advancedFilteringOnArraysEnabled - (Optional) Specifies whether advanced filters should be evaluated against an array of values instead of expecting a singular value. Defaults to false.


A storageQueueEndpoint block supports the following:

  • storageAccountId - (Required) Specifies the id of the storage account id where the storage queue is located.

  • queueName - (Required) Specifies the name of the storage queue where the Event Subscription will receive events.

  • queueMessageTimeToLiveInSeconds - (Optional) Storage queue message time to live in seconds.


An azureFunctionEndpoint block supports the following:

  • functionId - (Required) Specifies the ID of the Function where the Event Subscription will receive events. This must be the functions ID in format {function_app.id}/functions/{name}.

  • maxEventsPerBatch - (Optional) Maximum number of events per batch.

  • preferredBatchSizeInKilobytes - (Optional) Preferred batch size in Kilobytes.


A webhookEndpoint block supports the following:

  • url - (Required) Specifies the url of the webhook where the Event Subscription will receive events.

  • baseUrl - (Computed) The base url of the webhook where the Event Subscription will receive events.

  • maxEventsPerBatch - (Optional) Maximum number of events per batch.

  • preferredBatchSizeInKilobytes - (Optional) Preferred batch size in Kilobytes.

  • activeDirectoryTenantId - (Optional) The Azure Active Directory Tenant ID to get the access token that will be included as the bearer token in delivery requests.

  • activeDirectoryAppIdOrUri - (Optional) The Azure Active Directory Application ID or URI to get the access token that will be included as the bearer token in delivery requests.


A subjectFilter block supports the following:

  • subjectBeginsWith - (Optional) A string to filter events for an event subscription based on a resource path prefix.

  • subjectEndsWith - (Optional) A string to filter events for an event subscription based on a resource path suffix.

  • caseSensitive - (Optional) Specifies if subjectBeginsWith and subjectEndsWith case sensitive. This value


A advancedFilter supports the following nested blocks:

  • boolEquals - (Optional) Compares a value of an event using a single boolean value.
  • numberGreaterThan - (Optional) Compares a value of an event using a single floating point number.
  • numberGreaterThanOrEquals - (Optional) Compares a value of an event using a single floating point number.
  • numberLessThan - (Optional) Compares a value of an event using a single floating point number.
  • numberLessThanOrEquals - (Optional) Compares a value of an event using a single floating point number.
  • numberIn - (Optional) Compares a value of an event using multiple floating point numbers.
  • numberNotIn - (Optional) Compares a value of an event using multiple floating point numbers.
  • numberInRange - (Optional) Compares a value of an event using multiple floating point number ranges.
  • numberNotInRange - (Optional) Compares a value of an event using multiple floating point number ranges.
  • stringBeginsWith - (Optional) Compares a value of an event using multiple string values.
  • stringNotBeginsWith - (Optional) Compares a value of an event using multiple string values.
  • stringEndsWith - (Optional) Compares a value of an event using multiple string values.
  • stringNotEndsWith - (Optional) Compares a value of an event using multiple string values.
  • stringContains - (Optional) Compares a value of an event using multiple string values.
  • stringNotContains - (Optional) Compares a value of an event using multiple string values.
  • stringIn - (Optional) Compares a value of an event using multiple string values.
  • stringNotIn - (Optional) Compares a value of an event using multiple string values.
  • isNotNull - (Optional) Evaluates if a value of an event isn't NULL or undefined.
  • isNullOrUndefined - (Optional) Evaluates if a value of an event is NULL or undefined.

Each nested block consists of a key and a value(s) element.

  • key - (Required) Specifies the field within the event data that you want to use for filtering. Type of the field can be a number, boolean, or string.

  • value - (Required) Specifies a single value to compare to when using a single value operator.

OR

  • values - (Required) Specifies an array of values to compare to when using a multiple values operator.

\~> NOTE: A maximum of total number of advanced filter values allowed on event subscription is 25.


A deliveryIdentity block supports the following:

  • type - (Required) Specifies the type of Managed Service Identity that is used for event delivery. Allowed value is systemAssigned, userAssigned.

  • userAssignedIdentity - (Optional) The user identity associated with the resource.


A deliveryProperty block supports the following:

\~> NOTE: deliveryProperty blocks are only effective when using an azureFunctionEndpoint, eventhubEndpointId, hybridConnectionEndpointId, serviceBusTopicEndpointId, or webhookEndpoint endpoint specification.

  • headerName - (Required) The name of the header to send on to the destination.

  • type - (Required) Either static or dynamic.

  • value - (Optional) If the type is static, then provide the value to use.

  • sourceField - (Optional) If the type is dynamic, then provide the payload field to be used as the value. Valid source fields differ by subscription type.

  • secret - (Optional) Set to true if the value is a secret and should be protected, otherwise false. If true then this value won't be returned from Azure API calls.


A deadLetterIdentity block supports the following:

  • type - (Required) Specifies the type of Managed Service Identity that is used for dead lettering. Allowed value is systemAssigned, userAssigned.

  • userAssignedIdentity - (Optional) The user identity associated with the resource.


A storageBlobDeadLetterDestination block supports the following:

  • storageAccountId - (Required) Specifies the id of the storage account id where the storage blob is located.

  • storageBlobContainerName - (Required) Specifies the name of the Storage blob container that is the destination of the deadletter events.


A retryPolicy block supports the following:

  • maxDeliveryAttempts - (Required) Specifies the maximum number of delivery retry attempts for events.

  • eventTimeToLive - (Required) Specifies the time to live (in minutes) for events. Supported range is 1 to 1440. See official documentation for more details.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the EventGrid System Topic.

Timeouts

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

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

Import

EventGrid System Topic Event Subscriptions can be imported using the resourceId, e.g.

terraform import azurerm_eventgrid_system_topic_event_subscription.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.EventGrid/systemTopics/topic1/eventSubscriptions/subscription1