Skip to content

Commit

Permalink
Added generated module code
Browse files Browse the repository at this point in the history
  • Loading branch information
bczoma committed Feb 15, 2024
1 parent 61c1842 commit 3d9e80a
Show file tree
Hide file tree
Showing 12 changed files with 522 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/module-test-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Provider Test Pipeline

on: push

jobs:
test:
name: Run Provider setup and tests
runs-on: ubuntu-latest
steps:
# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: "1.21"

- name: Check out code
uses: actions/checkout@v4

- name: Set up Terraform latest
uses: hashicorp/setup-terraform@v2

- name: Setup test broker
run: |
mkdir -p $HOME/solace; chmod 777 $HOME/solace
docker run -d -p 8080:8080 -p 55555:55555 --shm-size=1g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin --env system_scaling_maxkafkabridgecount="10" --name=solace \
--env system_scaling_maxconnectioncount="1000" --mount type=bind,source=$HOME/solace,destination=/var/lib/solace,ro=false solace/solace-pubsub-standard:latest
while ! curl -s localhost:8080 | grep aurelia ; do sleep 1 ; done
- name: Test module from template on test broker
run: |
ci/scripts/test-module.sh ci/template-test
- name: Test module root on test broker
run: |
ci/scripts/test-module.sh ci/module-test
- name: Test examples
run: |
for dir in examples/*; do (ci/scripts/test-module.sh "$dir"); done
# ci/scripts/test-module.sh examples/non-exclusive-queue
84 changes: 82 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,82 @@
# terraform-solacebroker-jndi
Solace software broker Terraform module to abstract jndi configuration
# Solace PubSub+ Software Event Broker JNDI Terraform Module

Terraform module to configure a non-XA or XA [connection factory](https://docs.solace.com/API/Solace-JMS-API/Connection-Factories.htm) in the JNDI store of a [Solace PubSub+ Event Broker](https://solace.com/products/event-broker/).

Full details are provided in the [Examples](#examples).

## Related modules

JNDI access must be enabled on the Message VPN. This can be configured using the [Service Module](). By default JNDI access is not enabled on Solace PubSub+ appliances, but it is enabled on Solace PubSub+ software event brokers.

To configure JNDI managed objects (JNDI Topics and Queues) use the [Queues & Endpoint Module]().

## Module input variables

### Required

* `msg_vpn_name` - Endpoints and endpoint templates are specific to a Message VPN on the broker
* `connection_factory_name` - The name of the connection factory to be created

### Optional

* `xa_enabled`

Additional optional module variables names are the same as the underlying connection factory resource attributes. The recommended approach to determine variable name mappings is to look up the resource's documentation for matching attribute names:

| Resource name |
|---------------|
|[solacebroker_msg_vpn_jndi_connection_factory](https://registry.terraform.io/providers/SolaceProducts/solacebroker/latest/docs/resources/msg_vpn_jndi_connection_factory#optional)|

Most optional variables' default value is null.

## Module outputs

The output provides reference to created resources. Any reference for a resource that has not been created for an endpoint type will be set to `(null)`.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_solacebroker"></a> [solacebroker](#provider\_solacebroker) | ~> 0.9 |

## Resources

The following table shows the resources created for each `endpoint-type` value. "X" denotes a resource always created, "O" is a resource that may be created optionally

| Name | queue | topic_endpoint | queue_template | topic_endpoint_template |
|------|------|------|------|------|
| solacebroker_msg_vpn_queue | X | | | |
| solacebroker_msg_vpn_jndi_queue | O | | | |
| solacebroker_msg_vpn_queue_subscription | O | | | |
| solacebroker_msg_vpn_topic_endpoint | | X | | |
| solacebroker_msg_vpn_jndi_topic | | O | | |
| solacebroker_msg_vpn_queue_template | | | X | |
| solacebroker_msg_vpn_topic_endpoint_template | | | | X |

## Examples

Refer to the following configuration examples:

- Queue
- [Exclusive queue](examples/exclusive-queue)
- [Non-exclusive queue](examples/non-exclusive-queue)
- [Partitioned queue](examples/partitioned-queue)
- [Queue with topic subscriptions](examples/queue-with-topic-subscriptions)
- [Queue with exposed JNDI](examples/queue-with-jndi)
- [Queue template](examples/queue-template)
- [Topic endpoint](examples/topic-endpoint)
- [Topic endpoint with exposed JNDI](examples/topic-endpoint-with-jndi)
- [Topic endpoint template](examples/topic-endpoint-template)

## Module use recommendations

This module is expected to be used primarily by application teams. It supports provisioning connection factories required by a specific application. It may be forked and adjusted with private defaults.

## Resources

For more information about Solace technology in general please visit these resources:

- Solace [Technical Documentation](https://docs.solace.com/)
- The Solace Developer Portal website at: [solace.dev](//solace.dev/)
- Understanding [Solace technology](//solace.com/products/platform/)
- Ask the [Solace community](//dev.solace.com/community/).
36 changes: 36 additions & 0 deletions ci/module-test/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
provider "solacebroker" {
username = "admin"
password = "admin"
url = "http://localhost:8080"
}

module "testcf" {
source = "../.."
# version = ""

msg_vpn_name = "default"
connection_factory_name = "/JNDI/CF/GettingStarted"
transport_compression_level = 3
}

module "testcfxa" {
source = "../.."
# version = ""

msg_vpn_name = "default"
connection_factory_name = "/JNDI/CF/GettingStartedXA"
xa_enabled = true
transport_compression_level = 3
}

output "connection_factory" {
value = module.testcf.connection_factory
}

output "connection_factory_null" {
value = module.testcf.xa_connection_factory
}

output "xaconnection_factory" {
value = module.testcfxa.xa_connection_factory
}
10 changes: 10 additions & 0 deletions ci/module-test/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Terraform configuration

terraform {
required_providers {
solacebroker = {
source = "registry.terraform.io/solaceproducts/solacebroker"
}
}
required_version = "~> 1.2"
}
16 changes: 16 additions & 0 deletions ci/template-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ module "testcf" {
connection_factory_name = "/JNDI/CF/GettingStarted"
}

module "testcfxa" {
source = "../../internal/gen-template"

msg_vpn_name = "default"
connection_factory_name = "/JNDI/CF/GettingStartedXA"
xa_enabled = true
}

output "connection_factory" {
value = module.testcf.connection_factory
}

output "connection_factory_null" {
value = module.testcf.xa_connection_factory
}

output "xaconnection_factory" {
value = module.testcfxa.xa_connection_factory
}
2 changes: 2 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_jndi_connection_factory" "main" {

msg_vpn_name = var.msg_vpn_name
connection_factory_name = var.connection_factory_name
transport_direct_transport_enabled = var.xa_enabled == true ? false : var.transport_direct_transport_enabled
xa_enabled = var.xa_enabled

#AutoAddAttributes #EnableCommonVariables
}
4 changes: 4 additions & 0 deletions internal/gen-template/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
output "connection_factory" {
value = try(solacebroker_msg_vpn_jndi_connection_factory.main[0], null)
}

output "xa_connection_factory" {
value = var.xa_enabled == true ? try(solacebroker_msg_vpn_jndi_connection_factory.main[0], null) : null
}
12 changes: 12 additions & 0 deletions internal/gen-template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@ variable "connection_factory_name" {

# Optional variables

variable "xa_enabled" {
description = "Enable or disable connection factory as an XA Connection Factory."
type = bool
default = null
}

variable "transport_direct_transport_enabled" {
description = "Enable or disable usage of Direct Transport mode."
type = bool
default = null
}

#AutoAddAttributes
47 changes: 47 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
resource "solacebroker_msg_vpn_jndi_connection_factory" "main" {
count = var.connection_factory_name != "" ? 1 : 0

msg_vpn_name = var.msg_vpn_name
connection_factory_name = var.connection_factory_name
transport_direct_transport_enabled = var.xa_enabled == true ? false : var.transport_direct_transport_enabled
xa_enabled = var.xa_enabled

allow_duplicate_client_id_enabled = var.allow_duplicate_client_id_enabled
client_description = var.client_description
client_id = var.client_id
dto_receive_override_enabled = var.dto_receive_override_enabled
dto_receive_subscriber_local_priority = var.dto_receive_subscriber_local_priority
dto_receive_subscriber_network_priority = var.dto_receive_subscriber_network_priority
dto_send_enabled = var.dto_send_enabled
dynamic_endpoint_create_durable_enabled = var.dynamic_endpoint_create_durable_enabled
dynamic_endpoint_respect_ttl_enabled = var.dynamic_endpoint_respect_ttl_enabled
guaranteed_receive_ack_timeout = var.guaranteed_receive_ack_timeout
guaranteed_receive_reconnect_retry_count = var.guaranteed_receive_reconnect_retry_count
guaranteed_receive_reconnect_retry_wait = var.guaranteed_receive_reconnect_retry_wait
guaranteed_receive_window_size = var.guaranteed_receive_window_size
guaranteed_receive_window_size_ack_threshold = var.guaranteed_receive_window_size_ack_threshold
guaranteed_send_ack_timeout = var.guaranteed_send_ack_timeout
guaranteed_send_window_size = var.guaranteed_send_window_size
messaging_default_delivery_mode = var.messaging_default_delivery_mode
messaging_default_dmq_eligible_enabled = var.messaging_default_dmq_eligible_enabled
messaging_default_eliding_eligible_enabled = var.messaging_default_eliding_eligible_enabled
messaging_jmsx_user_id_enabled = var.messaging_jmsx_user_id_enabled
messaging_text_in_xml_payload_enabled = var.messaging_text_in_xml_payload_enabled
transport_compression_level = var.transport_compression_level
transport_connect_retry_count = var.transport_connect_retry_count
transport_connect_retry_per_host_count = var.transport_connect_retry_per_host_count
transport_connect_timeout = var.transport_connect_timeout
transport_keepalive_count = var.transport_keepalive_count
transport_keepalive_enabled = var.transport_keepalive_enabled
transport_keepalive_interval = var.transport_keepalive_interval
transport_msg_callback_on_io_thread_enabled = var.transport_msg_callback_on_io_thread_enabled
transport_optimize_direct_enabled = var.transport_optimize_direct_enabled
transport_port = var.transport_port
transport_read_timeout = var.transport_read_timeout
transport_receive_buffer_size = var.transport_receive_buffer_size
transport_reconnect_retry_count = var.transport_reconnect_retry_count
transport_reconnect_retry_wait = var.transport_reconnect_retry_wait
transport_send_buffer_size = var.transport_send_buffer_size
transport_tcp_no_delay_enabled = var.transport_tcp_no_delay_enabled
}

12 changes: 12 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Output variable definitions

output "connection_factory" {
value = try(solacebroker_msg_vpn_jndi_connection_factory.main[0], null)
description = "The message broker provides an internal JNDI store for provisioned Connection Factory objects that clients can access through JNDI lookups."
}

output "xa_connection_factory" {
value = var.xa_enabled == true ? try(solacebroker_msg_vpn_jndi_connection_factory.main[0], null) : null
description = "The message broker provides an internal JNDI store for provisioned Connection Factory objects that clients can access through JNDI lookups."
}

12 changes: 12 additions & 0 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Terraform configuration

terraform {
required_providers {
solacebroker = {
source = "registry.terraform.io/solaceproducts/solacebroker"
# TODO: auto-update version
version = "~> 0.9"
}
}
}

Loading

0 comments on commit 3d9e80a

Please sign in to comment.