diff --git a/.secrets.baseline b/.secrets.baseline index 272a07e..534dd20 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.sum|^.secrets.baseline$", "lines": null }, - "generated_at": "2024-10-24T08:11:07Z", + "generated_at": "2024-12-13T09:23:32Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -82,7 +82,7 @@ "hashed_secret": "49901d945ad6da0f0af47691f305daf994d9d2c9", "is_secret": false, "is_verified": false, - "line_number": 57, + "line_number": 59, "type": "Secret Keyword", "verified_result": null } diff --git a/README.md b/README.md index bb223aa..39a67ef 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ This module supports provisioning the following observability services: * Use IBM Cloud® Activity Tracker Event Routing to configure how to route auditing events, both global and location-based event data, in your IBM Cloud. Supports routing to the following target types: `IBM Cloud Object Storage (COS)`, `IBM Cloud Logs`, and `IBM® Event Streams for IBM Cloud®`. * **IBM Cloud Monitoring with Cloud Monitoring** * Monitor the health of services and applications in IBM Cloud. +* **IBM Cloud Metrics Routing** + * Use IBM Cloud® Metrics Routing to configure the routing of platform metrics generated in your IBM Cloud account. Supports routing to `IBM Cloud Monitoring` target. @@ -110,7 +112,7 @@ module "observability_instances" { { action = "send" targets = [{ - id = module.observability_instances.metrics_router_targets["my-mr-target].id + id = module.observability_instances.metrics_router_targets["my-mr-target"].id }] inclusion_filters = [{ operand = "location" @@ -198,9 +200,9 @@ No resources. | [enable\_platform\_metrics](#input\_enable\_platform\_metrics) | Receive platform metrics in the provisioned IBM Cloud Monitoring instance. | `bool` | `true` | no | | [global\_event\_routing\_settings](#input\_global\_event\_routing\_settings) | Global settings for event routing |
object({| `null` | no | | [logs\_routing\_tenant\_regions](#input\_logs\_routing\_tenant\_regions) | Pass a list of regions to create a tenant for that is targetted to the Cloud Logs instance created by this module. To manage platform logs that are generated by IBM Cloud® services in a region of IBM Cloud, you must create a tenant in each region that you operate. Leave the list empty if you don't want to create any tenants. | `list(any)` | `[]` | no | -| [metrics\_router\_routes](#input\_metrics\_router\_routes) | List of routes for IBM Metrics Router. |
default_targets = optional(list(string), [])
metadata_region_primary = string
metadata_region_backup = optional(string)
permitted_target_regions = list(string)
private_api_endpoint_only = optional(bool, false)
})
list(object({| `[]` | no | -| [metrics\_router\_settings](#input\_metrics\_router\_settings) | Global settings for Metrics Routing. |
name = string
rules = list(object({
action = string
targets = list(object({
id = string
}))
inclusion_filters = list(object({
operand = string
operator = string
values = list(string)
}))
}))
}))
object({| `null` | no | -| [metrics\_router\_targets](#input\_metrics\_router\_targets) | List of Metrics Router targets to be created. |
default_targets = list(object({
id = string
}))
permitted_target_regions = list(string)
primary_metadata_region = string
backup_metadata_region = string
private_api_endpoint_only = bool
})
list(object({| `[]` | no | +| [metrics\_router\_routes](#input\_metrics\_router\_routes) | List of routes for IBM Metrics Router. |
destination_crn = string
target_name = string
target_region = string
skip_mrouter_sysdig_iam_auth_policy = optional(bool, false)
}))
list(object({| `[]` | no | +| [metrics\_router\_settings](#input\_metrics\_router\_settings) | Global settings for Metrics Routing. |
name = string
rules = list(object({
action = optional(string, "send")
targets = optional(list(object({
id = string
})))
inclusion_filters = list(object({
operand = string
operator = string
values = list(string)
}))
}))
}))
object({| `null` | no | +| [metrics\_router\_targets](#input\_metrics\_router\_targets) | List of Metrics Router targets to be created. |
default_targets = optional(list(object({
id = string
})))
permitted_target_regions = optional(list(string))
primary_metadata_region = optional(string)
backup_metadata_region = optional(string)
private_api_endpoint_only = optional(bool, false)
})
list(object({| `[]` | no | | [region](#input\_region) | The IBM Cloud region where instances will be created. | `string` | `"us-south"` | no | | [resource\_group\_id](#input\_resource\_group\_id) | The id of the IBM Cloud resource group where the instance(s) will be created. | `string` | `null` | no | | [skip\_logs\_routing\_auth\_policy](#input\_skip\_logs\_routing\_auth\_policy) | Whether to create an IAM authorization policy that permits Logs Routing Sender access to the IBM Cloud Logs. | `bool` | `false` | no | diff --git a/modules/metrics_routing/README.md b/modules/metrics_routing/README.md index 9372712..b0c5397 100644 --- a/modules/metrics_routing/README.md +++ b/modules/metrics_routing/README.md @@ -1,9 +1,12 @@ -# Metric Router module +# Metrics Router module This module supports provisioning the following: -* **IBM Cloud Metric Routing** - * Use IBM Cloud® Metrics Routing to configure the routing of platform metrics generated in your IBM Cloud account. IBM Cloud Metrics Routing is a platform service, to manage platform metrics at the account-level by configuring targets and routes that define where data points are routed. +* **IBM Cloud Metrics Routing** + * Use IBM Cloud® Metrics Routing to configure the routing of platform metrics generated in your IBM Cloud account. + * IBM Cloud Metrics Routing is a platform service, to manage platform metrics at the account-level by configuring targets and routes that define where data points are routed. + * IBM Cloud Metrics Routing actively manages metrics generated by MR enabled services. Visit [here](https://cloud.ibm.com/docs/metrics-router?topic=metrics-router-cloud-services-mr) to see the list of services that have adopted IBM Cloud Metrics Routing. + * IBM Cloud Metrics Routing can only route metrics that are generated in [supported regions](https://cloud.ibm.com/docs/metrics-router?topic=metrics-router-regions). In regions where IBM Cloud Metrics Routing is unavailable, metrics continue to be collected and managed using the Monitoring service. ## Usage @@ -47,7 +50,7 @@ module "metric_router" { { action = "send" targets = [{ - id = module.observability_instances.metrics_router_targets["my-mr-target].id + id = "c3af557f-fb0e-4476-85c3-0889e7fe7bc4" }] inclusion_filters = [{ operand = "location" @@ -97,9 +100,9 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [metrics\_router\_routes](#input\_metrics\_router\_routes) | List of routes for IBM Metrics Router |
destination_crn = string
target_name = string
target_region = optional(string)
skip_mrouter_sysdig_iam_auth_policy = optional(bool, false)
}))
list(object({| `[]` | no | -| [metrics\_router\_settings](#input\_metrics\_router\_settings) | Global settings for Metrics Routing |
name = string
rules = list(object({
action = string
targets = optional(list(object({
id = optional(string)
})), [])
inclusion_filters = list(object({
operand = string
operator = string
values = list(string)
}))
}))
}))
object({| `null` | no | -| [metrics\_router\_targets](#input\_metrics\_router\_targets) | List of Metrics Router targets to be created. |
permitted_target_regions = list(string)
primary_metadata_region = string
backup_metadata_region = string
private_api_endpoint_only = bool
default_targets = optional(list(object({
id = string
})), [])
})
list(object({| `[]` | no | +| [metrics\_router\_routes](#input\_metrics\_router\_routes) | List of routes for IBM Metrics Router |
destination_crn = string
target_name = string
target_region = string
skip_mrouter_sysdig_iam_auth_policy = optional(bool, false)
}))
list(object({| `[]` | no | +| [metrics\_router\_settings](#input\_metrics\_router\_settings) | Global settings for Metrics Routing |
name = string
rules = list(object({
action = optional(string, "send")
targets = optional(list(object({
id = string
})))
inclusion_filters = list(object({
operand = string
operator = string
values = list(string)
}))
}))
}))
object({| `null` | no | +| [metrics\_router\_targets](#input\_metrics\_router\_targets) | List of Metrics Router targets to be created. |
permitted_target_regions = optional(list(string))
primary_metadata_region = optional(string)
backup_metadata_region = optional(string)
private_api_endpoint_only = optional(bool, false)
default_targets = optional(list(object({
id = string
})))
})
list(object({| `[]` | no | ### Outputs diff --git a/modules/metrics_routing/variables.tf b/modules/metrics_routing/variables.tf index c1a7871..c963d94 100644 --- a/modules/metrics_routing/variables.tf +++ b/modules/metrics_routing/variables.tf @@ -2,7 +2,7 @@ variable "metrics_router_targets" { type = list(object({ destination_crn = string target_name = string - target_region = string + target_region = optional(string) skip_mrouter_sysdig_iam_auth_policy = optional(bool, false) })) default = [] @@ -13,10 +13,10 @@ variable "metrics_router_routes" { type = list(object({ name = string rules = list(object({ - action = string + action = optional(string, "send") targets = optional(list(object({ - id = optional(string) - })), []) + id = string + }))) inclusion_filters = list(object({ operand = string operator = string @@ -29,27 +29,44 @@ variable "metrics_router_routes" { validation { condition = length(var.metrics_router_routes) == 0 || alltrue([ - for route in var.metrics_router_routes : ( - length(route.rules) <= 4 && - alltrue([ - for rule in route.rules : length(rule.inclusion_filters) <= 5 - ]) - ) + for route in var.metrics_router_routes : alltrue([ + for rule in route.rules : length(rule.inclusion_filters) <= 5 + ]) ]) - error_message = "The metrics_router_routes list can be empty or contain routes with up to 4 rules, and each rule's inclusion_filters must have less than 5 items." + error_message = "The 'metrics_router_routes' list can be empty or contain routes with rules, and each rule's 'inclusion_filters' must have less than 5 items." + } + validation { + condition = length(var.metrics_router_routes) == 0 || alltrue([ + for route in var.metrics_router_routes : alltrue([ + for rule in route.rules : + rule.action != "send" || length(rule.targets) > 0 + ]) + ]) + error_message = "Each rule with action 'send' must have at least one target defined in 'targets'." } } variable "metrics_router_settings" { type = object({ - permitted_target_regions = list(string) - primary_metadata_region = string - backup_metadata_region = string - private_api_endpoint_only = bool + permitted_target_regions = optional(list(string)) + primary_metadata_region = optional(string) + backup_metadata_region = optional(string) + private_api_endpoint_only = optional(bool, false) default_targets = optional(list(object({ id = string - })), []) + }))) }) description = "Global settings for Metrics Routing" default = null + + validation { + error_message = "Valid regions for 'permitted_target_regions' are: us-south, eu-de, us-east, eu-es, eu-gb, au-syd, br-sao, ca-tor, jp-tok, jp-osa" + condition = (var.metrics_router_settings == null ? + true : + alltrue([ + for region in var.metrics_router_settings.permitted_target_regions : + contains(["jp-osa", "au-syd", "jp-tok", "eu-de", "eu-gb", "eu-es", "us-south", "ca-tor", "us-east", "br-sao"], region) + ]) + ) + } } diff --git a/variables.tf b/variables.tf index 8188874..0286ec2 100644 --- a/variables.tf +++ b/variables.tf @@ -310,7 +310,7 @@ variable "metrics_router_targets" { type = list(object({ destination_crn = string target_name = string - target_region = string + target_region = optional(string) skip_mrouter_sysdig_iam_auth_policy = optional(bool, false) })) default = [] @@ -321,10 +321,10 @@ variable "metrics_router_routes" { type = list(object({ name = string rules = list(object({ - action = string - targets = list(object({ + action = optional(string, "send") + targets = optional(list(object({ id = string - })) + }))) inclusion_filters = list(object({ operand = string operator = string @@ -338,13 +338,13 @@ variable "metrics_router_routes" { variable "metrics_router_settings" { type = object({ - default_targets = list(object({ + default_targets = optional(list(object({ id = string - })) - permitted_target_regions = list(string) - primary_metadata_region = string - backup_metadata_region = string - private_api_endpoint_only = bool + }))) + permitted_target_regions = optional(list(string)) + primary_metadata_region = optional(string) + backup_metadata_region = optional(string) + private_api_endpoint_only = optional(bool, false) }) description = "Global settings for Metrics Routing." default = null
destination_crn = string
target_name = string
target_region = optional(string)
skip_mrouter_sysdig_iam_auth_policy = optional(bool, false)
}))