From be029483184540440b41f54b248c9602dc650a44 Mon Sep 17 00:00:00 2001 From: Matthieu Nicolescu Date: Sun, 17 Mar 2024 19:08:58 +0100 Subject: [PATCH] feat: Add az-asb tf module --- terraform/modules/az-asb/main.tf | 27 ++++++++++++++ terraform/modules/az-asb/variables.tf | 53 +++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 terraform/modules/az-asb/main.tf create mode 100644 terraform/modules/az-asb/variables.tf diff --git a/terraform/modules/az-asb/main.tf b/terraform/modules/az-asb/main.tf new file mode 100644 index 0000000..656648a --- /dev/null +++ b/terraform/modules/az-asb/main.tf @@ -0,0 +1,27 @@ +resource "azurerm_servicebus_namespace" "asb" { + name = var.name + location = var.location + resource_group_name = var.resource_group_name + sku = var.sku + capacity = var.capacity + + public_network_access_enabled = var.public_network_access_enabled + + dynamic "network_rule_set" { + for_each = var.subnet_ids.length > 0 ? [1] : [] + content { + public_network_access_enabled = var.public_network_access_enabled + default_action = var.network_rules_default_action + trusted_services_allowed = var.trusted_services_allowed + + dynamic "network_rules" { + for_each = var.subnet_ids + content { + subnet_id = network_rules.value + } + } + } + } + + tags = var.tags +} diff --git a/terraform/modules/az-asb/variables.tf b/terraform/modules/az-asb/variables.tf new file mode 100644 index 0000000..651654b --- /dev/null +++ b/terraform/modules/az-asb/variables.tf @@ -0,0 +1,53 @@ +variable "name" { + description = "Name of the azure bus namespace" +} + +variable "location" { + description = "Azure Region Location" + type = string +} + +variable "resource_group_name" { + description = "Resource group name of the azure bus namespace" +} + +variable "sku" { + description = "The SKU of the Azure Service Bus Namespace" + type = string + default = "Premium" +} + +variable "capacity" { + description = "The capacity of the Azure Service Bus Namespace" + type = number + default = 1 +} + +variable "public_network_access_enabled" { + description = "Is public network access enabled for the Azure Service Bus Namespace" + type = bool + default = false +} + +variable "subnet_ids" { + description = "The list of subnet ids to associate with the Azure Service Bus Namespace" + type = list(string) + default = [] +} + +variable "network_rules_default_action" { + description = "The default action of the network rules" + type = string + default = "Deny" +} + +variable "trusted_services_allowed" { + description = "The list of trusted services allowed" + type = bool + default = false +} + +variable "tags" { + description = "Tags to associate with resources." + type = map(string) +}