Skip to content

Commit

Permalink
Update multicluster example
Browse files Browse the repository at this point in the history
  • Loading branch information
bonclay7 committed Jan 15, 2024
1 parent b34e4a9 commit cae2ea4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion examples/eks-istio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ View the full documentation for this example [here](https://aws-observability.gi

| Name | Description |
|------|-------------|
| <a name="output_aws_region"></a> [aws\_region](#output\_aws\_region) | AWS Region |
| <a name="output_eks_cluster_id"></a> [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| <a name="output_eks_cluster_version"></a> [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| <a name="output_managed_prometheus_workspace_endpoint"></a> [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| <a name="output_managed_prometheus_workspace_id"></a> [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
| <a name="output_managed_prometheus_workspace_region"></a> [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
10 changes: 10 additions & 0 deletions examples/eks-multicluster/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
45 changes: 15 additions & 30 deletions examples/eks-multicluster/main.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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" {
Expand All @@ -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"
Expand All @@ -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
]
}
2 changes: 1 addition & 1 deletion examples/existing-cluster-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ terraform destroy -var-file=terraform.tfvars

| Name | Description |
|------|-------------|
| <a name="output_aws_region"></a> [aws\_region](#output\_aws\_region) | AWS Region |
| <a name="output_eks_cluster_id"></a> [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| <a name="output_eks_cluster_version"></a> [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| <a name="output_managed_prometheus_workspace_endpoint"></a> [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| <a name="output_managed_prometheus_workspace_id"></a> [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
| <a name="output_managed_prometheus_workspace_region"></a> [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3 changes: 1 addition & 2 deletions examples/existing-cluster-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws

| Name | Source | Version |
|------|--------|---------|
| <a name="module_aws_observability_accelerator"></a> [aws\_observability\_accelerator](#module\_aws\_observability\_accelerator) | ../../ | n/a |
| <a name="module_eks_monitoring"></a> [eks\_monitoring](#module\_eks\_monitoring) | ../../modules/eks-monitoring | n/a |

## Resources
Expand All @@ -244,9 +243,9 @@ add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws

| Name | Description |
|------|-------------|
| <a name="output_aws_region"></a> [aws\_region](#output\_aws\_region) | AWS Region |
| <a name="output_eks_cluster_id"></a> [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| <a name="output_eks_cluster_version"></a> [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| <a name="output_managed_prometheus_workspace_endpoint"></a> [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| <a name="output_managed_prometheus_workspace_id"></a> [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
| <a name="output_managed_prometheus_workspace_region"></a> [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3 changes: 3 additions & 0 deletions examples/existing-cluster-with-base-and-infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ View the full documentation for this example [here](https://aws-observability.gi
|------|-------------|
| <a name="output_eks_cluster_id"></a> [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| <a name="output_eks_cluster_version"></a> [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| <a name="output_managed_prometheus_workspace_endpoint"></a> [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| <a name="output_managed_prometheus_workspace_id"></a> [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
| <a name="output_managed_prometheus_workspace_region"></a> [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | AWS Region |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3 changes: 3 additions & 0 deletions modules/eks-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,7 @@ See examples using this Terraform modules in the **Amazon EKS** section of [this
| <a name="output_adot_irsa_arn"></a> [adot\_irsa\_arn](#output\_adot\_irsa\_arn) | IRSA Arn for ADOT |
| <a name="output_eks_cluster_id"></a> [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| <a name="output_eks_cluster_version"></a> [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| <a name="output_managed_prometheus_workspace_endpoint"></a> [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| <a name="output_managed_prometheus_workspace_id"></a> [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
| <a name="output_managed_prometheus_workspace_region"></a> [managed\_prometheus\_workspace\_region](#output\_managed\_prometheus\_workspace\_region) | Amazon Managed Prometheus workspace region |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1 change: 0 additions & 1 deletion modules/eks-monitoring/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cae2ea4

Please sign in to comment.