Skip to content

azurermServicebusQueue

Manages a ServiceBus Queue.

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: "terraform-servicebus",
  }
);
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 azurermServicebusQueueExample =
  new azurerm.servicebusQueue.ServicebusQueue(this, "example_2", {
    enable_partitioning: true,
    name: "tfex_servicebus_queue",
    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.*/
azurermServicebusQueueExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

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

  • namespaceId - (Required) The ID of the ServiceBus Namespace to create this queue in. Changing this forces a new resource to be created.

  • lockDuration - (Optional) The ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. Maximum value is 5 minutes. Defaults to 1 minute (pt1M).

  • maxMessageSizeInKilobytes - (Optional) Integer value which controls the maximum size of a message allowed on the queue for Premium SKU. For supported values see the "Large messages support" section of this document.

  • maxSizeInMegabytes - (Optional) Integer value which controls the size of memory allocated for the queue. For supported values see the "Queue or topic size" section of Service Bus Quotas. Defaults to 1024.

  • requiresDuplicateDetection - (Optional) Boolean flag which controls whether the Queue requires duplicate detection. Changing this forces a new resource to be created. Defaults to false.

  • requiresSession - (Optional) Boolean flag which controls whether the Queue requires sessions. This will allow ordered handling of unbounded sequences of related messages. With sessions enabled a queue can guarantee first-in-first-out delivery of messages. Changing this forces a new resource to be created. Defaults to false.

  • defaultMessageTtl - (Optional) The ISO 8601 timespan duration of the TTL of messages sent to this queue. This is the default value used when TTL is not set on message itself.

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

  • duplicateDetectionHistoryTimeWindow - (Optional) The ISO 8601 timespan duration during which duplicates can be detected. Defaults to 10 minutes (pt10M).

  • maxDeliveryCount - (Optional) Integer value which controls when a message is automatically dead lettered. Defaults to 10.

  • status - (Optional) The status of the Queue. Possible values are active, creating, deleting, disabled, receiveDisabled, renaming, sendDisabled, unknown. Note that restoring is not accepted. Defaults to active.

  • enableBatchedOperations - (Optional) Boolean flag which controls whether server-side batched operations are enabled. Defaults to true.

  • autoDeleteOnIdle - (Optional) The ISO 8601 timespan duration of the idle interval after which the Queue is automatically deleted, minimum of 5 minutes.

  • enablePartitioning - (Optional) Boolean flag which controls whether to enable the queue to be partitioned across multiple message brokers. Changing this forces a new resource to be created. Defaults to false for Basic and Standard.

-> NOTE: Partitioning is available at entity creation for all queues and topics in Basic or Standard SKUs. It is not available for the Premium messaging SKU, but any previously existing partitioned entities in Premium namespaces continue to work as expected. Please see the documentation for more information.

  • enableExpress - (Optional) Boolean flag which controls whether Express Entities are enabled. An express queue holds a message in memory temporarily before writing it to persistent storage. Defaults to false for Basic and Standard. For Premium, it MUST be set to false.

\~> NOTE: Service Bus Premium namespaces do not support Express Entities, so enableExpress MUST be set to false.

  • forwardTo - (Optional) The name of a Queue or Topic to automatically forward messages to. Please see the documentation for more information.

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

Attributes Reference

The following attributes are exported:

  • id - The ServiceBus Queue ID.

Timeouts

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

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

Import

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

terraform import azurerm_servicebus_queue.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ServiceBus/namespaces/sbns1/queues/snqueue1