Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: low quality example for IBM Cloud Monitoring #5897

Open
sean-freeman opened this issue Dec 29, 2024 · 0 comments
Open

docs: low quality example for IBM Cloud Monitoring #5897

sean-freeman opened this issue Dec 29, 2024 · 0 comments
Labels
documentation service/IAM Issues related to IAM service/Resource Management Issues related to Resource Manager or Resource controller Issues

Comments

@sean-freeman
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Working example below, including missing IAM Policy for S2S.

variable "ibmcloud_region_name" {}

variable "ibmcloud_resource_group_name" {}

variable "resource_prefix" {}


data "ibm_resource_group" "target" {
  name = var.ibmcloud_resource_group_name
}


# IBM Cloud Monitoring service instance
resource "ibm_resource_instance" "monitoring_service_instance" {
  name       = "${var.resource_prefix}-cloud-monitor"
  resource_group_id = data.ibm_resource_group.target.id
  service    = "sysdig-monitor"
  plan       = "graduated-tier"
  location   = var.ibmcloud_region_name
  parameters = {
    default_receiver = true
    # workload_protection_connected_instance = "crn_value"
    external_api_auth = "ANY" # ANY, IAM_ONLY, API_AUTH
  }
}

# Required on first provision to set the metadata location, otherwise cannot proceed
# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/metrics_router_settings
resource "ibm_metrics_router_settings" "metrics_router_settings_instance" {
  primary_metadata_region   = var.ibmcloud_region_name
  # backup_metadata_region    = "us-east"
  permitted_target_regions  = ["us-south", "eu-de", "eu-gb", "eu-es", "jp-osa", "br-sao", "au-syd", "au-syd", "jp-tok", "ca-tor", "us-east"]
  private_api_endpoint_only = false # Altering to true may cause an update IBM Cloud Metrics Routing settings for the account
  # default_targets { id = id_value } # Requires ibm_metrics_router_target, which conflicts with need to first define the metadata location
  lifecycle {
    ignore_changes = [
      backup_metadata_region
    ]
  }
}

# Service authorization is required to allow IBM Cloud Metrics Routing to communicate with IBM Cloud Monitoring
# IAM service authorization policy scoped to all resources in this account
resource "ibm_iam_authorization_policy" "s2s_metrics_to_monitoring" {
  source_service_name  = "metrics-router"
  target_service_name  = "sysdig-monitor"
  roles                = ["Supertenant Metrics Publisher"]
}

# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/metrics_router_target
resource "ibm_metrics_router_target" "metrics_router_target_instance" {
  name            = "${var.resource_prefix}-cloud-monitor-target"
  region          = "us-south"
  destination_crn = ibm_resource_instance.monitoring_service_instance.crn
}

# https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/metrics_router_route
resource "ibm_metrics_router_route" "metrics_router_route_default" {
  name     = "${var.resource_prefix}-cloud-monitor-route-default"
  rules {
    action = "send"
    targets {
      id = ibm_metrics_router_target.metrics_router_target_instance.id
    }
    inclusion_filters {
      operand = "location" # location, service_name, service_instance, resource_type, resource
      operator = "in" # is, in
      values = [ "global", "us-south", "eu-de", "eu-gb", "eu-es", "jp-osa", "br-sao", "au-syd", "au-syd", "jp-tok", "ca-tor", "us-east" ]
    }
  }
}
@github-actions github-actions bot added service/IAM Issues related to IAM service/Resource Management Issues related to Resource Manager or Resource controller Issues labels Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation service/IAM Issues related to IAM service/Resource Management Issues related to Resource Manager or Resource controller Issues
Projects
None yet
Development

No branches or pull requests

1 participant