Skip to content

Commit

Permalink
Experimental support for additional queue binding
Browse files Browse the repository at this point in the history
  • Loading branch information
bczoma committed Feb 28, 2024
1 parent 7e0ef7d commit bd15dbd
Show file tree
Hide file tree
Showing 14 changed files with 305 additions and 74 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
84 changes: 84 additions & 0 deletions examples/append-queue-binding-to-existing-rdp/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
provider "solacebroker" {
username = "admin"
password = "admin"
url = "http://localhost:8080"
}

resource "solacebroker_msg_vpn_queue" "myqueue" {
msg_vpn_name = "default"
queue_name = "my_queue"
permission = "consume"
ingress_enabled = true
egress_enabled = true
}

resource "solacebroker_msg_vpn_queue" "myqueue2" {
msg_vpn_name = "default"
queue_name = "my_queue2"
permission = "consume"
ingress_enabled = true
egress_enabled = true
}

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

msg_vpn_name = "default"
queue_name = solacebroker_msg_vpn_queue.myqueue.queue_name
url = "http://example.com/$${msgId()}"
rest_delivery_point_name = "my_rdp"
request_headers = [
{
header_name = "header1"
header_value = "$${uuid()}"
},
{
header_name = "header2"
header_value = "value2"
}
]
}

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

msg_vpn_name = "default"
queue_name = solacebroker_msg_vpn_queue.myqueue2.queue_name
url = "http://example.com/$${msgId()}2"
rest_delivery_point_name = module.testrdp.rest_delivery_point.rest_delivery_point_name
append_queue_binding_to_existing_rdp = true
request_headers = module.testrdp.request_headers
}

output "rdp" {
value = module.testrdp.rest_delivery_point
}

output "consumer" {
value = module.testrdp.rest_consumer
sensitive = true
}

output "queue_binding" {
value = module.testrdp.queue_binding
}

output "request_headers" {
value = module.testrdp.request_headers
}

resource "solacebroker_msg_vpn_rest_delivery_point_queue_binding_protected_request_header" "test" {
msg_vpn_name = module.testrdp.rest_delivery_point.msg_vpn_name
rest_delivery_point_name = module.testrdp.rest_delivery_point.rest_delivery_point_name
queue_binding_name = module.testrdp.queue_binding.queue_binding_name
header_name = "protected_header1"
header_value = "protected_value1"
}

resource "solacebroker_msg_vpn_rest_delivery_point_queue_binding_protected_request_header" "test2" {
msg_vpn_name = module.testrdp.rest_delivery_point.msg_vpn_name
rest_delivery_point_name = module.testrdp.rest_delivery_point.rest_delivery_point_name
queue_binding_name = module.testrdp2.queue_binding.queue_binding_name
header_name = "protected_header1"
header_value = "protected_value1"
}
10 changes: 10 additions & 0 deletions examples/append-queue-binding-to-existing-rdp/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"
}
86 changes: 64 additions & 22 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,35 +1,77 @@
# 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 = "../.."
resource "solacebroker_msg_vpn_queue" "myqueue" {
msg_vpn_name = "default"
queue_name = "my_queue"
permission = "consume"
}

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

msg_vpn_name = "default"
connection_factory_name = "/JNDI/CF/GettingStarted"
queue_name = solacebroker_msg_vpn_queue.myqueue.queue_name
url = "http://example.com/$${msgId()}"
rest_delivery_point_name = "my_rdp"
request_headers = [
{
header_name = "header1"
header_value = "$${uuid()}"
},
{
header_name = "header2"
header_value = "value2"
}
]
oauth_jwt_claims = [
{
oauth_jwt_claim_name = "scope"
oauth_jwt_claim_value = "\"https://www.googleapis.com/auth/pubsub\""
},
{
oauth_jwt_claim_name = "aud"
oauth_jwt_claim_value = "\"https://www.googleapis.com/oauth2/v4/token\""
},
{
oauth_jwt_claim_name = "iss"
oauth_jwt_claim_value = "\"111400995554822290197\""
},
{
oauth_jwt_claim_name = "sub"
oauth_jwt_claim_value = "\"111400995554822290197\""
}
]
}

output "rdp" {
value = module.testrdp.rest_delivery_point
}

output "consumer" {
value = module.testrdp.rest_consumer
sensitive = true
}

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

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

output "oauth_jwt_claims" {
value = module.testrdp.oauth_jwt_claims
}

resource "solacebroker_msg_vpn_rest_delivery_point_queue_binding_protected_request_header" "test" {
msg_vpn_name = module.testrdp.rest_delivery_point.msg_vpn_name
rest_delivery_point_name = module.testrdp.rest_delivery_point.rest_delivery_point_name
queue_binding_name = module.testrdp.queue_binding.queue_binding_name
header_name = "protected_header1"
header_value = "protected_value1"
}
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"
}
80 changes: 80 additions & 0 deletions examples/oauth-jwt-claims-workaround/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
provider "solacebroker" {
username = "admin"
password = "admin"
url = "http://localhost:8080"
}

resource "solacebroker_msg_vpn_queue" "myqueue" {
msg_vpn_name = "default"
queue_name = "my_queue"
permission = "consume"
ingress_enabled = true
egress_enabled = true
}

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

msg_vpn_name = "default"
queue_name = solacebroker_msg_vpn_queue.myqueue.queue_name
url = "http://example.com/$${msgId()}"
rest_delivery_point_name = "my_rdp"
enabled = var.enabled
request_headers = [
{
header_name = "header1"
header_value = "$${uuid()}"
},
{
header_name = "header2"
header_value = "value2"
}
]
oauth_jwt_claims = [
{
oauth_jwt_claim_name = "scope"
oauth_jwt_claim_value = "\"https://www.googleapis.com/auth/pubsub\""
},
{
oauth_jwt_claim_name = "aud"
oauth_jwt_claim_value = "\"https://www.googleapis.com/oauth2/v4/token\""
},
{
oauth_jwt_claim_name = "iss"
oauth_jwt_claim_value = "\"111400995554822290197\""
},
{
oauth_jwt_claim_name = "sub"
oauth_jwt_claim_value = "\"111400995554822290197\""
}
]
}

output "rdp" {
value = module.testrdp.rest_delivery_point
}

output "consumer" {
value = module.testrdp.rest_consumer
sensitive = true
}

output "queue_binding" {
value = module.testrdp.queue_binding
}

output "request_headers" {
value = module.testrdp.request_headers
}

output "oauth_jwt_claims" {
value = module.testrdp.oauth_jwt_claims
}

resource "solacebroker_msg_vpn_rest_delivery_point_queue_binding_protected_request_header" "test" {
msg_vpn_name = module.testrdp.rest_delivery_point.msg_vpn_name
rest_delivery_point_name = module.testrdp.rest_delivery_point.rest_delivery_point_name
queue_binding_name = module.testrdp.queue_binding.queue_binding_name
header_name = "protected_header1"
header_value = "protected_value1"
}
10 changes: 10 additions & 0 deletions examples/oauth-jwt-claims-workaround/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"
}
5 changes: 5 additions & 0 deletions examples/oauth-jwt-claims-workaround/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "enabled" {
type = bool
description = "Enable or disable the module"
default = true
}
24 changes: 14 additions & 10 deletions internal/gen-template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ locals {
}

resource "solacebroker_msg_vpn_rest_delivery_point" "main" {
count = var.append_queue_binding_to_existing_rdp ? 0 : 1

msg_vpn_name = var.msg_vpn_name
rest_delivery_point_name = var.rest_delivery_point_name
enabled = var.enabled
Expand All @@ -16,9 +18,11 @@ resource "solacebroker_msg_vpn_rest_delivery_point" "main" {
}

resource "solacebroker_msg_vpn_rest_delivery_point_rest_consumer" "main" {
msg_vpn_name = solacebroker_msg_vpn_rest_delivery_point.main.msg_vpn_name
rest_delivery_point_name = solacebroker_msg_vpn_rest_delivery_point.main.rest_delivery_point_name
enabled = solacebroker_msg_vpn_rest_delivery_point.main.enabled
count = var.append_queue_binding_to_existing_rdp ? 0 : 1

msg_vpn_name = solacebroker_msg_vpn_rest_delivery_point.main[0].msg_vpn_name
rest_delivery_point_name = solacebroker_msg_vpn_rest_delivery_point.main[0].rest_delivery_point_name
enabled = solacebroker_msg_vpn_rest_delivery_point.main[0].enabled
rest_consumer_name = var.rest_consumer_name != null ? var.rest_consumer_name : "consumer"
remote_host = local.host
remote_port = local.port
Expand All @@ -28,8 +32,8 @@ resource "solacebroker_msg_vpn_rest_delivery_point_rest_consumer" "main" {
}

resource "solacebroker_msg_vpn_rest_delivery_point_queue_binding" "main" {
msg_vpn_name = solacebroker_msg_vpn_rest_delivery_point.main.msg_vpn_name
rest_delivery_point_name = solacebroker_msg_vpn_rest_delivery_point.main.rest_delivery_point_name
msg_vpn_name = var.append_queue_binding_to_existing_rdp ? var.msg_vpn_name : solacebroker_msg_vpn_rest_delivery_point.main[0].msg_vpn_name
rest_delivery_point_name = var.append_queue_binding_to_existing_rdp ? var.rest_delivery_point_name : solacebroker_msg_vpn_rest_delivery_point.main[0].rest_delivery_point_name
queue_binding_name = var.queue_name
post_request_target = local.path

Expand All @@ -40,8 +44,8 @@ resource "solacebroker_msg_vpn_rest_delivery_point_queue_binding_request_header"

for_each = {for v in var.request_headers : v.header_name => v}

msg_vpn_name = solacebroker_msg_vpn_rest_delivery_point.main.msg_vpn_name
rest_delivery_point_name = solacebroker_msg_vpn_rest_delivery_point.main.rest_delivery_point_name
msg_vpn_name = var.append_queue_binding_to_existing_rdp ? var.msg_vpn_name : solacebroker_msg_vpn_rest_delivery_point.main[0].msg_vpn_name
rest_delivery_point_name = var.append_queue_binding_to_existing_rdp ? var.rest_delivery_point_name : solacebroker_msg_vpn_rest_delivery_point.main[0].rest_delivery_point_name
queue_binding_name = solacebroker_msg_vpn_rest_delivery_point_queue_binding.main.queue_binding_name

header_name = each.value.header_name
Expand All @@ -51,9 +55,9 @@ resource "solacebroker_msg_vpn_rest_delivery_point_queue_binding_request_header"
resource "solacebroker_msg_vpn_rest_delivery_point_rest_consumer_oauth_jwt_claim" "main" {
for_each = {for v in var.oauth_jwt_claims : v.oauth_jwt_claim_name => v}

msg_vpn_name = solacebroker_msg_vpn_rest_delivery_point.main.msg_vpn_name
rest_delivery_point_name = solacebroker_msg_vpn_rest_delivery_point.main.rest_delivery_point_name
rest_consumer_name = solacebroker_msg_vpn_rest_delivery_point_rest_consumer.main.rest_consumer_name
msg_vpn_name = solacebroker_msg_vpn_rest_delivery_point.main[0].msg_vpn_name
rest_delivery_point_name = solacebroker_msg_vpn_rest_delivery_point.main[0].rest_delivery_point_name
rest_consumer_name = solacebroker_msg_vpn_rest_delivery_point_rest_consumer.main[0].rest_consumer_name

oauth_jwt_claim_name = each.value.oauth_jwt_claim_name
oauth_jwt_claim_value = each.value.oauth_jwt_claim_value
Expand Down
Loading

0 comments on commit bd15dbd

Please sign in to comment.