A Terraform module for creating Azure Service Bus subscription Refer to the following link for a detailed explanation of the Azure Service Bus subscription.
Azure Service Bus Subscription
The following example shows how to use the module to create an Azure Service Bus subscription.
module "servicebus-subscription" {
source = "[email protected]:hmcts/terraform-module-servicebus-subscription?ref=master"
name = "your-subscription"
namespace_name = module.servicebus-namespace.name
topic_name = module.servicebus-topic.name
resource_group_name = azurerm_resource_group.rg.name
}
The following example shows how to add a servicebus subscription rule:
locals {
sql_filters = {
"hmc-servicebus-aat-subscription-rule-civil" : {
sql_filter = "hmctsServiceId IN ('AAA7','AAA6')"
}
}
correlation_filters = {
correlation_filter1 : {
properties = {
hmctsProperty = "any"
}
}
}
}
module "servicebus-subscription" {
source = "[email protected]:hmcts/terraform-module-servicebus-subscription?ref=master"
name = "hmc-to-civil-subscription"
namespace_name = "hmc-servicebus"
topic_name = "hmc-to-cft"
resource_group_name = "hmc-shared"
sql_filters = local.sql_filters
correlation_filters = local.correlation_filters
}
The following example shows how to give read access to a user assigned managed identity for the subscription:
module "servicebus-subscription" {
source = "[email protected]:hmcts/terraform-module-servicebus-subscription?ref=master"
name = "your-subscription"
namespace_name = module.servicebus-namespace.name
topic_name = module.servicebus-topic.name
resource_group_name = azurerm_resource_group.rg.name
# this variable is required
managed_identity_object_id = "your-mi-object-id"
}
Name | Version |
---|---|
azurerm | >= 3.0.0 |
Name | Version |
---|---|
azurerm | 3.79.0 |
Name | Type |
---|---|
azurerm_role_assignment.mi_role_assignment_receiver | resource |
azurerm_servicebus_subscription.servicebus_subscription | resource |
azurerm_servicebus_subscription_rule.correlation_filter_rules | resource |
azurerm_servicebus_subscription_rule.sql_filter_rule | resource |
azurerm_servicebus_topic.this | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
correlation_filters | A map of correlation filters to create rules for which messages will be forwarded from the topic to the subscription. If left undefined or empty all messages will be forwarded. Defaults to {}. | map(object({ |
{} |
no |
forward_dead_lettered_messages_to | Topic or Queue to forwards dead lettered messages to | string |
"" |
no |
forward_to | Topic or Queue to forwards received messages to | string |
"" |
no |
lock_duration | Message lock duration (ISO-8601) | string |
"PT1M" |
no |
managed_identity_object_id | the object id of the managed identity - can be retrieved with az identity show --name -sandbox-mi -g managed-identities--rg --subscription DCD-CFTAPPS- --query principalId -o tsv | any |
null |
no |
max_delivery_count | Maximum number of attempts to deliver a message before it's sent to dead letter queue | number |
10 |
no |
name | Azure Service Bus subscription name | string |
n/a | yes |
namespace_name | Azure Service Bus namespace | string |
n/a | yes |
requires_session | A value that indicates whether the queue supports the concept of sessions | bool |
false |
no |
resource_group_name | Resource group in which the Service Bus subscription should exist | string |
n/a | yes |
sql_filters | A map of sql filters | map(object({ |
{} |
no |
topic_name | Azure Service Bus topic name | string |
n/a | yes |
Name | Description |
---|---|
id | n/a |