Skip to content

Commit

Permalink
EKS Container Insights - updating docs and few varibaleable names, de…
Browse files Browse the repository at this point in the history
…finitions
  • Loading branch information
ruchimo committed Jan 19, 2024
1 parent 5ec274b commit 83bad93
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 26 deletions.
15 changes: 14 additions & 1 deletion docs/container-insights/eks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Setting Up Container Insights for your EKS Cluster

This example deploys CloudWatch Observability EKS add-on on an exisiting Amazon EKS cluster, which has Container Insights enhanced observability for Amazon EKS and CloudWatch Application Signals enabled by default.
This example deploys CloudWatch Observability EKS add-on on an exisiting Amazon EKS cluster, which enables Container Insights enhanced observability for Amazon EKS and CloudWatch Application Signals by default.

1. Enables the CloudWatch Observability Add-on on EKS using the IAM service account role
2. Creates an IAM Service Linked role for enabling Application Signals

## Prerequisites

Expand Down Expand Up @@ -32,6 +35,16 @@ Specify the EKS Cluster Name where the resources will be deployed:
export TF_VAR_eks_cluster_id=xxx
```

### 3. Disable creation of `Cloudwatch Application Signals Service-linked Role`
If you already have Application Signals deployed in your AWS account, please set the value of this variable to `false`
```
variable "create_cloudwatch_application_signals_role" {
type = bool
default = true
description = "Create a Cloudwatch Application Signals service-linked role"
}
```

## Deploy

Simply run this command to deploy the example
Expand Down
2 changes: 1 addition & 1 deletion examples/eks-container-insights/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Step-by-step instructions available on our [docs site](https://aws-observability

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | EKS cluster name | `string` | n/a | yes |
| <a name="input_eks_cluster_domain"></a> [eks\_cluster\_domain](#input\_eks\_cluster\_domain) | The domain for the EKS cluster | `string` | `""` | no |
| <a name="input_eks_cluster_id"></a> [eks\_cluster\_id](#input\_eks\_cluster\_id) | EKS cluster name | `string` | n/a | yes |
| <a name="input_eks_cluster_version"></a> [eks\_cluster\_version](#input\_eks\_cluster\_version) | The Kubernetes version for the cluster | `string` | `"1.28"` | no |
| <a name="input_eks_oidc_provider"></a> [eks\_oidc\_provider](#input\_eks\_oidc\_provider) | The OpenID Connect identity provider (issuer URL without leading `https://`) | `string` | `null` | no |
| <a name="input_eks_oidc_provider_arn"></a> [eks\_oidc\_provider\_arn](#input\_eks\_oidc\_provider\_arn) | The OpenID Connect identity provider ARN | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/eks-container-insights/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

data "aws_eks_cluster" "eks_cluster" {
name = var.cluster_name
name = var.eks_cluster_id
}
6 changes: 5 additions & 1 deletion examples/eks-container-insights/locals.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
locals {
name = "amazon-cloudwatch-observability"
kubernetes_version = var.eks_cluster_version
eks_oidc_issuer_url = replace(data.aws_eks_cluster.eks_cluster.identity[0].oidc[0].issuer, "https://", "")

addon_context = {
Expand All @@ -12,4 +11,9 @@ locals {
eks_cluster_id = data.aws_eks_cluster.eks_cluster.id
tags = var.tags
}

addon_config = {
kubernetes_version = var.eks_cluster_version
most_recent = true
}
}
11 changes: 6 additions & 5 deletions examples/eks-container-insights/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module "eks_container_insights" {
source = "../../modules/eks-container-insights"
cluster_name = var.cluster_name
enable_amazon_eks_cw_observability = true
create_cloudwatch_observability_irsa_role = true
eks_oidc_provider_arn = local.addon_context.eks_oidc_provider_arn
source = "../../modules/eks-container-insights"
eks_cluster_id = var.eks_cluster_id
enable_amazon_eks_cw_observability = true
create_cloudwatch_observability_irsa_role = true
eks_oidc_provider_arn = local.addon_context.eks_oidc_provider_arn
create_cloudwatch_application_signals_role = true
}
2 changes: 1 addition & 1 deletion examples/eks-container-insights/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "cluster_name" {
variable "eks_cluster_id" {
description = "EKS cluster name"
type = string
}
Expand Down
10 changes: 5 additions & 5 deletions modules/eks-container-insights/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ Use CloudWatch Container Insights to collect, aggregate, and summarize metrics a
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_addon_config"></a> [addon\_config](#input\_addon\_config) | Amazon EKS Managed CloudWatch Observability Add-on config | `any` | `{}` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the EKS cluster | `string` | `"eks-cw"` | no |
| <a name="input_create_cloudwatch_application_signals_role"></a> [create\_cloudwatch\_application\_signals\_role](#input\_create\_cloudwatch\_application\_signals\_role) | Create a Cloudwatch Application Signals service-linked role | `string` | `true` | no |
| <a name="input_create_cloudwatch_observability_irsa_role"></a> [create\_cloudwatch\_observability\_irsa\_role](#input\_create\_cloudwatch\_observability\_irsa\_role) | Create a Cloudwatch Observability IRSA | `string` | `true` | no |
| <a name="input_create_cloudwatch_application_signals_role"></a> [create\_cloudwatch\_application\_signals\_role](#input\_create\_cloudwatch\_application\_signals\_role) | Create a Cloudwatch Application Signals service-linked role | `bool` | `true` | no |
| <a name="input_create_cloudwatch_observability_irsa_role"></a> [create\_cloudwatch\_observability\_irsa\_role](#input\_create\_cloudwatch\_observability\_irsa\_role) | Create a Cloudwatch Observability IRSA | `bool` | `true` | no |
| <a name="input_eks_cluster_id"></a> [eks\_cluster\_id](#input\_eks\_cluster\_id) | Name of the EKS cluster | `string` | `"eks-cw"` | no |
| <a name="input_eks_oidc_provider_arn"></a> [eks\_oidc\_provider\_arn](#input\_eks\_oidc\_provider\_arn) | The OIDC Provider ARN of AWS EKS cluster | `string` | `""` | no |
| <a name="input_enable_amazon_eks_cw_observability"></a> [enable\_amazon\_eks\_cw\_observability](#input\_enable\_amazon\_eks\_cw\_observability) | Enable Amazon EKS CloudWatch Observability add-on | `bool` | `false` | no |
| <a name="input_enable_amazon_eks_cw_observability"></a> [enable\_amazon\_eks\_cw\_observability](#input\_enable\_amazon\_eks\_cw\_observability) | Enable Amazon EKS CloudWatch Observability add-on | `bool` | `true` | no |
| <a name="input_kubernetes_version"></a> [kubernetes\_version](#input\_kubernetes\_version) | Kubernetes version | `string` | `"1.28"` | no |
| <a name="input_most_recent"></a> [most\_recent](#input\_most\_recent) | Most Recent | `string` | `"false"` | no |
| <a name="input_most_recent"></a> [most\_recent](#input\_most\_recent) | Determines if the most recent or default version of the addon should be returned. | `bool` | `false` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit`,`XYZ`) | `map(string)` | `{}` | no |

## Outputs
Expand Down
2 changes: 1 addition & 1 deletion modules/eks-container-insights/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

data "aws_eks_cluster" "eks_cluster" {
name = var.cluster_name
name = var.eks_cluster_id
}
6 changes: 3 additions & 3 deletions modules/eks-container-insights/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ module "cloudwatch_observability_irsa_role" {

data "aws_eks_addon_version" "eks_addon_version" {
addon_name = local.name
kubernetes_version = var.kubernetes_version
most_recent = var.most_recent
kubernetes_version = try(var.addon_config.kubernetes_version, var.kubernetes_version)
most_recent = try(var.addon_config.most_recent, true)
}

resource "aws_eks_addon" "amazon_cloudwatch_observability" {
count = var.enable_amazon_eks_cw_observability ? 1 : 0

cluster_name = var.cluster_name
cluster_name = var.eks_cluster_id
addon_name = local.name
addon_version = try(var.addon_config.addon_version, data.aws_eks_addon_version.eks_addon_version.version)
resolve_conflicts_on_create = try(var.addon_config.resolve_conflicts_on_create, "OVERWRITE")
Expand Down
14 changes: 7 additions & 7 deletions modules/eks-container-insights/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "cluster_name" {
variable "eks_cluster_id" {
description = "Name of the EKS cluster"
default = "eks-cw"
type = string
Expand All @@ -7,7 +7,7 @@ variable "cluster_name" {
variable "enable_amazon_eks_cw_observability" {
description = "Enable Amazon EKS CloudWatch Observability add-on"
type = bool
default = false
default = true
}

variable "addon_config" {
Expand All @@ -23,9 +23,9 @@ variable "kubernetes_version" {
}

variable "most_recent" {
description = "Most Recent"
type = string
default = "false"
description = "Determines if the most recent or default version of the addon should be returned."
type = bool
default = false
}

variable "eks_oidc_provider_arn" {
Expand All @@ -35,13 +35,13 @@ variable "eks_oidc_provider_arn" {
}

variable "create_cloudwatch_observability_irsa_role" {
type = string
type = bool
default = true
description = "Create a Cloudwatch Observability IRSA"
}

variable "create_cloudwatch_application_signals_role" {
type = string
type = bool
default = true
description = "Create a Cloudwatch Application Signals service-linked role"
}
Expand Down

0 comments on commit 83bad93

Please sign in to comment.