Skip to content

Commit

Permalink
feat: Add Amazon Managed service for Prometheus controller support (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdemagny authored Nov 21, 2022
1 parent 203ecae commit 950645c
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module "eks_ack_addons" {
enable_dynamodb = true
enable_s3 = true
enable_rds = true
enable_amp = true
tags = {
Environment = "dev"
Expand Down Expand Up @@ -47,6 +48,7 @@ Examples codified under the [`examples`](https://github.com/aws-ia/terraform-aws

| Name | Source | Version |
|------|--------|---------|
| <a name="module_amp"></a> [amp](#module\_amp) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 |
| <a name="module_api_gatewayv2"></a> [api\_gatewayv2](#module\_api\_gatewayv2) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 |
| <a name="module_dynamodb"></a> [dynamodb](#module\_dynamodb) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 |
| <a name="module_rds"></a> [rds](#module\_rds) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.12.2 |
Expand All @@ -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 |
Expand All @@ -71,10 +74,12 @@ Examples codified under the [`examples`](https://github.com/aws-ia/terraform-aws

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_amp_helm_config"></a> [amp\_helm\_config](#input\_amp\_helm\_config) | ACK amp Helm Chart config | `any` | `{}` | no |
| <a name="input_api_gatewayv2_helm_config"></a> [api\_gatewayv2\_helm\_config](#input\_api\_gatewayv2\_helm\_config) | ACK API gateway v2 Helm Chart config | `any` | `{}` | no |
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | EKS Cluster Id | `string` | n/a | yes |
| <a name="input_data_plane_wait_arn"></a> [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 |
| <a name="input_dynamodb_helm_config"></a> [dynamodb\_helm\_config](#input\_dynamodb\_helm\_config) | ACK dynamodb Helm Chart config | `any` | `{}` | no |
| <a name="input_enable_amp"></a> [enable\_amp](#input\_enable\_amp) | Enable ACK amp add-on | `bool` | `false` | no |
| <a name="input_enable_api_gatewayv2"></a> [enable\_api\_gatewayv2](#input\_enable\_api\_gatewayv2) | Enable ACK API gateway v2 add-on | `bool` | `false` | no |
| <a name="input_enable_dynamodb"></a> [enable\_dynamodb](#input\_enable\_dynamodb) | Enable ACK dynamodb add-on | `bool` | `false` | no |
| <a name="input_enable_rds"></a> [enable\_rds](#input\_enable\_rds) | Enable ACK rds add-on | `bool` | `false` | no |
Expand Down
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module "eks_ack_addons" {
enable_dynamodb = true
enable_s3 = true
enable_rds = true
enable_amp = true

tags = local.tags
}
Expand Down
66 changes: 66 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
16 changes: 16 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
}

0 comments on commit 950645c

Please sign in to comment.