Skip to content

Commit feb1f71

Browse files
authored
Merge pull request #270 from mark5cinco/eks-cluster-encryption
EKS: Enable specifying of KMS arn for cluster encryption
2 parents f02567b + 96226cc commit feb1f71

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

aws/_modules/eks/master.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ resource "aws_eks_cluster" "current" {
1010
public_access_cidrs = var.cluster_public_access_cidrs
1111
}
1212

13+
dynamic "encryption_config" {
14+
for_each = var.cluster_encryption_key_arn != null ? toset([1]) : toset([])
15+
content {
16+
resources = ["secrets"]
17+
18+
provider {
19+
key_arn = var.cluster_encryption_key_arn
20+
}
21+
}
22+
}
23+
1324
depends_on = [
1425
aws_iam_role_policy_attachment.master_cluster_policy,
1526
aws_iam_role_policy_attachment.master_service_policy,

aws/_modules/eks/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,9 @@ variable "cluster_public_access_cidrs" {
159159
default = null
160160
description = "List of CIDR blocks which can access the Amazon EKS public API server endpoint. EKS defaults this to a list with 0.0.0.0/0."
161161
}
162+
163+
variable "cluster_encryption_key_arn" {
164+
type = string
165+
default = null
166+
description = "Arn of an AWS KMS symmetric key to be used for encryption of kubernetes resources."
167+
}

aws/cluster/configuration.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ locals {
6060
cluster_endpoint_public_access = lookup(local.cfg, "cluster_endpoint_public_access", true)
6161
cluster_public_access_cidrs_lookup = lookup(local.cfg, "cluster_public_access_cidrs", null)
6262
cluster_public_access_cidrs = local.cluster_public_access_cidrs_lookup == null ? null : split(",", local.cluster_public_access_cidrs_lookup)
63+
64+
cluster_encryption_key_arn = lookup(local.cfg, "cluster_encryption_key_arn", null)
6365
}

aws/cluster/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ module "cluster" {
5454
cluster_endpoint_public_access = local.cluster_endpoint_public_access
5555
cluster_public_access_cidrs = local.cluster_public_access_cidrs
5656

57+
cluster_encryption_key_arn = local.cluster_encryption_key_arn
58+
5759
# cluster module configuration is still map(string)
5860
# once module_variable_optional_attrs isn't experimental anymore
5961
# we can migrate cluster module configuration to map(object(...))

0 commit comments

Comments
 (0)