Skip to content

Commit 0625151

Browse files
authored
feat: (IAC-1020) Support for Azure Service Bus - Experimental (#320)
1 parent 60f6d5d commit 0625151

File tree

6 files changed

+128
-0
lines changed

6 files changed

+128
-0
lines changed

main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,19 @@ module "netapp" {
252252
depends_on = [module.vnet]
253253
}
254254

255+
module "message_broker" {
256+
source = "./modules/azurerm_message_broker"
257+
count = var.create_azure_message_broker ? 1 : 0
258+
259+
resource_group_name = local.aks_rg.name
260+
location = var.location
261+
prefix = var.prefix
262+
message_broker_sku = var.message_broker_sku
263+
message_broker_name = var.message_broker_name
264+
message_broker_capacity = var.message_broker_capacity
265+
tags = var.tags
266+
}
267+
255268
data "external" "git_hash" {
256269
program = ["files/tools/iac_git_info.sh"]
257270
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright © 2020-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Azure Service Bus
5+
# - https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview
6+
# - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/servicebus_namespace
7+
# - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/servicebus_namespace_authorization_rule
8+
9+
resource "azurerm_servicebus_namespace" "message_broker" {
10+
name = "${var.prefix}-message-broker"
11+
location = var.location
12+
resource_group_name = var.resource_group_name
13+
sku = var.message_broker_sku
14+
capacity = var.message_broker_capacity
15+
16+
tags = var.tags
17+
}
18+
19+
resource "azurerm_servicebus_namespace_authorization_rule" "message_broker_config" {
20+
name = var.message_broker_name
21+
namespace_id = azurerm_servicebus_namespace.message_broker.id
22+
23+
listen = true
24+
send = true
25+
manage = true
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright © 2020-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
output "message_broker_hostname" {
5+
value = regex("//(.*):", azurerm_servicebus_namespace.message_broker.endpoint)
6+
}
7+
8+
output "message_broker_primary_key" {
9+
value = azurerm_servicebus_namespace_authorization_rule.message_broker_config.primary_key
10+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright © 2020-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
variable "prefix" {
5+
description = "A prefix used in the name for all the Azure resources created by this script."
6+
type = string
7+
}
8+
9+
variable "resource_group_name" {
10+
description = "The name of the resource group in which to create the PostgreSQL Server. Changing this forces a new resource to be created."
11+
type = string
12+
}
13+
14+
variable "location" {
15+
description = "Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created."
16+
type = string
17+
}
18+
19+
variable "message_broker_sku" {
20+
description = "Defines which tier to use. Options are Basic, Standard or Premium. SAS Viya Platform recommends using 'Premium'."
21+
type = string
22+
default = "Premium"
23+
}
24+
25+
variable "message_broker_name" {
26+
description = "Specifies the name of the message broker, also specified for the ServiceBus Namespace Authorization Rule resource. Changing this forces a new resource to be created."
27+
type = string
28+
default = "Arke"
29+
}
30+
31+
variable "message_broker_capacity" {
32+
description = "Specifies the capacity. When sku is Premium, capacity can be 1, 2, 4, 8 or 16. When sku is Basic or Standard, capacity can be 0 only."
33+
type = number
34+
default = 1
35+
}
36+
37+
variable "tags" {
38+
description = "Map of common tags to be placed on the Resources"
39+
type = map(any)
40+
}

outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,17 @@ output "cluster_node_pool_mode" {
144144
output "cluster_api_mode" {
145145
value = var.cluster_api_mode
146146
}
147+
148+
## Message Broker - Azure Service Bus
149+
output "message_broker_hostname" {
150+
value = element(flatten(module.message_broker[*].message_broker_hostname), 0)
151+
}
152+
153+
output "message_broker_primary_key" {
154+
value = element(coalescelist(module.message_broker[*].message_broker_primary_key, [""]), 0)
155+
sensitive = true
156+
}
157+
158+
output "message_broker_name" {
159+
value = var.message_broker_name
160+
}

variables.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,3 +741,28 @@ variable "aks_identity" {
741741
error_message = "ERROR: Supported values for `aks_identity` are: uai, sp."
742742
}
743743
}
744+
745+
## Message Broker - Azure Service Bus - Experimental
746+
variable "create_azure_message_broker" {
747+
description = "Allows user to create a fully managed enterprise message broker: Azure Service Bus"
748+
type = bool
749+
default = false
750+
}
751+
752+
variable "message_broker_sku" {
753+
description = "Defines which tier to use. Options are Basic, Standard or Premium. SAS Viya Platform recommends using 'Premium'."
754+
type = string
755+
default = "Premium"
756+
}
757+
758+
variable "message_broker_name" {
759+
description = "Specifies the name of the message broker, also specified for the ServiceBus Namespace Authorization Rule resource. Changing this forces a new resource to be created."
760+
type = string
761+
default = "Arke"
762+
}
763+
764+
variable "message_broker_capacity" {
765+
description = "Specifies the capacity. When sku is Premium, capacity can be 1, 2, 4, 8 or 16. When sku is Basic or Standard, capacity can be 0 only."
766+
type = number
767+
default = 1
768+
}

0 commit comments

Comments
 (0)