Skip to content

Commit

Permalink
Added basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
bczoma committed Feb 28, 2024
1 parent 7e0ef7d commit 201bcd5
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# .tfstate files
*.tfstate
*.tfstate.*
*.lock.hcl

# Crash log files
crash.log
Expand Down
47 changes: 22 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Terraform module to support the setup of a [REST consumer](https://docs.solace.com/API/REST/REST-Consumers.htm) on the [Solace PubSub+ Event Broker](https://solace.com/products/event-broker/).

Given a queue, as a destination for messages to be forwarded to a REST consumer application, this module configures a [REST delivery point](https://docs.solace.com/API/REST/REST-Consumers.htm#_Toc433874658) between the queue and the application.
Given a queue on the broker, as a destination for messages to be forwarded to a REST consumer application, this module configures a [REST delivery point](https://docs.solace.com/API/REST/REST-Consumers.htm#_Toc433874658) between the queue and the application.

Specific use case details are provided in the [Examples](#examples).

Expand All @@ -11,18 +11,18 @@ Specific use case details are provided in the [Examples](#examples).
### Required

* `msg_vpn_name` - REST delivery points are specific to a Message VPN on the broker.
* `url` - The REST consumer destination URL including base URL and endpoint path. The path portion of the URL may contain [substitution expressions](https://docs.solace.com/Messaging/Substitution-Expressions-Overview.htm).
* `rest_delivery_point_name` - The name of the REST delivery point to be created.
* `url` - The REST consumer destination URL including base URL and endpoint path. The path portion of the URL may contain [substitution expressions](https://docs.solace.com/Messaging/Substitution-Expressions-Overview.htm).
* `queue_name` - The name of the queue to bind to.

Important: The REST Delivery Point must have permission to consume messages from the queue — to achieve this, the queue’s owner must be set to `#rdp/<rest_delivery_point_name>` or the queue’s permissions for non-owner clients must be set to at least `consume` level access.
Important: The REST delivery point must have permission to consume messages from the queue — to achieve this, the queue’s owner must be set to `#rdp/<rest_delivery_point_name>` or the queue’s permissions for non-owner clients must be set to at least `consume` level access. Queue ingress and egress must also be enabled.


### Optional

* `rest_consumer_name` - The name of the REST consumer to be created. The default is `consumer`.
* `request_headers` - A set of request headers to be added to the HTTP request
* `oauth_jwt_claims` - A set of additional claims to be added to the JWT sent to the OAuth token request endpoint
* `rest_consumer_name` - The name of the REST consumer to be created. The default is `consumer`.

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

Expand All @@ -36,7 +36,7 @@ Additional optional module variables names are the same as the underlying resour

Most optional variables' default value is `null`, meaning that if not provided then the resource default value will be provisioned on the broker.

-> The module default for the `enabled` optional variables is `true`, which differ from the resource attribute defaults.
-> The module default for the `enabled` optional variable is `true`, which differ from the resource attribute default.

## Module outputs

Expand All @@ -50,32 +50,28 @@ Most optional variables' default value is `null`, meaning that if not provided t

## 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. "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 | |
|------|------|
| solacebroker_msg_vpn_rest_delivery_point | X |
| solacebroker_msg_vpn_rest_delivery_point_rest_consumer | X |
| solacebroker_msg_vpn_rest_delivery_point_queue_binding | X |
| solacebroker_msg_vpn_rest_delivery_point_queue_binding_request_header | O |
| solacebroker_msg_vpn_rest_delivery_point_rest_consumer_oauth_jwt_claim | O |

## 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)
- [Basic](examples/basic)
- [Substitution Expressions](examples/using-substitution-expressions)
- [Adding protected headers](examples/adding-protected-headers)
- [Multiple queue bindings](examples/multiple-queue-bindings)
- [Adding JWT claims (workaround)](examples/adding-oauth-jwt-claims-workaround)
- [Amazon AWS consumer](examples/aws)
- [Microsoft Azure consumer](examples/azure)
- [Google Cloud consumer](examples/gcp)

## Module use recommendations

Expand All @@ -86,6 +82,7 @@ This module is expected to be used primarily by application teams. It supports p
For more information about Solace technology in general please visit these resources:

- Solace [Technical Documentation](https://docs.solace.com/)
- [Managing REST Delivery Points](https://docs.solace.com/Services/Managing-RDPs.htm)
- 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/).
24 changes: 17 additions & 7 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
# Connection Factory Example
# Basic REST Delivery Configuration Example

Configuration in this directory creates a [connection factory](https://docs.solace.com/API/Solace-JMS-API/Connection-Factories.htm) object in the JNDI store on the PubSub+ event broker, leveraging the JNDI Terraform module.
Configuration in this directory creates a [connection factory](https://docs.solace.com/API/Solace-JMS-API/Connection-Factories.htm) object in the JNDI store on the PubSub+ event broker, leveraging the Rest Delivery 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
* `rest_delivery_point_name`
* `url` - set to `https://example.com/test` in the example. Note that it includes the endpoint path
* `queue_name` - the name of an existing queue to bind to

Important: The REST delivery point must have permission to consume messages from the queue — to achieve this, the queue’s owner must be set to `#rdp/<rest_delivery_point_name>` or the queue’s permissions for non-owner clients must be set to at least `consume` level access. Queue ingress and egress must also be enabled.

### 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).

The module default for the `enabled` variable is true, which enables both the RDP and the REST consumer resources.

### Output

The module `provisioned_connection_factory` output refers to the created connection factory.
The module `rdp` output refers to the created REST delivery point.

## Created resources

This example will create following resources:

* `solacebroker_msg_vpn_jndi_connection_factory`
* `solacebroker_msg_vpn_queue` (created before the module, as pre-requisite)
</br></br>
* `solacebroker_msg_vpn_rest_delivery_point`
* `solacebroker_msg_vpn_rest_delivery_point_rest_consumer`
* `solacebroker_msg_vpn_rest_delivery_point_queue_binding`

## Running the Example

Expand All @@ -34,7 +44,7 @@ If you don't already have access to a broker, refer to the [Developers page](htt
The sample is available from the module GitHub repo:

```bash
git clone https://github.com/SolaceProducts/terraform-solacebroker-jndi.git
git clone https://github.com/SolaceProducts/terraform-solacebroker-rest-delivery.git
cd examples/basic
```

Expand All @@ -58,4 +68,4 @@ 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.
Refer to the [Managing REST Delivery Points](https://docs.solace.com/Services/Managing-RDPs.htm) section in the PubSub+ documentation.
63 changes: 41 additions & 22 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
# 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 = "../.."
# The RDP requires a queue to bind to.
# Recommended: Use the queue-endpoint module to create the queue
# TODO: Uncomment the following block and replace the resource block once the queue-endpoint module is available
# module "rdp_queue" {
# source = SolaceProducts/queue-endpoint/solacebroker
#
# msg_vpn_name = "default"
# endpoint_type = "queue"
# endpoint_name = "my_queue"
#
# # The REST delivery point must have permission to consume messages from the queue
# # — to achieve this, either the queue’s owner must be set to `#rdp/<rest_delivery_point_name>`
# # owner = "#rdp/my_rdp"
# # or the queue’s permissions for non-owner clients must be set to at least `consume` level access
# permission = "consume"
#
# # The queue must also be enabled for ingress and egress, which is the default for the rdp_queue module
# }
resource "solacebroker_msg_vpn_queue" "rdp_queue" {
msg_vpn_name = "default"
queue_name = "my_queue"
permission = "consume"
ingress_enabled = true
egress_enabled = true
}

module "testrdp" {
source = "../.."

msg_vpn_name = "default"
connection_factory_name = "/JNDI/CF/GettingStarted"
rest_delivery_point_name = "basic_rdp"
url = "https://example.com/test"
# queue_name = module.rdp_queue.queue.queue_name
queue_name = solacebroker_msg_vpn_queue.rdp_queue.queue_name
}

output "provisioned_connection_factory" {
value = module.testcf.connection_factory
description = "The provisioned connection factory"
output "rdp" {
value = module.testrdp.rest_delivery_point
}

# Note that for a non-XA connection factory the output module.testcf.xa_connection_factory is null
output "consumer" {
value = module.testrdp.rest_consumer
sensitive = true
}

output "queue_binding" {
value = module.testrdp.queue_binding
}
15 changes: 1 addition & 14 deletions examples/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# 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 {
Expand All @@ -20,4 +6,5 @@ terraform {
source = "registry.terraform.io/solaceproducts/solacebroker"
}
}
required_version = "~> 1.2"
}

0 comments on commit 201bcd5

Please sign in to comment.