azurerm_servicebus_subscription_rule

Manages a ServiceBus Subscription Rule.

Example Usage (SQL Filter)

resource "azurerm_resource_group" "example" {
  name     = "tfex-servicebus-subscription-rule-sql"
  location = "West Europe"
}

resource "azurerm_servicebus_namespace" "example" {
  name                = "tfex-servicebus-namespace"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku                 = "Standard"

  tags = {
    source = "terraform"
  }
}

resource "azurerm_servicebus_topic" "example" {
  name         = "tfex_servicebus_topic"
  namespace_id = azurerm_servicebus_namespace.example.id

  enable_partitioning = true
}

resource "azurerm_servicebus_subscription" "example" {
  name               = "tfex_servicebus_subscription"
  topic_id           = azurerm_servicebus_topic.example.id
  max_delivery_count = 1
}

resource "azurerm_servicebus_subscription_rule" "example" {
  name            = "tfex_servicebus_rule"
  subscription_id = azurerm_servicebus_subscription.example.id
  filter_type     = "SqlFilter"
  sql_filter      = "colour = 'red'"
}

Example Usage (Correlation Filter)

resource "azurerm_resource_group" "example" {
  name     = "tfex-servicebus-subscription-rule-cor"
  location = "West Europe"
}

resource "azurerm_servicebus_namespace" "example" {
  name                = "tfex-servicebus-namespace"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku                 = "Standard"

  tags = {
    source = "terraform"
  }
}

resource "azurerm_servicebus_topic" "example" {
  name         = "tfex_servicebus_topic"
  namespace_id = azurerm_servicebus_namespace.example.id

  enable_partitioning = true
}

resource "azurerm_servicebus_subscription" "example" {
  name               = "tfex_servicebus_subscription"
  topic_id           = azurerm_servicebus_topic.example.id
  max_delivery_count = 1
}

resource "azurerm_servicebus_subscription_rule" "example" {
  name            = "tfex_servicebus_rule"
  subscription_id = azurerm_servicebus_subscription.example.id
  filter_type     = "CorrelationFilter"

  correlation_filter {
    correlation_id = "high"
    label          = "red"
    properties = {
      customProperty = "value"
    }
  }
}

Argument Reference

The following arguments are supported:


The correlation_filter block supports the following:

Attributes Reference

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

Timeouts

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

Import

Service Bus Subscription Rule can be imported using the resource id, e.g.

terraform import azurerm_servicebus_subscription_rule.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ServiceBus/namespaces/sbns1/topics/sntopic1/subscriptions/sbsub1/rules/sbrule1