From 96c945da7ef5f96be57fd0d74d0df8dfd7b3f77e Mon Sep 17 00:00:00 2001 From: Balazs Czoma Date: Thu, 15 Feb 2024 07:02:27 -0500 Subject: [PATCH] Added general cf example --- README.md | 34 ++++++--------- examples/connection-factory/README.md | 53 ++++++++++++++++++++++++ examples/connection-factory/main.tf | 38 +++++++++++++++++ examples/connection-factory/providers.tf | 23 ++++++++++ 4 files changed, 126 insertions(+), 22 deletions(-) create mode 100644 examples/connection-factory/README.md create mode 100644 examples/connection-factory/main.tf create mode 100644 examples/connection-factory/providers.tf diff --git a/README.md b/README.md index 9fe41e5..fc0d26a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Full details are provided in the [Examples](#examples). 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](). +To configure JNDI managed objects (JNDI Topics and Queues) when provisioning a PubSub+ queue or topic endpoint, use the [Queues & Endpoint Module](). ## Module input variables @@ -31,7 +31,11 @@ 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)`. +The output provides reference to created resources. Any reference to a resource that has not been created will be set to `(null)`. + +Outputs: +* `connection_factory` - the connection factory created +* `xa_connection_factory` - an alternative reference to the `connection_factory` if an XA connection factory has been created ## Providers @@ -41,32 +45,18 @@ The output provides reference to created resources. Any reference for a resource ## 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 +The following table shows the resources created depending on the `xa_enabled` variable. "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 | +| Name | `false` or not specified | `true` | +|------|------|------| +| solacebroker_msg_vpn_jndi_connection_factory | X | 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) +- [Connection factory](examples/connection-factory) +- [XA connection factory](examples/xa-connection-factory) ## Module use recommendations diff --git a/examples/connection-factory/README.md b/examples/connection-factory/README.md new file mode 100644 index 0000000..6169eb4 --- /dev/null +++ b/examples/connection-factory/README.md @@ -0,0 +1,53 @@ +# Exclusive Queue Example + +Configuration in this directory creates a [connection factory](https://docs.solace.com/API/Solace-JMS-API/Connection-Factories.htm) on the PubSub+ event broker leveraging the JNDI Terraform module. + +## Module Configuration in the Example + +### Mandatory Inputs + +* `msg_vpn_name` - set to `default` in the example +* `connection_factory_name` - set to `/JNDI/CF/GettingStarted` in the example + +### Optional Inputs + +Optional module input variables have the same name as the attributes of the underlying provider resource. If omitted then the default for the related resource attribute will be configured on the broker. For attributes and defaults, refer to the [documentation of "solacebroker_msg_vpn_queue"](https://registry.terraform.io/providers/SolaceProducts/solacebroker/latest/docs/resources/msg_vpn_queue#optional). + +### Output + +The module `provisioned_connection_factory` output refers to the created connection factory. + +## Created resources + +This example will create following resources: + +* `solacebroker_msg_vpn_jndi_connection_factory` + +## Running the Example + +### Access to a PubSub+ broker + +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 + +Adjust the [provider parameters](https://registry.terraform.io/providers/SolaceProducts/solacebroker/latest/docs#schema) in `main.tf` according to your broker. The example configuration shows settings for a local broker running in Docker. + +### Create the resource + +Hint: You can verify configuration changes on the broker, before and after, using the [PubSub+ Broker Manager Web UI](https://docs.solace.com/Admin/Broker-Manager/PubSub-Manager-Overview.htm) + +Execute from this folder: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Run `terraform destroy` to clean up created resources when no longer needed. + +## Additional Documentation + +Refer to the [Connection Factories](https://docs.solace.com/API/Solace-JMS-API/Connection-Factories.htm) section in the PubSub+ documentation. + diff --git a/examples/connection-factory/main.tf b/examples/connection-factory/main.tf new file mode 100644 index 0000000..1afecd0 --- /dev/null +++ b/examples/connection-factory/main.tf @@ -0,0 +1,38 @@ +# Copyright 2024 Solace Corporation. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +provider "solacebroker" { + username = "admin" + password = "admin" + url = "http://localhost:8080" +} + +module "testcf" { + # update with the module location + source = "../.." + + msg_vpn_name = "default" + connection_factory_name = "/JNDI/CF/GettingStarted" + + # unless "xa_enabled" is specified and set to "true" the conection factory is non-XA + # xa_enabled = false +} + +output "provisioned_connection_factory" { + value = module.testcf.connection_factory + description = "The provisioned connection factory" +} + +# Note that for a non-XA connection factory the output module.testcf.xa_connection_factory is null + diff --git a/examples/connection-factory/providers.tf b/examples/connection-factory/providers.tf new file mode 100644 index 0000000..cf0d9af --- /dev/null +++ b/examples/connection-factory/providers.tf @@ -0,0 +1,23 @@ +# Copyright 2024 Solace Corporation. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Terraform configuration + +terraform { + required_providers { + solacebroker = { + source = "registry.terraform.io/solaceproducts/solacebroker" + } + } +}