Skip to content

Commit 32d05b1

Browse files
timoguinTim O'Guin
andauthored
feat: Allow enabling the CloudWatch Observability Add-on for EKS (#446)
## Changes - Adds a new `cloudwatch_observability_enabled` variable - Conditionally installs the `amazon-cloudwatch-observability` add-on - Conditionally attaches the AWS-managed CloudWatchAgentServerPolicy to the node role Co-authored-by: Tim O'Guin <tim@auguria.io>
1 parent 4063c62 commit 32d05b1

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ resource "aws_eks_addon" "core" {
5656
"aws-ebs-csi-driver",
5757
var.s3_csi_driver_enabled ? ["aws-mountpoint-s3-csi-driver"] : [],
5858
var.efs_enabled ? ["aws-efs-csi-driver"] : [],
59+
var.cloudwatch_observability_enabled ? ["amazon-cloudwatch-observability"] : [],
5960
]))
6061

6162
cluster_name = aws_eks_cluster.cluster.name

iam.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,14 @@ resource "aws_iam_role_policy_attachment" "csi" {
425425
policy_arn = join("", aws_iam_policy.s3_policy.*.arn)
426426
role = aws_iam_role.node.name
427427
}
428+
429+
# Attach the AWS-managed CloudWatchAgentServerPolicy to the node IAM role.
430+
# We may want to harden this down a bit later, but it's essentially scoped
431+
# to a few read-only calls and the ability to write logs, metrics, and traces
432+
# to CloudWatch (metrics), CloudWatch Logs (logs), and X-Ray (traces).
433+
resource "aws_iam_role_policy_attachment" "cloudwatch_observability" {
434+
count = var.cloudwatch_observability_enabled ? 1 : 0
435+
436+
policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
437+
role = aws_iam_role.node.name
438+
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,8 @@ variable "s3_csi_bucket_names" {
461461
default = [""]
462462
}
463463

464+
variable "cloudwatch_observability_enabled" {
465+
description = "Enable or disable the CloudWatch Observability Add-on for EKS"
466+
type = bool
467+
default = false
468+
}

0 commit comments

Comments
 (0)