Configures an EKS cluster to enable control plane logging and sets up the associated CloudWatch log group.

Terraform Template

variable "cluster_name" {
  default = "example"
  type = "${string}"
}

resource "aws_cloudwatch_log_group" "example" {
  name = "/aws/eks/${var.cluster_name}/cluster"
  retention_in_days = 7
}

resource "aws_eks_cluster" "example" {
  depends_on = ["aws_cloudwatch_log_group.example"]
  enabled_cluster_log_types = ["api", "audit"]
  name = "var.cluster_name"
}