Split base from modules

- Add infra as a example
- Introduces a dependency issue between adot operator and workload collector
This commit is contained in:
Rodrigue Koffi
2022-08-09 23:24:01 +02:00
parent 5b5d5e7dd1
commit 6dca51b135
16 changed files with 139 additions and 147 deletions
+31
View File
@@ -0,0 +1,31 @@
data "aws_partition" "current" {}
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
data "aws_eks_cluster" "eks_cluster" {
name = var.eks_cluster_id
}
locals {
name = "adot-collector-kubeprometheus"
namespace = try(var.config.helm_config.namespace, local.name)
eks_oidc_issuer_url = replace(data.aws_eks_cluster.eks_cluster.identity[0].oidc[0].issuer, "https://", "")
eks_cluster_endpoint = data.aws_eks_cluster.eks_cluster.endpoint
context = {
aws_caller_identity_account_id = data.aws_caller_identity.current.account_id
aws_caller_identity_arn = data.aws_caller_identity.current.arn
aws_eks_cluster_endpoint = local.eks_cluster_endpoint
aws_partition_id = data.aws_partition.current.partition
aws_region_name = data.aws_region.current.name
eks_cluster_id = var.eks_cluster_id
eks_oidc_issuer_url = local.eks_oidc_issuer_url
eks_oidc_provider_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${local.eks_oidc_issuer_url}"
tags = var.tags
irsa_iam_role_path = var.irsa_iam_role_path
irsa_iam_permissions_boundary = var.irsa_iam_permissions_boundary
}
}
+8 -8
View File
@@ -1,7 +1,3 @@
locals {
name = "adot-collector-kubeprometheus"
namespace = try(var.config.helm_config.namespace, local.name)
}
terraform {
required_providers {
@@ -12,6 +8,11 @@ terraform {
}
}
provider "grafana" {
url = var.managed_grafana_workspace_endpoint
auth = var.grafana_api_key
}
resource "helm_release" "kube_state_metrics" {
count = var.config.enable_kube_state_metrics ? 1 : 0
chart = var.config.ksm_helm_chart_name
@@ -47,7 +48,6 @@ resource "helm_release" "prometheus_node_exporter" {
}
}
}
data "aws_partition" "current" {}
module "helm_addon" {
source = "github.com/aws-ia/terraform-aws-eks-blueprints/modules/kubernetes-addons/helm-addon"
@@ -66,11 +66,11 @@ module "helm_addon" {
set_values = [
{
name = "ampurl"
value = "${var.amp_endpoint}api/v1/remote_write"
value = "${var.managed_prometheus_workspace_endpoint}api/v1/remote_write"
},
{
name = "region"
value = var.amp_region
value = var.managed_prometheus_workspace_region
},
{
name = "prometheusMetricsEndpoint"
@@ -102,5 +102,5 @@ module "helm_addon" {
irsa_iam_policies = ["arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonPrometheusRemoteWriteAccess"]
}
addon_context = var.addon_context
addon_context = local.context
}
+35 -21
View File
@@ -1,48 +1,56 @@
variable "eks_cluster_id" {
description = "EKS Cluster Id"
type = string
}
# ADOT variable
variable "helm_config" {
description = "Helm Config for Prometheus"
type = any
default = {}
}
variable "amp_endpoint" {
variable "irsa_iam_role_path" {
description = "IAM role path for IRSA roles"
type = string
default = "/"
}
variable "irsa_iam_permissions_boundary" {
description = "IAM permissions boundary for IRSA roles"
type = string
default = ""
}
variable "managed_prometheus_workspace_endpoint" {
description = "Amazon Managed Prometheus Workspace Endpoint"
type = string
default = null
}
variable "amp_id" {
variable "managed_prometheus_workspace_id" {
description = "Amazon Managed Prometheus Workspace ID"
type = string
default = null
}
variable "amp_region" {
variable "managed_prometheus_workspace_region" {
description = "Amazon Managed Prometheus Workspace's Region"
type = string
default = null
}
variable "dashboards_folder_id" {
type = string
variable "managed_grafana_workspace_endpoint" {
type = string
default = ""
}
variable "addon_context" {
description = "Input configuration for the addon"
type = object({
aws_caller_identity_account_id = string
aws_caller_identity_arn = string
aws_eks_cluster_endpoint = string
aws_partition_id = string
aws_region_name = string
eks_cluster_id = string
eks_oidc_issuer_url = string
eks_oidc_provider_arn = string
irsa_iam_permissions_boundary = string
irsa_iam_role_path = string
tags = map(string)
})
variable "grafana_api_key" {
type = string
default = null
}
variable "dashboards_folder_id" {
type = string
}
variable "config" {
@@ -98,3 +106,9 @@ variable "config" {
}
nullable = false
}
variable "tags" {
description = "Additional tags (e.g. `map('BusinessUnit`,`XYZ`)"
type = map(string)
default = {}
}