Skip to content

Commit

Permalink
Added examples code
Browse files Browse the repository at this point in the history
  • Loading branch information
bczoma committed Mar 8, 2024
1 parent 2109fc2 commit 1859387
Show file tree
Hide file tree
Showing 16 changed files with 323 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/module-test-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ jobs:
- name: Test examples
run: |
shopt -s extglob
for d in examples/!(adding-headers)/; do (ci/scripts/test-module.sh "$d"); done
# ci/scripts/test-module.sh examples/adding-headers/ -var-file=secret.tfvars
for d in examples/!(basic-client-username)/; do (ci/scripts/test-module.sh "$d"); done
# ci/scripts/test-module.sh examples/basic-client-username/ -var-file=secret.tfvars
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Specific use case details are provided in the [Examples](#examples).

### Optional

* `password` - If using a client username to identify the client and configured basic authentication with internal database for the Message VPN, this variable provisions a password for authentication purposes.
* `password` - If using a client username to identify the client and configured basic authentication with internal database for the Message VPN, this variable provisions a password for authentication.
* `acl_profile_publish_topic_exceptions`, `acl_profile_subscribe_share_name_exceptions`, `acl_profile_subscribe_topic_exceptions`, `acl_profile_client_connect_exceptions` - A set of exceptions that may be added to the ACL profile, to support specific needs of the client.
* `client_username_attributes` - A set of attributes that may be defined in case of using a client username.

Expand Down Expand Up @@ -71,7 +71,7 @@ The following table shows the resources created for each `client_identifier_type

Refer to the following configuration examples:

- [Client username](examples/client-username)
- [Client username](examples/basic-client-username)
- [Client username attributes](examples/client-username-attributes)
- [Authorization group](examples/authorization-group)
- [ACL profile exeptions](examples/acl-profile-exceptions)
Expand Down
2 changes: 1 addition & 1 deletion ci/module-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ output "acl_profile_client_connect_exceptions" {
}

output "client_username_attributes" {
value = module.testclientusername.msg_vpn_client_username_attributes
value = module.testclientusername.client_username_attributes
}

module "testauthorizationgroup" {
Expand Down
2 changes: 1 addition & 1 deletion ci/template-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ output "acl_profile_client_connect_exceptions" {
}

output "client_username_attributes" {
value = module.testclientusername.msg_vpn_client_username_attributes
value = module.testclientusername.client_username_attributes
}

module "testauthorizationgroup" {
Expand Down
86 changes: 86 additions & 0 deletions examples/acl-profile-exceptions/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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 "testclient" {
source = "../.."

msg_vpn_name = "default"
client_identifier_type = "client_username"
client_name = "myclient"
client_profile_name = "default"
acl_profile_name = "default"

// The "default" ACL profile, used in the example, default actions are "allow", exceptions are "deny"

// example of multiple publish topic exceptions
acl_profile_publish_topic_exceptions = [
{
publish_topic_exception = "a/b/c* d/e/f",
publish_topic_exception_syntax = "smf"
},
{
publish_topic_exception = "g/h/i",
publish_topic_exception_syntax = "mqtt"
}
]

// example subscribe topic exception
acl_profile_subscribe_topic_exceptions = [
{
subscribe_topic_exception = "j/k/l",
subscribe_topic_exception_syntax = "smf"
}
]

// example subscribe share name exception
acl_profile_subscribe_share_name_exceptions = [
{
subscribe_share_name_exception = "share-test1",
subscribe_share_name_exception_syntax = "smf"
}
]

// example client connect exceptions
acl_profile_client_connect_exceptions = [ "192.0.2.0/24", "2001:db8::/32" ]

// No need to set enabled, it defaults to true
// enabled = true
}

output "client_username" {
value = module.testclient.client_username
sensitive = true
}

output "publish_topic_exceptions" {
value = module.testclient.acl_profile_publish_topic_exceptions
}

output "subscribe_topic_exceptions" {
value = module.testclient.acl_profile_subscribe_topic_exceptions
}

output "subscribe_share_name_exceptions" {
value = module.testclient.acl_profile_subscribe_share_name_exceptions
}

output "client_connect_exceptions" {
value = module.testclient.acl_profile_client_connect_exceptions
}
24 changes: 24 additions & 0 deletions examples/acl-profile-exceptions/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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"
}
}
required_version = "~> 1.2"
}
38 changes: 38 additions & 0 deletions examples/authorization-group/main.tf
Original file line number Diff line number Diff line change
@@ -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 "testauthgroup" {
source = "../.."

msg_vpn_name = "default"
client_identifier_type = "authorization_group"
client_name = "myauthgroup"
client_profile_name = "default"
acl_profile_name = "default"

// No need to set enabled, it defaults to true
// enabled = true
}

output "authorization_group" {
value = module.testauthgroup.authorization_group
sensitive = true
}

24 changes: 24 additions & 0 deletions examples/authorization-group/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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"
}
}
required_version = "~> 1.2"
}
41 changes: 41 additions & 0 deletions examples/basic-client-username/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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 "testclient" {
source = "../.."

msg_vpn_name = "default"
client_identifier_type = "client_username"
client_name = "myclient"
client_profile_name = "default"
acl_profile_name = "default"

// Configuring a password for the client_username
password = var.password

// No need to set enabled, it defaults to true
// enabled = true
}

output "client_username" {
value = module.testclient.client_username
sensitive = true
}

24 changes: 24 additions & 0 deletions examples/basic-client-username/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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"
}
}
required_version = "~> 1.2"
}
1 change: 1 addition & 0 deletions examples/basic-client-username/secret.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password = "mypassword"
4 changes: 4 additions & 0 deletions examples/basic-client-username/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "password" {
type = string
sensitive = true
}
49 changes: 49 additions & 0 deletions examples/client-username-attributes/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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 "testclient" {
source = "../.."

msg_vpn_name = "default"
client_identifier_type = "client_username"
client_name = "myclient"
client_profile_name = "default"
acl_profile_name = "default"

// Optional attributes example. One of the main use cases is client certificates authentication, no password is set here
client_username_attributes = [
{
attribute_name = "ou"
attribute_value = "Unit1"
}
]

// No need to set enabled, it defaults to true
// enabled = true
}

output "client_username" {
value = module.testclient.client_username
sensitive = true
}

output "attributes" {
value = module.testclient.client_username_attributes
}
24 changes: 24 additions & 0 deletions examples/client-username-attributes/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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"
}
}
required_version = "~> 1.2"
}
2 changes: 1 addition & 1 deletion internal/gen-template/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ output "acl_profile_client_connect_exceptions" {
value = try(solacebroker_msg_vpn_acl_profile_client_connect_exception.main, null)
}

output "msg_vpn_client_username_attributes" {
output "client_username_attributes" {
value = try(solacebroker_msg_vpn_client_username_attribute.main, null)
}

2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ output "acl_profile_client_connect_exceptions" {
description = "A Client Connect Exception is an exception to the default action to take when a client using the ACL Profile connects to the Message VPN. Exceptions must be expressed as an IP address/netmask in CIDR form"
}

output "msg_vpn_client_username_attributes" {
output "client_username_attributes" {
value = try(solacebroker_msg_vpn_client_username_attribute.main, null)
description = "A ClientUsername Attribute is a key+value pair that can be used to locate a client username, for example when using client certificate mapping"
}
Expand Down

0 comments on commit 1859387

Please sign in to comment.