Skip to content

azurermWebPubsubHub

Manages the hub settings for a Web Pubsub.

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: "east us",
    name: "terraform-webpubsub",
  }
);
const azurermUserAssignedIdentityExample =
  new azurerm.userAssignedIdentity.UserAssignedIdentity(this, "example_1", {
    location: azurermResourceGroupExample.location,
    name: "tfex-uai",
    resource_group_name: azurermResourceGroupExample.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.*/
azurermUserAssignedIdentityExample.overrideLogicalId("example");
const azurermWebPubsubExample = new azurerm.webPubsub.WebPubsub(
  this,
  "example_2",
  {
    capacity: 1,
    location: azurermResourceGroupExample.location,
    name: "tfex-webpubsub",
    resource_group_name: azurermResourceGroupExample.name,
    sku: "Standard_S1",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermWebPubsubExample.overrideLogicalId("example");
const azurermWebPubsubHubExample = new azurerm.webPubsubHub.WebPubsubHub(
  this,
  "example_3",
  {
    anonymous_connections_enabled: true,
    depends_on: [`\${${azurermWebPubsubExample.fqn}}`],
    event_handler: [
      {
        system_events: ["connect", "connected"],
        url_template: "https://test.com/api/{hub}/{event}",
        user_event_pattern: "*",
      },
      {
        auth: [
          {
            managed_identity_id: azurermUserAssignedIdentityExample.id,
          },
        ],
        system_events: ["connected"],
        url_template: "https://test.com/api/{hub}/{event}",
        user_event_pattern: "event1, event2",
      },
    ],
    name: "tfex_wpsh",
    web_pubsub_id: azurermWebPubsubExample.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.*/
azurermWebPubsubHubExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the Web Pubsub hub service. Changing this forces a new resource to be created.

  • webPubsubId - (Required) Specify the id of the Web Pubsub. Changing this forces a new resource to be created.

  • anonymousConnectionsEnabled - (Optional) Is anonymous connections are allowed for this hub? Defaults to false. Possible values are true, false.

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

-> NOTE: User can change the order of eventHandler to change the priority accordingly.


An eventHandler block supports the following:

  • urlTemplate - (Required) The Event Handler URL Template. Two predefined parameters {hub} and {event} are available to use in the template. The value of the EventHandler URL is dynamically calculated when the client request comes in. Example: http://exampleCom/api/{hub}/{event}.

  • userEventPattern - (Optional) Specify the matching event names. There are 3 kind of patterns supported: * * matches any event name * , Combine multiple events with , for example event1,event2, it matches event event1 and event2 * The single event name, for example event1, it matches event1.

  • systemEvents - (Optional) Specify the list of system events. Supported values are connect, connected and disconnected.

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


An auth block supports the following:

  • managedIdentityId - (Required) Specify the identity ID of the target resource.

-> NOTE: managedIdentityId is required if the auth block is defined

Attributes Reference

The following attributes are exported:

  • id - The ID of the Web Pubsub Hub resource.

  • name - (Required) The name of the Web Pubsub Hub resource. Changing this forces a new resource to be created.

Timeouts

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

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

Import

Web Pubsub Hub can be imported using the resourceId, e.g.

terraform import azurerm_web_pubsub_hub.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.SignalRService/webPubSub/webPubSub1/hubs/webPubSubhub1