Skip to content

Commit 7c7df61

Browse files
authored
feat: Module updates:<br>- added the ability to create multiple resource keys using new input resource_keys.<br>- The following module variables have been renamed:<br> - manager_key_name -> access_key_name<br> - manager_key_tags -> access_key_tags<br>The following module outputs have been renamed:<br> - manager_key_name -> access_key_name<br>- A new boolean disable_access_key_creation has been added to disable access key creation.<br><br>DA updates:<br>- Added the ability to create multiple resource keys using new input cloud_monitoring_resource_keys.<br>- A new boolean disable_access_key_creation has been added to disable access key creation. (#90)
1 parent 9b812b1 commit 7c7df61

File tree

12 files changed

+210
-44
lines changed

12 files changed

+210
-44
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-10-04T03:55:50Z",
6+
"generated_at": "2025-10-06T08:45:19Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,37 +160,41 @@ You need the following permissions to run this module.
160160
|------|------|
161161
| [ibm_resource_instance.cloud_monitoring](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_instance) | resource |
162162
| [ibm_resource_key.resource_key](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_key) | resource |
163+
| [ibm_resource_key.resource_keys](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_key) | resource |
163164
| [ibm_resource_tag.cloud_monitoring_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource |
164165

165166
### Inputs
166167

167168
| Name | Description | Type | Default | Required |
168169
|------|-------------|------|---------|:--------:|
170+
| <a name="input_access_key_name"></a> [access\_key\_name](#input\_access\_key\_name) | The name to give the default IBM Cloud Monitoring Manager access key. Use `disable_access_key_creation` to disable access key creation. For guidance on access keys, see [here](https://cloud.ibm.com/docs/monitoring?topic=monitoring-access_key). | `string` | `"SysdigManagerKey"` | no |
171+
| <a name="input_access_key_tags"></a> [access\_key\_tags](#input\_access\_key\_tags) | Tags associated with the IBM Cloud Monitoring access key. | `list(string)` | `[]` | no |
169172
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | Access Management Tags associated with the IBM Cloud Monitoring instance (Optional, array of strings). | `list(string)` | `[]` | no |
170173
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of context-based restrictions rules to create | <pre>list(object({<br/> description = string<br/> account_id = string<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |
174+
| <a name="input_disable_access_key_creation"></a> [disable\_access\_key\_creation](#input\_disable\_access\_key\_creation) | When set to true, disables the creation of a default manager access key which is required by agents to ingest metrics. | `bool` | `false` | no |
171175
| <a name="input_enable_platform_metrics"></a> [enable\_platform\_metrics](#input\_enable\_platform\_metrics) | Receive platform metrics in the provisioned IBM Cloud Monitoring instance. Only 1 instance in a given region can be enabled for platform metrics. | `bool` | `false` | no |
172176
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name of the IBM Cloud Monitoring instance to create. Defaults to 'cloud-monitoring-<region>' | `string` | `null` | no |
173-
| <a name="input_manager_key_name"></a> [manager\_key\_name](#input\_manager\_key\_name) | The name to give the IBM Cloud Monitoring manager key. | `string` | `"SysdigManagerKey"` | no |
174-
| <a name="input_manager_key_tags"></a> [manager\_key\_tags](#input\_manager\_key\_tags) | Tags associated with the IBM Cloud Monitoring manager key. | `list(string)` | `[]` | no |
175177
| <a name="input_plan"></a> [plan](#input\_plan) | The IBM Cloud Monitoring plan to provision. Available: lite, graduated-tier and graduated-tier-sysdig-secure-plus-monitor (available in region eu-fr2 only) | `string` | `"lite"` | no |
176178
| <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where Cloud Monitoring instance will be created. | `string` | `"us-south"` | no |
177179
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The id of the IBM Cloud resource group where the Cloud Monitoring instance will be created. | `string` | n/a | yes |
180+
| <a name="input_resource_keys"></a> [resource\_keys](#input\_resource\_keys) | A list of maps representing resource keys to create for the IBM Cloud Monitoring instance. Each entry defines a single resource key. Use this list to manage custom keys and handle key rotation. | <pre>list(object({<br/> name = string<br/> key_name = optional(string, null)<br/> generate_hmac_credentials = optional(bool, false) # pragma: allowlist secret<br/> role = optional(string, "Manager")<br/> service_id_crn = optional(string, null)<br/> }))</pre> | `[]` | no |
178181
| <a name="input_resource_tags"></a> [resource\_tags](#input\_resource\_tags) | Tags associated with the IBM Cloud Monitoring instance (Optional, array of strings). | `list(string)` | `[]` | no |
179182
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The type of the service endpoint that will be set for the Sisdig instance. | `string` | `"public-and-private"` | no |
180183

181184
### Outputs
182185

183186
| Name | Description |
184187
|------|-------------|
185-
| <a name="output_access_key"></a> [access\_key](#output\_access\_key) | The cloud monitoring access key for agents to use |
188+
| <a name="output_access_key"></a> [access\_key](#output\_access\_key) | The Cloud Monitoring access key for agents to use |
189+
| <a name="output_access_key_name"></a> [access\_key\_name](#output\_access\_key\_name) | The Cloud Monitoring access key name |
186190
| <a name="output_account_id"></a> [account\_id](#output\_account\_id) | The account id where cloud monitoring instance is provisioned. |
187191
| <a name="output_crn"></a> [crn](#output\_crn) | The id of the provisioned cloud monitoring instance. |
188192
| <a name="output_guid"></a> [guid](#output\_guid) | The guid of the provisioned cloud monitoring instance. |
189193
| <a name="output_ingestion_endpoint_private"></a> [ingestion\_endpoint\_private](#output\_ingestion\_endpoint\_private) | The Cloud Monitoring private ingestion endpoint. |
190194
| <a name="output_ingestion_endpoint_public"></a> [ingestion\_endpoint\_public](#output\_ingestion\_endpoint\_public) | The Cloud Monitoring public ingestion endpoint. |
191-
| <a name="output_manager_key_name"></a> [manager\_key\_name](#output\_manager\_key\_name) | The cloud monitoring manager key name |
192195
| <a name="output_name"></a> [name](#output\_name) | The name of the provisioned cloud monitoring instance. |
193196
| <a name="output_resource_group_id"></a> [resource\_group\_id](#output\_resource\_group\_id) | The resource group where cloud monitoring monitor instance resides |
197+
| <a name="output_resource_keys"></a> [resource\_keys](#output\_resource\_keys) | A list of maps representing resource keys created for the IBM Cloud Monitoring instance. |
194198
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
195199

196200
<!-- Leave this section as is so that your module has a link to local development environment set-up steps for contributors to follow -->

examples/advanced/outputs.tf

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,39 @@
99

1010
output "cloud_monitoring_crn" {
1111
value = module.cloud_monitoring.crn
12-
description = "The CRN of the provisioned IBM cloud monitoring instance."
12+
description = "The CRN of the provisioned IBM Cloud Monitoring instance."
1313
}
1414

1515
output "cloud_monitoring_guid" {
1616
value = module.cloud_monitoring.guid
17-
description = "The GUID of the provisioned IBM cloud monitoring instance."
17+
description = "The GUID of the provisioned IBM Cloud Monitoring instance."
1818
}
1919

2020
output "cloud_monitoring_name" {
2121
value = module.cloud_monitoring.name
22-
description = "The name of the provisioned IBM cloud monitoring instance."
22+
description = "The name of the provisioned IBM Cloud Monitoring instance."
2323
}
2424

2525
output "resource_group_id" {
2626
value = module.resource_group.resource_group_id
27-
description = "The resource group where cloud monitoring monitor instance resides."
27+
description = "The resource group where Cloud Monitoring monitor instance resides."
2828
}
2929

3030
output "access_key" {
3131
value = module.cloud_monitoring.access_key
32-
description = "The cloud monitoring access key for agents to use."
32+
description = "The Cloud Monitoring access key for agents to use."
3333
sensitive = true
3434
}
3535

36-
output "manager_key_name" {
37-
value = module.cloud_monitoring.manager_key_name
38-
description = "The cloud monitoring manager key name."
36+
output "access_key_name" {
37+
value = module.cloud_monitoring.access_key_name
38+
description = "The Cloud Monitoring access key name."
39+
}
40+
41+
output "cloud_monitoring_resource_keys" {
42+
value = module.cloud_monitoring.resource_keys
43+
description = "A list of maps containing resource keys created for the Cloud Monitoring instance."
44+
sensitive = true
3945
}
4046

4147
output "metrics_router_routes" {

examples/basic/outputs.tf

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@
44

55
output "cloud_monitoring_crn" {
66
value = module.cloud_monitoring.crn
7-
description = "The CRN of the provisioned IBM cloud monitoring instance."
7+
description = "The CRN of the provisioned IBM Cloud Monitoring instance."
88
}
99

1010
output "cloud_monitoring_name" {
1111
value = module.cloud_monitoring.name
12-
description = "The name of the provisioned IBM cloud monitoring instance."
12+
description = "The name of the provisioned IBM Cloud Monitoring instance."
1313
}
1414

1515
output "resource_group_id" {
1616
value = module.resource_group.resource_group_id
17-
description = "The resource group where cloud monitoring monitor instance resides."
17+
description = "The resource group where Cloud Monitoring monitor instance resides."
18+
}
19+
20+
output "cloud_monitoring_resource_keys" {
21+
value = module.cloud_monitoring.resource_keys
22+
description = "A list of maps containing resource keys created for the Cloud Monitoring instance."
23+
sensitive = true
24+
}
25+
26+
output "cloud_monitoring_access_key" {
27+
value = module.cloud_monitoring.access_key
28+
description = "The Cloud Monitoring access key for agents to use."
29+
sensitive = true
1830
}
1931

2032
output "ingestion_endpoint_private" {

ibm_catalog.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@
185185
}
186186
}
187187
},
188+
{
189+
"key": "cloud_monitoring_resource_keys",
190+
"type": "array",
191+
"custom_config": {
192+
"type": "code_editor",
193+
"grouping": "deployment",
194+
"original_grouping": "deployment"
195+
}
196+
},
197+
{
198+
"key": "disable_access_key_creation"
199+
},
188200
{
189201
"key": "enable_platform_metrics",
190202
"required": true

main.tf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,31 @@ resource "ibm_resource_tag" "cloud_monitoring_tag" {
3131
tag_type = "access"
3232
}
3333

34+
###############################################################################
35+
# Resource Key (Default Manager Key)
36+
###############################################################################
37+
3438
resource "ibm_resource_key" "resource_key" {
35-
name = var.manager_key_name
39+
count = var.disable_access_key_creation ? 0 : 1
40+
name = var.access_key_name
3641
resource_instance_id = ibm_resource_instance.cloud_monitoring.id
3742
role = "Manager"
38-
tags = var.manager_key_tags
43+
tags = var.access_key_tags
44+
}
45+
46+
###############################################################################
47+
# Resource Keys
48+
###############################################################################
49+
50+
resource "ibm_resource_key" "resource_keys" {
51+
for_each = { for key in var.resource_keys : key.name => key }
52+
name = each.value.key_name == null ? each.key : each.value.key_name
53+
resource_instance_id = ibm_resource_instance.cloud_monitoring.id
54+
role = each.value.role
55+
parameters = {
56+
"serviceid_crn" = each.value.service_id_crn
57+
"HMAC" = each.value.generate_hmac_credentials
58+
}
3959
}
4060

4161
########################################################################

outputs.tf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,22 @@ output "resource_group_id" {
2323
description = "The resource group where cloud monitoring monitor instance resides"
2424
}
2525

26-
output "access_key" {
27-
value = ibm_resource_key.resource_key.credentials["Sysdig Access Key"]
28-
description = "The cloud monitoring access key for agents to use"
26+
output "resource_keys" {
27+
description = "A list of maps representing resource keys created for the IBM Cloud Monitoring instance."
28+
value = ibm_resource_key.resource_keys
2929
sensitive = true
3030
}
3131

32-
output "manager_key_name" {
33-
value = ibm_resource_key.resource_key.name
34-
description = "The cloud monitoring manager key name"
32+
output "access_key_name" {
33+
value = !var.disable_access_key_creation ? ibm_resource_key.resource_key[0].name : null
34+
description = "The Cloud Monitoring access key name"
35+
}
36+
37+
# https://cloud.ibm.com/docs/monitoring?topic=monitoring-access_key
38+
output "access_key" {
39+
value = !var.disable_access_key_creation ? ibm_resource_key.resource_key[0].credentials["Sysdig Access Key"] : null
40+
description = "The Cloud Monitoring access key for agents to use"
41+
sensitive = true
3542
}
3643

3744
# https://cloud.ibm.com/docs/monitoring?topic=monitoring-endpoints#endpoints_ingestion

solutions/fully-configurable/DA-types.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Several optional input variables in the IBM Cloud [Cloud Monitoring instances de
44

55
* [IBM Cloud Metrics Router Routes](#metrics_router_routes) (`metrics_router_routes`)
66
* [Context Based Restrictions Rules](#cbr_rules) (`cbr_rules`)
7+
* [Cloud Monitoring Resource Keys](#cloud_monitoring_resource_keys) (`cloud_monitoring_resource_keys`)
78

89
## Metrics Router Routes <a name="metrics_router_routes"></a>
910

@@ -105,3 +106,45 @@ The `cbr_rules` input variable allows you to provide a rule for the target servi
105106
}
106107
]
107108
```
109+
110+
## Cloud Monitoring Resource Keys <a name="cloud_monitoring_resource_keys"></a>
111+
112+
The `cloud_monitoring_resource_keys` input variable allows you to provide a list of resource key to create that will be configured in the IBM Cloud Monitoring instance. In the configuration, specify the name of the resource key, whether HMAC credentials should be included, the Role of the key and an optional Service ID CRN to create with a Service ID. Refer [here](https://cloud.ibm.com/docs/monitoring?topic=monitoring-access_key) for more information.
113+
114+
* Variable name: `cloud_monitoring_resource_keys`.
115+
* Type: A list of objects that represent a resource key
116+
* Default value:
117+
118+
```
119+
{
120+
name = "SysdigManagerKey"
121+
generate_hmac_credentials = false
122+
role = "Manager"
123+
service_id_crn = null
124+
}
125+
```
126+
127+
### Options for cloud_monitoring_resource_keys
128+
129+
* `name` (required): A unique human-readable name that identifies this resource key.
130+
* `generate_hmac_credentials` (optional, default = `false`): Set to true to include HMAC keys in the resource key. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key#example-to-create-by-using-hmac).
131+
* `role` (optional, default = `Reader`): The name of the user role.
132+
* `service_id_crn` (optional, default = `null`): Pass a Service ID CRN to create credentials for a resource with a Service ID. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key#example-to-create-by-using-serviceid).
133+
134+
### Example route for Cloud Monitoring Resource Keys
135+
136+
The following example includes all the configuration options for two resource keys. One is a HMAC key with a `Reader` role, the other with an IAM key with `Manager` role.
137+
138+
```hcl
139+
[
140+
{
141+
"name": "icm-resource-key",
142+
"generate_hmac_credentials": true,
143+
"role": "Reader",
144+
},
145+
{
146+
"name": "icm-resource-key",
147+
"role": "Manager"
148+
}
149+
]
150+
```

solutions/fully-configurable/main.tf

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,19 @@ locals {
4444
}
4545

4646
module "cloud_monitoring" {
47-
count = local.create_cloud_monitoring ? 1 : 0
48-
source = "../.."
49-
resource_group_id = module.resource_group.resource_group_id
50-
region = var.region
51-
instance_name = local.cloud_monitoring_instance_name
52-
plan = var.cloud_monitoring_plan
53-
resource_tags = var.cloud_monitoring_resource_tags
54-
access_tags = var.cloud_monitoring_access_tags
55-
service_endpoints = "public-and-private"
56-
enable_platform_metrics = var.enable_platform_metrics
57-
cbr_rules = var.cbr_rules
47+
count = local.create_cloud_monitoring ? 1 : 0
48+
source = "../.."
49+
resource_group_id = module.resource_group.resource_group_id
50+
region = var.region
51+
instance_name = local.cloud_monitoring_instance_name
52+
plan = var.cloud_monitoring_plan
53+
resource_tags = var.cloud_monitoring_resource_tags
54+
access_tags = var.cloud_monitoring_access_tags
55+
resource_keys = var.cloud_monitoring_resource_keys
56+
disable_access_key_creation = var.disable_access_key_creation
57+
service_endpoints = "public-and-private"
58+
enable_platform_metrics = var.enable_platform_metrics
59+
cbr_rules = var.cbr_rules
5860
}
5961

6062
module "metrics_routing" {

solutions/fully-configurable/outputs.tf

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,38 @@ output "resource_group_id" {
1515

1616
output "cloud_monitoring_crn" {
1717
value = local.cloud_monitoring_crn
18-
description = "The id of the provisioned IBM cloud monitoring instance."
18+
description = "The id of the provisioned IBM Cloud Monitoring instance."
1919
}
2020
output "cloud_monitoring_name" {
2121
value = local.create_cloud_monitoring ? module.cloud_monitoring[0].name : null
22-
description = "The name of the provisioned IBM cloud monitoring instance."
22+
description = "The name of the provisioned IBM Cloud Monitoring instance."
2323
}
2424

2525
output "cloud_monitoring_guid" {
2626
value = local.create_cloud_monitoring ? module.cloud_monitoring[0].guid : module.existing_cloud_monitoring_crn_parser[0].service_instance
27-
description = "The guid of the provisioned IBM cloud monitoring instance."
27+
description = "The guid of the provisioned IBM Cloud Monitoring instance."
28+
}
29+
30+
output "cloud_monitoring_access_key_name" {
31+
value = local.create_cloud_monitoring ? module.cloud_monitoring[0].access_key_name : null
32+
description = "The name of the IBM Cloud Monitoring access key for agents to use"
2833
}
2934

3035
output "cloud_monitoring_access_key" {
3136
value = local.create_cloud_monitoring ? module.cloud_monitoring[0].access_key : null
32-
description = "IBM cloud monitoring access key for agents to use"
37+
description = "The IBM Cloud Monitoring access key for agents to use"
38+
sensitive = true
39+
}
40+
41+
output "cloud_monitoring_resource_keys" {
42+
value = local.create_cloud_monitoring ? module.cloud_monitoring[0].resource_keys : null
43+
description = "A list of maps representing resource keys created for the IBM Cloud Monitoring instance."
3344
sensitive = true
3445
}
3546

3647
output "account_id" {
3748
value = local.create_cloud_monitoring ? module.cloud_monitoring[0].account_id : module.existing_cloud_monitoring_crn_parser[0].account_id
38-
description = "The account id where cloud monitoring instance is provisioned."
49+
description = "The account id where Cloud Monitoring instance is provisioned."
3950
}
4051

4152
# https://cloud.ibm.com/docs/monitoring?topic=monitoring-endpoints#endpoints_ingestion

0 commit comments

Comments
 (0)