From dad96663a0bb54df3264d27e94e5875fc2970d84 Mon Sep 17 00:00:00 2001 From: Rodrigue Koffi Date: Mon, 15 Jan 2024 12:59:19 -0500 Subject: [PATCH] Update examples --- .../README.md | 5 +-- .../main.tf | 40 +++++-------------- .../outputs.tf | 5 --- 3 files changed, 12 insertions(+), 38 deletions(-) diff --git a/examples/existing-cluster-with-base-and-infra/README.md b/examples/existing-cluster-with-base-and-infra/README.md index 3b06c870..aeb088b1 100644 --- a/examples/existing-cluster-with-base-and-infra/README.md +++ b/examples/existing-cluster-with-base-and-infra/README.md @@ -1,4 +1,4 @@ -# Existing Cluster with the AWS Observability accelerator base module and Infrastructure monitoring +# Existing Cluster with the AWS Observability accelerator EKS Infrastructure monitoring This example demonstrates how to use the AWS Observability Accelerator Terraform modules with Infrastructure monitoring enabled. @@ -35,7 +35,6 @@ View the full documentation for this example [here](https://aws-observability.gi | Name | Source | Version | |------|--------|---------| -| [aws\_observability\_accelerator](#module\_aws\_observability\_accelerator) | ../../ | n/a | | [eks\_monitoring](#module\_eks\_monitoring) | ../../modules/eks-monitoring | n/a | ## Resources @@ -44,6 +43,7 @@ View the full documentation for this example [here](https://aws-observability.gi |------|------| | [aws_eks_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source | | [aws_eks_cluster_auth.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source | +| [aws_grafana_workspace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/grafana_workspace) | data source | ## Inputs @@ -60,7 +60,6 @@ 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 | diff --git a/examples/existing-cluster-with-base-and-infra/main.tf b/examples/existing-cluster-with-base-and-infra/main.tf index eccd94a1..a00df02f 100644 --- a/examples/existing-cluster-with-base-and-infra/main.tf +++ b/examples/existing-cluster-with-base-and-infra/main.tf @@ -10,6 +10,10 @@ data "aws_eks_cluster" "this" { name = var.eks_cluster_id } +data "aws_grafana_workspace" "this" { + workspace_id = var.managed_grafana_workspace_id +} + provider "kubernetes" { host = local.eks_cluster_endpoint cluster_ca_certificate = base64decode(data.aws_eks_cluster.this.certificate_authority[0].data) @@ -33,28 +37,6 @@ locals { } } -# deploys the base module -module "aws_observability_accelerator" { - source = "../../" - # source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v2.0.0" - - aws_region = var.aws_region - - # creates a new Amazon Managed Prometheus workspace, defaults to true - enable_managed_prometheus = local.create_new_workspace - - # reusing existing Amazon Managed Prometheus if specified - managed_prometheus_workspace_id = var.managed_prometheus_workspace_id - - # sets up the Amazon Managed Prometheus alert manager at the workspace level - enable_alertmanager = true - - # reusing existing Amazon Managed Grafana workspace - managed_grafana_workspace_id = var.managed_grafana_workspace_id - - tags = local.tags -} - module "eks_monitoring" { source = "../../modules/eks-monitoring" # source = "github.com/aws-observability/terraform-aws-observability-accelerator//modules/eks-monitoring?ref=v2.0.0" @@ -75,15 +57,17 @@ module "eks_monitoring" { grafana_api_key = var.grafana_api_key target_secret_name = "grafana-admin-credentials" target_secret_namespace = "grafana-operator" - grafana_url = module.aws_observability_accelerator.managed_grafana_workspace_endpoint + grafana_url = "https://${data.aws_grafana_workspace.this.endpoint}" # control the publishing of dashboards by specifying the boolean value for the variable 'enable_dashboards', default is 'true' enable_dashboards = var.enable_dashboards - managed_prometheus_workspace_id = module.aws_observability_accelerator.managed_prometheus_workspace_id + # creates a new Amazon Managed Prometheus workspace, defaults to true + enable_managed_prometheus = local.create_new_workspace + managed_prometheus_workspace_id = var.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 + # sets up the Amazon Managed Prometheus alert manager at the workspace level + enable_alertmanager = true # optional, defaults to 60s interval and 15s timeout prometheus_config = { @@ -94,8 +78,4 @@ module "eks_monitoring" { enable_logs = true tags = local.tags - - depends_on = [ - module.aws_observability_accelerator - ] } diff --git a/examples/existing-cluster-with-base-and-infra/outputs.tf b/examples/existing-cluster-with-base-and-infra/outputs.tf index f8b4d584..5d70fe2a 100644 --- a/examples/existing-cluster-with-base-and-infra/outputs.tf +++ b/examples/existing-cluster-with-base-and-infra/outputs.tf @@ -1,8 +1,3 @@ -output "aws_region" { - description = "AWS Region" - value = module.aws_observability_accelerator.aws_region -} - output "eks_cluster_version" { description = "EKS Cluster version" value = module.eks_monitoring.eks_cluster_version