Enterprise-managed platform logs routing
Use IBM® Cloud Logs Routing to configure the routing of platform logs from your enterprise child accounts to your enterprise parent account. Use Cloud Identity and Access Management (IAM) Action Control to restrict changes to the enterprise-managed routing.
You can configure your enterprise child accounts to route all or a subset of platform logs to an enterprise parent account. The child accounts contain Cloud resources that generate platform logs. The parent account owns the enterprise and has IBM Cloud Logs instances that will contain the platform logs from the child accounts.
The enterprise-managed routing configurations, from child accounts to parent account, can be locked by restricting the IBM® Cloud Logs Routing enterprise actions with IAM Action Control. The child accounts can continue to manage their own account-managed IBM® Cloud Logs Routing configurations, while the enterprise-managed configurations are restricted.
This example uses terraform automation to facilitate consistent routing configurations and action control restrictions across many child accounts. However, other configuration methods can be used as well.
Before you begin
-
This document only supports version 3 of the IBM® Cloud Logs Routing API, see Transitioning from v1 to v3 to migrate your child accounts.
-
To learn about how enterprise-manged IAM templates make your enterprise more secure, see How enterprise-managed IAM access works.
-
Be a member of the enterprise account to create and assign enterprise-managed IAM templates.
-
To create, update, and delete an enterprise-managed IAM template, make sure that you are assigned with the following access:
- A policy with the Template Administrator role on All IAM Account Management services.
-
To assign an enterprise-managed IAM template to child accounts, make sure that you are assigned with the following access:
- A policy with the Template Assignment Administrator role on All IAM Account Management services
- A policy with at least the Viewer role on the Enterprise service.
-
To create and assign action control templates, new and existing accounts in your enterprise must opt-in to enterprise-managed IAM. For more information, see Opting in to enterprise-managed IAM.
-
You must have Administrator role with permissions to manage IBM Cloud Logs Routing in the source accounts. See Managing access with IAM and Granting IAM permissions.
Step 1 - Create the parent account destination instance
Follow Provisioning an IBM Cloud Logs instance by using Terraform to create the instance in the enterprise parent account. The instance will not receive platform logs until the child accounts are configured to send their logs to the instance.
Step 3 - Create enterprise targets in child accounts
Next, you need to create IBM® Cloud Logs Routing enterprise targets in each child account, the target destination is the parent account's IBM Cloud Logs instance. In this example, there are only two child accounts, but there is no limitation to the number of child accounts that can be targeted to a single parent account.
Note the managed_by = "enterprise" parameter below.
# NEW FILE: child_a/main.tf
terraform {
required_version = ">= 0.13"
required_providers {
ibm = {
source = "ibm-cloud/ibm"
version = "~>1.88.3"
}
}
}
variable "ibmcloud_api_key" {
description = "The IBM Cloud API key."
type = string
sensitive = true
}
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
}
resource "ibm_logs_router_settings" "logs_router_settings" {
primary_metadata_region = "<INPUT_LOGS_ROUTING_REGION>"
}
resource "ibm_logs_router_target" "logs_router_target" {
destination_crn = "<INPUT_PARENT_CLOUD_LOGS_CRN>"
name = "child-a-target"
managed_by = "enterprise"
}
# NEW FILE: child_b/main.tf
terraform {
required_version = ">= 0.13"
required_providers {
ibm = {
source = "ibm-cloud/ibm"
version = "~>1.81.0"
}
}
}
variable "ibmcloud_api_key" {
description = "The IBM Cloud API key."
type = string
sensitive = true
}
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
}
resource "ibm_logs_router_settings" "logs_router_settings" {
primary_metadata_region = "<INPUT_LOGS_ROUTING_REGION>"
}
resource "ibm_logs_router_target" "logs_router_target" {
destination_crn = "<INPUT_PARENT_CLOUD_LOGS_CRN>"
name = "child-b-target"
managed_by = "enterprise"
}
This step creates IBM® Cloud Logs Routing enterprise targets pointing to the parent IBM Cloud Logs instance. Routing is not yet enabled.
Step 4 - Create enterprise routes in the child accounts
Create IBM® Cloud Logs Routing enterprise routes in each child account. You can route all platform logs to the parent or a subset of platform logs to the parent. In this example, child A and child B accounts will route all platform logs to the parent.
See IBM Cloud services that generate platform logs.
# FILE: child_a/main.tf
# Previous steps...
resource "ibm_logs_router_route" "logs_router_route" {
lifecycle {
create_before_destroy = true
}
name = "child-a-route"
managed_by = "enterprise"
# Route all platform logs to the hub.
rules {
action = "send"
targets {
id = ibm_logs_router_target.logs_router_target.id
}
}
}
# FILE: child_b/main.tf
# Previous steps...
resource "ibm_logs_router_route" "logs_router_route" {
lifecycle {
create_before_destroy = true
}
name = "child-b-route"
managed_by = "enterprise"
# Route all platform logs to the hub.
rules {
action = "send"
targets {
id = ibm_logs_router_target.logs_router_target.id
}
}
}
This step creates the IBM® Cloud Logs Routing enterprise routes. Platform logs will be routed to the parent IBM Cloud Logs instance.
Step 5 - Restrict enterprise actions with IAM Action Control
Now that the enterprise-managed routing is created, you must restrict the usage of IBM® Cloud Logs Routing enterprise actions so that the enterprise-managed routing cannot be modified by any entity. In this example, there is only one version of the action control template and it is assigned to each individual Account instead of the entire Enterprise or an Account Group.
In order to make changes to the enterprise-managed routing, you must delete the action control assignments.
# FILE: parent/main.tf
# Previous steps...
resource "ibm_iam_action_control_template" "logs_router_enterprise_action_control_template" {
name = "Logs Router Enterprise Routing"
description = "Restrict Logs Router enterprise-managed routing"
action_control {
actions = [
"logs-router.enterprise-target.create",
"logs-router.enterprise-target.update",
"logs-router.enterprise-target.delete",
"logs-router.enterprise-route.create",
"logs-router.enterprise-route.update",
"logs-router.enterprise-route.delete"
]
service_name = "logs-router"
}
committed = "true"
}
locals {
child_accounts = [
"<INPUT_CHILD_A_ACCOUNT_ID>",
"<INPUT_CHILD_B_ACCOUNT_ID>"
]
}
resource "ibm_iam_action_control_assignment" "logs_router_enterprise_action_control_assignment" {
for_each = toset(local.child_accounts)
target = {
type = "Account"
id = each.key
}
templates {
id = ibm_iam_action_control_template.logs_router_enterprise_action_control_template.template_id
version = ibm_iam_action_control_template.logs_router_enterprise_action_control_template.version
}
}
This step ensures IBM® Cloud Logs Routing enterprise actions are restricted from further use, locking the enterprise-managed routing.
Optional Step 6 - Account-managed routing
Optionally, you can create account-managed routing in the enterprise child accounts or parent account; it will not conflict with the enterprise-managed routing created earlier. To create account-managed routing, ensure that the IBM® Cloud Logs
Routing target and route configurations have managed_by = "account".