diff --git a/README.md b/README.md index 54b59b0..8b4f829 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ module "eks_ack_addons" { enable_dynamodb = true enable_s3 = true enable_rds = true + enable_amp = true tags = { Environment = "dev" @@ -47,6 +48,7 @@ Examples codified under the [`examples`](https://github.com/aws-ia/terraform-aws | Name | Source | Version | |------|--------|---------| +| [amp](#module\_amp) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 | | [api\_gatewayv2](#module\_api\_gatewayv2) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 | | [dynamodb](#module\_dynamodb) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 | | [rds](#module\_rds) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 | @@ -59,6 +61,7 @@ Examples codified under the [`examples`](https://github.com/aws-ia/terraform-aws | [time_sleep.dataplane](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | | [aws_eks_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source | +| [aws_iam_policy.amp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source | | [aws_iam_policy.api_gatewayv2_admin](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source | | [aws_iam_policy.api_gatewayv2_invoke](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source | | [aws_iam_policy.dynamodb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source | @@ -71,10 +74,12 @@ Examples codified under the [`examples`](https://github.com/aws-ia/terraform-aws | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [amp\_helm\_config](#input\_amp\_helm\_config) | ACK amp Helm Chart config | `any` | `{}` | no | | [api\_gatewayv2\_helm\_config](#input\_api\_gatewayv2\_helm\_config) | ACK API gateway v2 Helm Chart config | `any` | `{}` | no | | [cluster\_id](#input\_cluster\_id) | EKS Cluster Id | `string` | n/a | yes | | [data\_plane\_wait\_arn](#input\_data\_plane\_wait\_arn) | Addon deployment will not proceed until this value is known. Set to node group/Fargate profile ARN to wait for data plane to be ready before provisioning addons | `string` | `""` | no | | [dynamodb\_helm\_config](#input\_dynamodb\_helm\_config) | ACK dynamodb Helm Chart config | `any` | `{}` | no | +| [enable\_amp](#input\_enable\_amp) | Enable ACK amp add-on | `bool` | `false` | no | | [enable\_api\_gatewayv2](#input\_enable\_api\_gatewayv2) | Enable ACK API gateway v2 add-on | `bool` | `false` | no | | [enable\_dynamodb](#input\_enable\_dynamodb) | Enable ACK dynamodb add-on | `bool` | `false` | no | | [enable\_rds](#input\_enable\_rds) | Enable ACK rds add-on | `bool` | `false` | no | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index e1e568d..d9d1480 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -100,6 +100,7 @@ module "eks_ack_addons" { enable_dynamodb = true enable_s3 = true enable_rds = true + enable_amp = true tags = local.tags } diff --git a/main.tf b/main.tf index 066f444..41a199e 100644 --- a/main.tf +++ b/main.tf @@ -306,3 +306,69 @@ data "aws_iam_policy" "rds" { name = "AmazonRDSFullAccess" } + +################################################################################ +# Amazon Managed Service for Prometheus +################################################################################ + +locals { + amp_name = "ack-amp" +} + +module "amp" { + source = "github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon?ref=v4.12.2" + + count = var.enable_amp ? 1 : 0 + + helm_config = merge( + { + name = local.amp_name + chart = "prometheusservice-chart" + repository = "oci://public.ecr.aws/aws-controllers-k8s" + version = "v0.1.1" + namespace = local.amp_name + create_namespace = true + description = "ACK amp Controller v2 Helm chart deployment configuration" + values = [ + # shortens pod name from `ack-amp-amp-chart-xxxxxxxxxxxxx` to `ack-amp-xxxxxxxxxxxxx` + <<-EOT + nameOverride: ack-amp + EOT + ] + }, + var.amp_helm_config + ) + + set_values = [ + { + name = "serviceAccount.name" + value = local.amp_name + }, + { + name = "serviceAccount.create" + value = false + }, + { + name = "aws.region" + value = local.region + } + ] + + irsa_config = { + create_kubernetes_namespace = true + kubernetes_namespace = try(var.amp_helm_config.namespace, local.amp_name) + + create_kubernetes_service_account = true + kubernetes_service_account = local.amp_name + + irsa_iam_policies = [data.aws_iam_policy.amp[0].arn] + } + + addon_context = local.addon_context +} + +data "aws_iam_policy" "amp" { + count = var.enable_amp ? 1 : 0 + + name = "AmazonPrometheusFullAccess" +} diff --git a/variables.tf b/variables.tf index b7bb271..b60e031 100644 --- a/variables.tf +++ b/variables.tf @@ -90,3 +90,19 @@ variable "rds_helm_config" { type = any default = {} } + +################################################################################ +# AMP +################################################################################ + +variable "enable_amp" { + description = "Enable ACK amp add-on" + type = bool + default = false +} + +variable "amp_helm_config" { + description = "ACK amp Helm Chart config" + type = any + default = {} +}