Skip to content

Commit

Permalink
Reorganized mandatory variables
Browse files Browse the repository at this point in the history
  • Loading branch information
bczoma committed Feb 8, 2024
1 parent 5b99399 commit 6bf998c
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 59 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Most optional variables' default value is null. If they are not provided then th

-> The module defaults for `ingress_enabled` and `egress_enabled` are `true`, which differ from the resource attribute defaults.

-> Important: Queues or topic endpoints must have proper `owner` or `permission` for non-owners configured to enable clients to connect and consume messages. The default values restrict all access. For additional details, refer to the [Solace documentation](https://docs.solace.com/Messaging/Guaranteed-Msg/Configuring-Queues.htm#Configuring_Queue_Owners)

## Examples

Refer to the following configuration examples:
Expand Down
10 changes: 9 additions & 1 deletion ci/module-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module "messaging_endpoint_1" {
msg_vpn_name = "default"
endpoint_type = "queue"
endpoint_name = "testQ2"
access_type = "exclusive"
permission = "consume"
queue_subscription_topics = ["foo/bar1", "foo/bar2", "foo/bar3"]
max_msg_size = 10
jndi_queue_name = "jndi/q"
Expand All @@ -22,9 +24,11 @@ module "messaging_endpoint_2" {
msg_vpn_name = "default"
endpoint_type = "topic_endpoint"
endpoint_name = "testT2"
access_type = "exclusive"
permission = "consume"
queue_subscription_topics = ["foo/bar1", "foo/bar3"]
max_msg_size = 10
jndi_topic_name = "jndi/t"
max_msg_size = 10
}

module "queue_template_1" {
Expand All @@ -33,6 +37,8 @@ module "queue_template_1" {
msg_vpn_name = "default"
endpoint_type = "queue_template"
endpoint_name = "qt"
access_type = "exclusive"
permission = "consume"
}

module "te_template_1" {
Expand All @@ -41,6 +47,8 @@ module "te_template_1" {
msg_vpn_name = "default"
endpoint_type = "topic_endpoint_template"
endpoint_name = "tet"
access_type = "exclusive"
permission = "consume"
}

output "queue" {
Expand Down
8 changes: 8 additions & 0 deletions ci/template-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module "messaging_endpoint_1" {
msg_vpn_name = "default"
endpoint_type = "queue"
endpoint_name = "testQ2"
access_type = "exclusive"
permission = "consume"
queue_subscription_topics = ["foo/bar1", "foo/bar2", "foo/bar3"]
jndi_queue_name = "jndi/q"
}
Expand All @@ -21,6 +23,8 @@ module "messaging_endpoint_2" {
msg_vpn_name = "default"
endpoint_type = "topic_endpoint"
endpoint_name = "testT2"
access_type = "exclusive"
permission = "consume"
queue_subscription_topics = ["foo/bar1", "foo/bar3"]
jndi_topic_name = "jndi/t"
}
Expand All @@ -31,6 +35,8 @@ module "queue_template_1" {
msg_vpn_name = "default"
endpoint_type = "queue_template"
endpoint_name = "qt"
access_type = "exclusive"
permission = "consume"
}

module "te_template_1" {
Expand All @@ -39,6 +45,8 @@ module "te_template_1" {
msg_vpn_name = "default"
endpoint_type = "topic_endpoint_template"
endpoint_name = "tet"
access_type = "exclusive"
permission = "consume"
}

output "queue" {
Expand Down
6 changes: 3 additions & 3 deletions examples/non-exclusive-queue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Configuration in this directory creates a [non-exclusive queue](https://docs.sol
* `msg_vpn_name` - set to `default` in the example
* `endpoint_type` - set to `queue`
* `endpoint_name`

While an optional input, `access_type` is set to `non-exclusive` to configure a non-exclusive queue.
* `access_type` - set to `non-exclusive` to configure a non-exclusive queue
* `permission` - set to `consume` to enable the receiver app to remove consumed messages from the queue

### Optional Inputs

Expand All @@ -24,7 +24,7 @@ The module `queue` output refers to the created queue.

### Access to a PubSub+ broker

If you don't already have access to a broker, refer to the [Developers page](https://www.solace.dev/) to get started.
If you don't already have access to a broker, refer to the [Developers page](https://www.solace.dev/) for options to get started.

### Adjust Provider Configuration

Expand Down
8 changes: 4 additions & 4 deletions examples/non-exclusive-queue/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ provider solacebroker {
}

module "non_exclusive_queue" {
# update with the module location
source = "../.."

msg_vpn_name = "default"
endpoint_type = "queue"
endpoint_name = "testQ"
access_type = "non-exclusive"
permission = "consume"

# ingress and egress are enabled by default in the module
# ingress and egress are enabled by default in the module, no need to enable here
# ingress_enabled = true
# egress_enabled = true

# other optional module variables example
permission = "consume"
}

output "provisioned_queue" {
value = module.non_exclusive_queue.queue
description = "The provisioned queue resource"
}

8 changes: 8 additions & 0 deletions internal/gen-template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ resource "solacebroker_msg_vpn_queue" "main" {

msg_vpn_name = var.msg_vpn_name
queue_name = var.endpoint_name
access_type = var.access_type
permission = var.permission
ingress_enabled = var.ingress_enabled
egress_enabled = var.egress_enabled

Expand Down Expand Up @@ -30,6 +32,8 @@ resource "solacebroker_msg_vpn_topic_endpoint" "main" {

msg_vpn_name = var.msg_vpn_name
topic_endpoint_name = var.endpoint_name
access_type = var.access_type
permission = var.permission
ingress_enabled = var.ingress_enabled
egress_enabled = var.egress_enabled

Expand All @@ -50,6 +54,8 @@ resource "solacebroker_msg_vpn_queue_template" "main" {

msg_vpn_name = var.msg_vpn_name
queue_template_name = var.endpoint_name
access_type = var.access_type
permission = var.permission

#AutoAddAttributes #EnableCommonVariables
}
Expand All @@ -59,6 +65,8 @@ resource "solacebroker_msg_vpn_topic_endpoint_template" "main" {

msg_vpn_name = var.msg_vpn_name
topic_endpoint_template_name = var.endpoint_name
access_type = var.access_type
permission = var.permission

#AutoAddAttributes #EnableCommonVariables
}
Expand Down
54 changes: 38 additions & 16 deletions internal/gen-template/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Input variable definitions

variable "msg_vpn_name" {
description = "The name of the Message VPN"
type = string
}
# Required variables

variable "endpoint_type" {
description = "The endpoint or template type. Must be one of `queue`, `topic_endpoint`, `queue_template` or `topic_endpoint_template`."
Expand All @@ -14,29 +11,36 @@ variable "endpoint_type" {
}
}

variable "endpoint_name" {
description = "The name of the endpoint or template"
variable "msg_vpn_name" {
description = "The name of the Message VPN"
type = string
}

variable "queue_subscription_topics" {
description = "List of queue subscription topics. Only valid if endpoint type is `queue`."
type = list(string)
default = []
variable "endpoint_name" {
description = "The name of the endpoint or template"
type = string
}

variable "jndi_queue_name" {
description = "Name of the JNDI queue if provided"
variable "access_type" {
description = "The access type for delivering messages to consumer flows bound to the endpoint. The allowed values and their meaning are: `exclusive` - Exclusive delivery of messages to the first bound consumer flow. `non-exclusive` - Non-exclusive delivery of messages to bound consumer flows in a round-robin (if partition count is zero) or partitioned (if partition count is non-zero) fashion."
type = string
default = ""
validation {
condition = contains(["exclusive", "non-exclusive"], var.access_type)
error_message = "Access type must be either `exclusive` or `non-exclusive`."
}
}

variable "jndi_topic_name" {
description = "Name of the JNDI topic if provided"
variable "permission" {
description = "The permission level for all consumers of the endpoint, excluding the owner. The allowed values and their meaning are: `no-access` - Disallows all access. `read-only` - Read-only access to the messages. `consume` - Consume (read and remove) messages. `modify-topic` - Consume messages or modify the topic/selector. `delete` - Consume messages, modify the topic/selector or delete the Client created endpoint altogether."
type = string
default = ""
validation {
condition = contains(["no-access", "read-only", "consume", "modify-topic", "delete"], var.permission)
error_message = "Permission must be one of `no-access`, `read-only`, `consume`, `modify-topic` or `delete`."
}
}

# Optional variables

variable "ingress_enabled" {
description = "Enable or disable the reception of messages to the endpoint. The default value is `true`"
type = bool
Expand All @@ -49,4 +53,22 @@ variable "egress_enabled" {
default = true
}

variable "queue_subscription_topics" {
description = "List of queue subscription topics. Only valid if endpoint type is `queue`."
type = list(string)
default = []
}

variable "jndi_queue_name" {
description = "Name of the JNDI queue if provided"
type = string
default = ""
}

variable "jndi_topic_name" {
description = "Name of the JNDI topic if provided"
type = string
default = ""
}

#AutoAddAttributes
16 changes: 8 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ resource "solacebroker_msg_vpn_queue" "main" {

msg_vpn_name = var.msg_vpn_name
queue_name = var.endpoint_name
access_type = var.access_type
permission = var.permission
ingress_enabled = var.ingress_enabled
egress_enabled = var.egress_enabled

access_type = var.access_type
consumer_ack_propagation_enabled = var.consumer_ack_propagation_enabled
dead_msg_queue = var.dead_msg_queue
delivery_count_enabled = var.delivery_count_enabled
Expand All @@ -24,7 +25,6 @@ resource "solacebroker_msg_vpn_queue" "main" {
partition_count = var.partition_count
partition_rebalance_delay = var.partition_rebalance_delay
partition_rebalance_max_handoff_time = var.partition_rebalance_max_handoff_time
permission = var.permission
redelivery_delay_enabled = var.redelivery_delay_enabled
redelivery_delay_initial_interval = var.redelivery_delay_initial_interval
redelivery_delay_max_interval = var.redelivery_delay_max_interval
Expand Down Expand Up @@ -58,10 +58,11 @@ resource "solacebroker_msg_vpn_topic_endpoint" "main" {

msg_vpn_name = var.msg_vpn_name
topic_endpoint_name = var.endpoint_name
access_type = var.access_type
permission = var.permission
ingress_enabled = var.ingress_enabled
egress_enabled = var.egress_enabled

access_type = var.access_type
consumer_ack_propagation_enabled = var.consumer_ack_propagation_enabled
dead_msg_queue = var.dead_msg_queue
delivery_count_enabled = var.delivery_count_enabled
Expand All @@ -76,7 +77,6 @@ resource "solacebroker_msg_vpn_topic_endpoint" "main" {
max_spool_usage = var.max_spool_usage
max_ttl = var.max_ttl
owner = var.owner
permission = var.permission
redelivery_delay_enabled = var.redelivery_delay_enabled
redelivery_delay_initial_interval = var.redelivery_delay_initial_interval
redelivery_delay_max_interval = var.redelivery_delay_max_interval
Expand All @@ -103,8 +103,9 @@ resource "solacebroker_msg_vpn_queue_template" "main" {

msg_vpn_name = var.msg_vpn_name
queue_template_name = var.endpoint_name
access_type = var.access_type
permission = var.permission

access_type = var.access_type
consumer_ack_propagation_enabled = var.consumer_ack_propagation_enabled
dead_msg_queue = var.dead_msg_queue
delivery_delay = var.delivery_delay
Expand All @@ -118,7 +119,6 @@ resource "solacebroker_msg_vpn_queue_template" "main" {
max_msg_spool_usage = var.max_msg_spool_usage
max_redelivery_count = var.max_redelivery_count
max_ttl = var.max_ttl
permission = var.permission
queue_name_filter = var.queue_name_filter
redelivery_delay_enabled = var.redelivery_delay_enabled
redelivery_delay_initial_interval = var.redelivery_delay_initial_interval
Expand All @@ -137,8 +137,9 @@ resource "solacebroker_msg_vpn_topic_endpoint_template" "main" {

msg_vpn_name = var.msg_vpn_name
topic_endpoint_template_name = var.endpoint_name
access_type = var.access_type
permission = var.permission

access_type = var.access_type
consumer_ack_propagation_enabled = var.consumer_ack_propagation_enabled
dead_msg_queue = var.dead_msg_queue
delivery_delay = var.delivery_delay
Expand All @@ -151,7 +152,6 @@ resource "solacebroker_msg_vpn_topic_endpoint_template" "main" {
max_msg_spool_usage = var.max_msg_spool_usage
max_redelivery_count = var.max_redelivery_count
max_ttl = var.max_ttl
permission = var.permission
redelivery_delay_enabled = var.redelivery_delay_enabled
redelivery_delay_initial_interval = var.redelivery_delay_initial_interval
redelivery_delay_max_interval = var.redelivery_delay_max_interval
Expand Down
Loading

0 comments on commit 6bf998c

Please sign in to comment.