diff --git a/examples/eks-istio/README.md b/examples/eks-istio/README.md
index d0db54c0..7a3bb4b4 100644
--- a/examples/eks-istio/README.md
+++ b/examples/eks-istio/README.md
@@ -49,9 +49,9 @@ View the full documentation for this example [here](https://aws-observability.gi
| Name | Description |
|------|-------------|
-| [aws\_region](#output\_aws\_region) | AWS Region |
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
+| [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
diff --git a/examples/eks-multicluster/data.tf b/examples/eks-multicluster/data.tf
index acc5d558..6ebf21b7 100644
--- a/examples/eks-multicluster/data.tf
+++ b/examples/eks-multicluster/data.tf
@@ -17,3 +17,13 @@ data "aws_eks_cluster" "eks_cluster_2" {
name = var.eks_cluster_2_id
provider = aws.eks_cluster_2
}
+
+data "aws_grafana_workspace" "this" {
+ workspace_id = var.managed_grafana_workspace_id
+ provider = aws.eks_cluster_1
+}
+
+data "aws_prometheus_workspace" "this" {
+ workspace_id = var.managed_prometheus_workspace_id
+ provider = aws.eks_cluster_1
+}
diff --git a/examples/eks-multicluster/main.tf b/examples/eks-multicluster/main.tf
index 8e3034b5..a4242951 100644
--- a/examples/eks-multicluster/main.tf
+++ b/examples/eks-multicluster/main.tf
@@ -1,17 +1,3 @@
-module "aws_observability_accelerator" {
- source = "../../../terraform-aws-observability-accelerator"
- aws_region = var.eks_cluster_1_region
- enable_managed_prometheus = false
- enable_alertmanager = true
- managed_prometheus_workspace_region = null
- managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
- managed_grafana_workspace_id = var.managed_grafana_workspace_id
-
- providers = {
- aws = aws.eks_cluster_1
- }
-}
-
module "eks_cluster_1_monitoring" {
source = "../../../terraform-aws-observability-accelerator//modules/eks-monitoring"
eks_cluster_id = var.eks_cluster_1_id
@@ -31,11 +17,15 @@ module "eks_cluster_1_monitoring" {
enable_apiserver_monitoring = true
enable_adotcollector_metrics = true
- grafana_api_key = var.grafana_api_key
- managed_prometheus_workspace_id = module.aws_observability_accelerator.managed_prometheus_workspace_id
- managed_prometheus_workspace_endpoint = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
- managed_prometheus_workspace_region = module.aws_observability_accelerator.managed_prometheus_workspace_region
- grafana_url = module.aws_observability_accelerator.managed_grafana_workspace_endpoint
+ grafana_api_key = var.grafana_api_key
+ grafana_url = "https://${data.aws_grafana_workspace.this.endpoint}"
+
+ # prevents the module to create a workspace
+ enable_managed_prometheus = false
+
+ managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
+ managed_prometheus_workspace_endpoint = data.aws_prometheus_workspace.this.prometheus_endpoint
+ managed_prometheus_workspace_region = var.eks_cluster_1_region
prometheus_config = {
global_scrape_interval = "60s"
@@ -48,10 +38,6 @@ module "eks_cluster_1_monitoring" {
kubernetes = kubernetes.eks_cluster_1
helm = helm.eks_cluster_1
}
-
- depends_on = [
- module.aws_observability_accelerator
- ]
}
module "eks_cluster_2_monitoring" {
@@ -73,9 +59,12 @@ module "eks_cluster_2_monitoring" {
enable_apiserver_monitoring = false
enable_adotcollector_metrics = false
- managed_prometheus_workspace_id = module.aws_observability_accelerator.managed_prometheus_workspace_id
- managed_prometheus_workspace_endpoint = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
- managed_prometheus_workspace_region = module.aws_observability_accelerator.managed_prometheus_workspace_region
+ # prevents the module to create a workspace
+ enable_managed_prometheus = false
+
+ managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
+ managed_prometheus_workspace_endpoint = data.aws_prometheus_workspace.this.prometheus_endpoint
+ managed_prometheus_workspace_region = var.eks_cluster_1_region
prometheus_config = {
global_scrape_interval = "60s"
@@ -88,8 +77,4 @@ module "eks_cluster_2_monitoring" {
kubernetes = kubernetes.eks_cluster_2
helm = helm.eks_cluster_2
}
-
- depends_on = [
- module.aws_observability_accelerator
- ]
}
diff --git a/examples/existing-cluster-java/README.md b/examples/existing-cluster-java/README.md
index afb78690..1b1e08b2 100644
--- a/examples/existing-cluster-java/README.md
+++ b/examples/existing-cluster-java/README.md
@@ -232,9 +232,9 @@ terraform destroy -var-file=terraform.tfvars
| Name | Description |
|------|-------------|
-| [aws\_region](#output\_aws\_region) | AWS Region |
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
+| [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
diff --git a/examples/existing-cluster-nginx/README.md b/examples/existing-cluster-nginx/README.md
index a67d0eff..dad16832 100644
--- a/examples/existing-cluster-nginx/README.md
+++ b/examples/existing-cluster-nginx/README.md
@@ -218,7 +218,6 @@ add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws
| Name | Source | Version |
|------|--------|---------|
-| [aws\_observability\_accelerator](#module\_aws\_observability\_accelerator) | ../../ | n/a |
| [eks\_monitoring](#module\_eks\_monitoring) | ../../modules/eks-monitoring | n/a |
## Resources
@@ -244,9 +243,9 @@ add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws
| Name | Description |
|------|-------------|
-| [aws\_region](#output\_aws\_region) | AWS Region |
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
+| [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
diff --git a/examples/existing-cluster-with-base-and-infra/README.md b/examples/existing-cluster-with-base-and-infra/README.md
index aeb088b1..a2a22630 100644
--- a/examples/existing-cluster-with-base-and-infra/README.md
+++ b/examples/existing-cluster-with-base-and-infra/README.md
@@ -62,4 +62,7 @@ View the full documentation for this example [here](https://aws-observability.gi
|------|-------------|
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
+| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
+| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
+| [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
diff --git a/modules/eks-monitoring/README.md b/modules/eks-monitoring/README.md
index f5255b9e..5116546d 100644
--- a/modules/eks-monitoring/README.md
+++ b/modules/eks-monitoring/README.md
@@ -140,4 +140,7 @@ See examples using this Terraform modules in the **Amazon EKS** section of [this
| [adot\_irsa\_arn](#output\_adot\_irsa\_arn) | IRSA Arn for ADOT |
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
+| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
+| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
+| [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | Amazon Managed Prometheus workspace region |
diff --git a/modules/eks-monitoring/locals.tf b/modules/eks-monitoring/locals.tf
index adf70a79..a2ae3330 100644
--- a/modules/eks-monitoring/locals.tf
+++ b/modules/eks-monitoring/locals.tf
@@ -8,7 +8,6 @@ data "aws_eks_cluster" "eks_cluster" {
name = var.eks_cluster_id
}
-
locals {
# if region is not passed, we assume the current one
managed_prometheus_workspace_id = var.enable_managed_prometheus ? aws_prometheus_workspace.this[0].id : var.managed_prometheus_workspace_id