diff --git a/examples/eks-cross-account-with-central-amp/data.tf b/examples/eks-cross-account-with-central-amp/data.tf index e3d2f33b..88c91c4d 100644 --- a/examples/eks-cross-account-with-central-amp/data.tf +++ b/examples/eks-cross-account-with-central-amp/data.tf @@ -19,6 +19,6 @@ data "aws_eks_cluster" "eks_two" { } data "aws_grafana_workspace" "this" { - workspace_id = var.managed_grafana_workspace_id + workspace_id = var.monitoring.managed_grafana_id provider = aws.eks_cluster_one } diff --git a/examples/eks-multicluster/data.tf b/examples/eks-multicluster/data.tf index 6ebf21b7..2a25fd5e 100644 --- a/examples/eks-multicluster/data.tf +++ b/examples/eks-multicluster/data.tf @@ -24,6 +24,6 @@ data "aws_grafana_workspace" "this" { } data "aws_prometheus_workspace" "this" { - workspace_id = var.managed_prometheus_workspace_id + workspace_id = local.managed_prometheus_workspace_id provider = aws.eks_cluster_1 } diff --git a/examples/eks-multicluster/main.tf b/examples/eks-multicluster/main.tf index 721c5ae0..d5b8e72c 100644 --- a/examples/eks-multicluster/main.tf +++ b/examples/eks-multicluster/main.tf @@ -1,3 +1,7 @@ +locals { + create_new_workspace = var.managed_prometheus_workspace_id == "" ? true : false + managed_prometheus_workspace_id = local.create_new_workspace ? module.managed_service_prometheus[0].workspace_id : var.managed_prometheus_workspace_id +} module "eks_cluster_1_monitoring" { source = "../..//modules/eks-monitoring" eks_cluster_id = var.eks_cluster_1_id @@ -23,7 +27,7 @@ module "eks_cluster_1_monitoring" { # prevents the module to create a workspace enable_managed_prometheus = false - managed_prometheus_workspace_id = var.managed_prometheus_workspace_id + managed_prometheus_workspace_id = local.managed_prometheus_workspace_id managed_prometheus_workspace_endpoint = data.aws_prometheus_workspace.this.prometheus_endpoint managed_prometheus_workspace_region = var.eks_cluster_1_region @@ -78,3 +82,14 @@ module "eks_cluster_2_monitoring" { helm = helm.eks_cluster_2 } } + +module "managed_service_prometheus" { + count = local.create_new_workspace ? 1 : 0 + source = "terraform-aws-modules/managed-service-prometheus/aws" + version = "~> 2.2.2" + providers = { + aws = aws.eks_cluster_1 + } + + workspace_alias = "aws-observability-accelerator-multicluster" +}