Skip to content

azurermServicebusSubscription

Manages a ServiceBus 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: "tfex-servicebus-subscription",
  }
);
const azurermServicebusNamespaceExample =
  new azurerm.servicebusNamespace.ServicebusNamespace(this, "example_1", {
    location: azurermResourceGroupExample.location,
    name: "tfex-servicebus-namespace",
    resource_group_name: azurermResourceGroupExample.name,
    sku: "Standard",
    tags: {
      source: "terraform",
    },
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermServicebusNamespaceExample.overrideLogicalId("example");
const azurermServicebusTopicExample =
  new azurerm.servicebusTopic.ServicebusTopic(this, "example_2", {
    enable_partitioning: true,
    name: "tfex_servicebus_topic",
    namespace_id: azurermServicebusNamespaceExample.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermServicebusTopicExample.overrideLogicalId("example");
const azurermServicebusSubscriptionExample =
  new azurerm.servicebusSubscription.ServicebusSubscription(this, "example_3", {
    max_delivery_count: 1,
    name: "tfex_servicebus_subscription",
    topic_id: azurermServicebusTopicExample.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermServicebusSubscriptionExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the ServiceBus Subscription resource. Changing this forces a new resource to be created.

  • topicId - (Required) The ID of the ServiceBus Topic to create this Subscription in. Changing this forces a new resource to be created.

  • maxDeliveryCount - (Required) The maximum number of deliveries.

  • autoDeleteOnIdle - (Optional) The idle interval after which the topic is automatically deleted as an ISO 8601 duration. The minimum duration is 5 minutes or pt5M.

  • defaultMessageTtl - (Optional) The Default message timespan to live as an ISO 8601 duration. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.

  • lockDuration - (Optional) The lock duration for the subscription as an ISO 8601 duration. The default value is 1 minute or p0Dt0H1M0S . The maximum value is 5 minutes or p0Dt0H5M0S .

  • deadLetteringOnMessageExpiration - (Optional) Boolean flag which controls whether the Subscription has dead letter support when a message expires.

  • deadLetteringOnFilterEvaluationError - (Optional) Boolean flag which controls whether the Subscription has dead letter support on filter evaluation exceptions. Defaults to true.

  • enableBatchedOperations - (Optional) Boolean flag which controls whether the Subscription supports batched operations.

  • requiresSession - (Optional) Boolean flag which controls whether this Subscription supports the concept of a session. Changing this forces a new resource to be created.

  • forwardTo - (Optional) The name of a Queue or Topic to automatically forward messages to.

  • forwardDeadLetteredMessagesTo - (Optional) The name of a Queue or Topic to automatically forward Dead Letter messages to.

  • status - (Optional) The status of the Subscription. Possible values are active,receiveDisabled, or disabled. Defaults to active.

  • clientScopedSubscriptionEnabled - (Optional) whether the subscription is scoped to a client id. Defaults to false.

\~> NOTE: Client Scoped Subscription can only be used for JMS subscription (Java Message Service).

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

A clientScopedSubscription block supports the following:

  • clientId - (Optional) Specifies the Client ID of the application that created the client-scoped subscription. Changing this forces a new resource to be created.

\~> NOTE: Client ID can be null or empty, but it must match the client ID set on the JMS client application. From the Azure Service Bus perspective, a null client ID and an empty client id have the same behavior. If the client ID is set to null or empty, it is only accessible to client applications whose client ID is also set to null or empty.

  • isClientScopedSubscriptionShareable - (Optional) Whether the client scoped subscription is shareable. Defaults to true Changing this forces a new resource to be created.

  • isClientScopedSubscriptionDurable - (Optional) Whether the client scoped subscription is durable. This property can only be controlled from the application side.

Attributes Reference

The following attributes are exported:

  • id - The ServiceBus Subscription ID.

Timeouts

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

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

Import

Service Bus Subscriptions can be imported using the resourceId, e.g.

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