Skip to content

Commit 8c273b1

Browse files
authored
fix: include unofficial extensions<br>- NOTE: No upgrade path supported from previous versions (#56)
1 parent ece4c94 commit 8c273b1

File tree

32 files changed

+910
-24
lines changed

32 files changed

+910
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ crash.log
1818

1919
# Ignore files for local testing
2020
test.tf
21+
bootstrap_api_key.txt
2122

2223
# Ignore override files as they are usually used to override resources locally and so
2324
# are not checked in

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ are incomplete, may not be in final form and may generate unpredicatable failure
3737
* [terraform-ibm-mq-cloud](#terraform-ibm-mq-cloud)
3838
* [Submodules](./modules)
3939
* [application](./modules/application)
40+
* [experimental-api-key](./modules/experimental-api-key)
41+
* [experimental-certificate](./modules/experimental-certificate)
42+
* [experimental-connection](./modules/experimental-connection)
4043
* [keystore-certificate](./modules/keystore-certificate)
4144
* [mq-instance](./modules/mq-instance)
4245
* [queue-manager](./modules/queue-manager)
@@ -83,7 +86,7 @@ module "mq_on_cloud" {
8386
queue_manager_display_name = "queue-manager"
8487
queue_manager_name = "qm"
8588
queue_manager_size = "xsmall"
86-
queue_manager_version = "9.4.0_1"
89+
queue_manager_version = "9.4.0_3"
8790
8891
applications = {
8992
"application" = {
@@ -169,9 +172,9 @@ No resources.
169172

170173
| Name | Description | Type | Default | Required |
171174
|------|-------------|------|---------|:--------:|
172-
| <a name="input_applications"></a> [applications](#input\_applications) | A map of IBM MQ on Cloud applications to be created. | <pre>map(object({<br> name = string<br> }))</pre> | `{}` | no |
175+
| <a name="input_applications"></a> [applications](#input\_applications) | A map of IBM MQ on Cloud applications to be created. | <pre>map(object({<br/> name = string<br/> }))</pre> | `{}` | no |
173176
| <a name="input_existing_mq_capacity_crn"></a> [existing\_mq\_capacity\_crn](#input\_existing\_mq\_capacity\_crn) | The CRN of an existing capacity service instance, if not specifed, a new capacity plan will be created | `string` | `null` | no |
174-
| <a name="input_keystore_certificates"></a> [keystore\_certificates](#input\_keystore\_certificates) | A map of IBM MQ on Cloud keystore certificates to be created. | <pre>map(object({<br> certificate = string<br> label = string<br> }))</pre> | `{}` | no |
177+
| <a name="input_keystore_certificates"></a> [keystore\_certificates](#input\_keystore\_certificates) | A map of IBM MQ on Cloud keystore certificates to be created. | <pre>map(object({<br/> certificate = string<br/> label = string<br/> }))</pre> | `{}` | no |
175178
| <a name="input_name"></a> [name](#input\_name) | The name to give the MQ on Cloud instance. | `string` | n/a | yes |
176179
| <a name="input_queue_manager_display_name"></a> [queue\_manager\_display\_name](#input\_queue\_manager\_display\_name) | A displayable name for the queue manager. | `string` | n/a | yes |
177180
| <a name="input_queue_manager_location"></a> [queue\_manager\_location](#input\_queue\_manager\_location) | The location in which the queue manager will be deployed. Defaults to using the first location in the created service instance | `string` | `null` | no |
@@ -181,8 +184,8 @@ No resources.
181184
| <a name="input_region"></a> [region](#input\_region) | The region to provision the MQ on Cloud instance to. | `string` | n/a | yes |
182185
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The ID of the resource group to provision the MQ on Cloud instance to. | `string` | n/a | yes |
183186
| <a name="input_tags"></a> [tags](#input\_tags) | The list of resource tags that you want to associate with your MQ on Cloud instance. | `list(string)` | `[]` | no |
184-
| <a name="input_truststore_certificates"></a> [truststore\_certificates](#input\_truststore\_certificates) | A map of IBM MQ on Cloud truststore certificates to be created. | <pre>map(object({<br> certificate = string<br> label = string<br> }))</pre> | `{}` | no |
185-
| <a name="input_users"></a> [users](#input\_users) | A map of IBM MQ on Cloud users to be created. | <pre>map(object({<br> email = string<br> name = string<br> }))</pre> | `{}` | no |
187+
| <a name="input_truststore_certificates"></a> [truststore\_certificates](#input\_truststore\_certificates) | A map of IBM MQ on Cloud truststore certificates to be created. | <pre>map(object({<br/> certificate = string<br/> label = string<br/> }))</pre> | `{}` | no |
188+
| <a name="input_users"></a> [users](#input\_users) | A map of IBM MQ on Cloud users to be created. | <pre>map(object({<br/> email = string<br/> name = string<br/> }))</pre> | `{}` | no |
186189

187190
### Outputs
188191

examples/advanced/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module "mq_on_cloud" {
3232
queue_manager_display_name = "${var.prefix}-qm-display"
3333
queue_manager_name = "${local.prefix}_qm"
3434
queue_manager_size = "xsmall"
35-
queue_manager_version = "9.4.0_1"
35+
queue_manager_version = "9.4.0_3"
3636

3737
applications = {
3838
"app-${local.prefix}" = {

examples/basic/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module "mq_on_cloud" {
3232
queue_manager_display_name = "${var.prefix}-qm-display"
3333
queue_manager_name = "${local.prefix}_qm"
3434
queue_manager_size = "xsmall"
35-
queue_manager_version = "9.4.0_1"
35+
queue_manager_version = "9.4.0_3"
3636

3737
applications = {
3838
"app-${local.prefix}" = {

ibm_catalog.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
"required": true,
6666
"default_value": "us-east"
6767
},
68+
{
69+
"key": "resource_tags"
70+
},
6871
{
6972
"key": "prefix"
7073
},
@@ -107,6 +110,30 @@
107110
},
108111
{
109112
"key": "existing_queue_manager_name"
113+
},
114+
{
115+
"key": "application_name"
116+
},
117+
{
118+
"key": "existing_application_name"
119+
},
120+
{
121+
"key": "user_name"
122+
},
123+
{
124+
"key": "existing_user_name"
125+
},
126+
{
127+
"key": "user_email"
128+
},
129+
{
130+
"key": "existing_secrets_manager_crn"
131+
},
132+
{
133+
"key": "existing_secret_group_id"
134+
},
135+
{
136+
"key": "secret_group_name"
110137
}
111138
],
112139
"architecture": {

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module "mqcloud_instance" {
1717
name = var.name
1818
region = var.region
1919
resource_group_id = var.resource_group_id
20-
existing_mq_capacity_crn = local.capacity_crn
20+
existing_mq_capacity_crn = var.existing_mq_capacity_crn
2121
tags = var.tags
2222
}
2323

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# MQ on Cloud API Key
2+
3+
This is an experimental module to extend the [application module](../application). This module uses the application create_api_key_uri to return an application user name and password.
4+
5+
[Learn more](https://cloud.ibm.com/docs/mqcloud?topic=mqcloud-users_and_apps)
6+
7+
This module is problematic in some environments. A temporary step during the provisioning of the key writes to a file. This file has to be retained from one terraform command to another. This means pipeline environments, such as IBM Cloud schematics, which use a clean environment for each run will fail after the first apply.
8+
9+
### Usage
10+
11+
```hcl
12+
module "application_api_key" {
13+
source = "terraform-ibm-modules/mq-cloud/ibm//modules/experimental-api-key"
14+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
15+
ibmcloud_api_key = "IBM Cloud Api Key" # pragma: allowlist secret
16+
key_name = "my-application-key"
17+
href = module.<application>.href
18+
}
19+
```
20+
21+
<!-- The following content is automatically populated by the pre-commit hook -->
22+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
23+
### Requirements
24+
25+
| Name | Version |
26+
|------|---------|
27+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
28+
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 2.5.2 |
29+
30+
### Modules
31+
32+
No modules.
33+
34+
### Resources
35+
36+
| Name | Type |
37+
|------|------|
38+
| [terraform_data.bootstrap_api_key](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
39+
| [local_sensitive_file.bootstrap_api_key](https://registry.terraform.io/providers/hashicorp/local/latest/docs/data-sources/sensitive_file) | data source |
40+
41+
### Inputs
42+
43+
| Name | Description | Type | Default | Required |
44+
|------|-------------|------|---------|:--------:|
45+
| <a name="input_href"></a> [href](#input\_href) | The application href | `string` | n/a | yes |
46+
| <a name="input_ibmcloud_api_key"></a> [ibmcloud\_api\_key](#input\_ibmcloud\_api\_key) | The IBM Cloud API key to deploy resources. | `string` | n/a | yes |
47+
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | The name to give to the api key | `string` | n/a | yes |
48+
49+
### Outputs
50+
51+
| Name | Description |
52+
|------|-------------|
53+
| <a name="output_api_key"></a> [api\_key](#output\_api\_key) | MQ on Cloud application API key (sensitive) |
54+
| <a name="output_api_key_id"></a> [api\_key\_id](#output\_api\_key\_id) | MQ on Cloud application API key id |
55+
| <a name="output_api_key_name"></a> [api\_key\_name](#output\_api\_key\_name) | MQ on Cloud application API key name |
56+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Exit if any of the intermediate steps fail
4+
set -e
5+
6+
APIKEY=${1}
7+
KEYNAME=${2}
8+
HREF=${3}
9+
10+
BEARER=$(curl -X POST "https://iam.cloud.ibm.com/identity/token" --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey' --data-urlencode 'apikey='"${APIKEY}" 2>/dev/null | jq .access_token | sed 's/^"//' | sed 's/"$//') # pragma: allowlist secret
11+
12+
# shellcheck disable=SC2086
13+
KEY=$(curl -X POST --location --header "Authorization: Bearer ${BEARER}" --header "Accept: application/json" --header "Content-Type: application/json" --data '{ "name": "'${KEYNAME}'" }' "${HREF}" 2>/dev/null)
14+
15+
echo "${KEY}"

modules/experimental-api-key/main.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
##############################################################################
2+
# terraform-ibm-mq-cloud
3+
#
4+
# Create an MQ on Cloud application api key
5+
##############################################################################
6+
7+
locals {
8+
api_key_href = "${var.href}/api_key"
9+
}
10+
11+
# terraform_data is as a do-nothing container for arbitrary actions taken by a provisioner.
12+
# Redirect standard output to a file
13+
resource "terraform_data" "bootstrap_api_key" {
14+
triggers_replace = []
15+
16+
provisioner "local-exec" {
17+
command = "../../modules/experimental-api-key/curlly.sh \"${var.ibmcloud_api_key}\" \"${var.key_name}\" \"${local.api_key_href}\" > bootstrap_api_key.txt"
18+
}
19+
}
20+
21+
# Sensitively read output
22+
data "local_sensitive_file" "bootstrap_api_key" {
23+
filename = "bootstrap_api_key.txt"
24+
25+
depends_on = [resource.terraform_data.bootstrap_api_key]
26+
}
27+
28+
# Find values in JSON, retaining sensitive on api_key
29+
locals {
30+
api_key = regexall("(.*api_key\":\")([0-9a-zA-Z_]*)", data.local_sensitive_file.bootstrap_api_key.content)[0][1]
31+
api_key_id = nonsensitive(regexall("(.*api_key_id\":\")([0-9a-fApiKey-]*)", data.local_sensitive_file.bootstrap_api_key.content)[0][1])
32+
api_key_name = nonsensitive(regexall("(.*api_key_name\":\")([0-9a-zA-Z-_]*)", data.local_sensitive_file.bootstrap_api_key.content)[0][1])
33+
}

0 commit comments

Comments
 (0)