EKS Cluster Module - Reference Guide
Overview
The Kosmos EKS Cluster module creates a simple production-ready EKS cluster using the Kosmos Provider, conforming to Samsung Security Checklist requirements.
Requirements
| Name | Version |
|---|---|
| terraform | >= 1.13 |
| aws | >= 5.95 |
| kosmos | >= 0.11 |
Artifacts
Download the Terraform module from the Terraform Artifacts page:
| Artifact | Version |
|---|---|
| EKS (Amazon Web Services) Module | v3.2.2 |
Quick Start
module "eks_cluster" {
source = "https://srin-s3-terraform-modules.s3.ap-southeast-1.amazonaws.com/terraform-kosmos-eks-v3.2.2.tar.gz"
fleet_name = "production-fleet"
kosmos_owner = "admin-user"
aws_region = "ap-northeast-2"
cluster_name = "prod-eks-cluster"
eks_version = "1.30"
oidc_provider_arn = "arn:aws:iam::123456789:oidc-provider/console.kosmos.spcplatform.com/oidc-name"
public_access_cidrs = ["210.94.41.89/32"]
}
Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| fleet_name | string | ✓ | - | Target fleet in Kosmos where the cluster will be deployed |
| kosmos_owner | string | ✓ | - | Kosmos user ID as owner of the cluster |
| cluster_name | string | ✓ | - | EKS cluster name |
| oidc_provider_arn | string | ✓ | - | OIDC ARN for temporary AWS credentials |
| public_access_cidrs | list(string) | ✓ | - | List of IP addresses that can access the cluster |
| aws_region | string | ✓ | - | AWS region target |
| vpc_cidr | string | - | "10.0.0.0/16" | VPC CIDR block |
| create_vpc | bool | - | true | Whether to create a new VPC |
| eks_version | string | ✓ | - | Kubernetes version (e.g., “1.30”) |
| external_nat_ip_ids | list(string) | - | [] | List of Elastic IDs addresses to be used for the NAT Gateway |
| enable_nat_gateway | bool | - | true | A Boolean to create a NAT Gateway |
| cluster_public_access | bool | - | true | Whether to allow public access to the cluster |
| bastion_instance_type | string | - | "t3.micro" | Bastion host instance type |
| bastion_volume_size | number | - | 20 | Bastion host EBS volume size in GB |
| bastion_ssh_port | number | - | 4222 | SSH port for bastion host |
| bastion_state | string | - | stopped | State of the Bastion instance. Valid values are stopped, running |
| bastion_eip_id | string | - | null | Elastic IPs ID to be assigned to the Bastion instance. Create Elastic IP is empty. |
| ami_type | string | - | "amazon-linux-2023/x86_64/standard" | EKS-optimized AMI type |
| node_groups | object | - | [] | Node groups configuration |
| create_eks_node_security_group | bool | - | true | Whether to create EKS control plane security group |
| vpc_id | string | - | null | VPC ID (required if create_vpc = false) |
| eks_node_security_group_ids | string | - | null | EKS security group ID (required if create_eks_control_plane_security_group = false) |
| eks_subnet_ids | list(string) | - | [] | EKS subnet IDs (required if create_vpc = false) |
| eks_bastion_subnet_id | string | - | null | Bastion subnet ID (required if create_vpc = false) |
| kosmos_tier | string | - | null | Kosmos environment tier (dev, stg, or null for PRD) |
| vpc_endpoint_security_group_ids | string | - | "" | VPC Endpoint security group ID (required if create_eks_node_security_group = true and create_vpc = false) |
| enabled_vpc_endpoint_gateway | list(string) | - | [] | Map of services to enable VPC endpoints for the EKS cluster type Gateway |
| enabled_vpc_endpoint_interface | list(string) | - | [] | Map of services to enable VPC endpoints for the EKS cluster type Interface |
| node_group_security_group_egress_rule | map(object) | - | {} | Map of Egress Rule for the Node Group’s Security Group Rules |
| node_group_security_group_ingress_rule | map(object) | - | {} | Map of Ingress Rule for the Node Group’s Security Group Rules |
| create_eks_cluster_security_group | bool | - | true | Whether to create EKS Cluster security group |
| eks_cluster_security_group_ids | string | - | "" | ID of the AWS security group to associate with eks cluster |
| cluster_security_group_ingress_rule | map(object) | - | {} | Map of Ingress Rule for the Cluster’s Security Group Rules |
| cluster_security_group_egress_rule | map(object) | - | {} | Map of Egress Rule for the Cluster’s Security Group Rules |
| enable_irsa | bool | - | true | To create an IAM OIDC identity provider for the EKS cluster |
| oidc_provider_audiences | list(string) | - | [] | Audiences for the IAM OIDC identity provider |
Examples
Basic Usage
module "eks_cluster" {
source = "https://srin-s3-terraform-modules.s3.ap-southeast-1.amazonaws.com/terraform-kosmos-eks-v3.2.2.tar.gz"
fleet_name = "production-fleet"
cluster_name = "prod-eks-cluster"
kosmos_owner = "admin"
oidc_provider_arn = "arn:aws:iam::123456789:oidc-provider/console.kosmos.spcplatform.com/oidc-name"
public_access_cidrs = ["10.0.0.0/8", "192.168.0.0/16"]
aws_region = "ap-southeast-1"
eks_version = "1.30"
}
Custom VPC Usage
module "eks_cluster" {
source = "https://srin-s3-terraform-modules.s3.ap-southeast-1.amazonaws.com/terraform-kosmos-eks-v3.2.2.tar.gz"
create_vpc = false
vpc_id = "vpc-12345678"
eks_subnet_ids = ["subnet-12345678", "subnet-87654321"]
eks_bastion_subnet_id = "subnet-11111111"
fleet_name = "staging-fleet"
cluster_name = "staging-eks-cluster"
kosmos_owner = "dev-team"
eks_version = "1.30"
oidc_provider_arn = "arn:aws:iam::123456789:oidc-provider/console.kosmos.spcplatform.com/oidc-name"
public_access_cidrs = ["10.0.0.0/8"]
aws_region = "ap-southeast-1"
}
Fully Private Cluster
- Disabled NAT Gateway by setting
enable_nat_gatewaytofalse - Setting up the minimum Security group permission
- Setting up the minimum VPC Endpoint requred
module "eks_cluster" {
source = "https://srin-s3-terraform-modules.s3.ap-southeast-1.amazonaws.com/terraform-kosmos-eks-v3.2.2.tar.gz"
# EKS Node Group Security Group
node_group_security_group_egress_rule = {}
node_group_security_group_ingress_rule = {}
# EKS Cluster Security Group
cluster_security_group_ingress_rule = {}
cluster_security_group_egress_rule = {}
# NAT Gateway
enable_nat_gateway = false
# VPC Endpoint
enabled_vpc_endpoint_gateway = ["s3"]
enabled_vpc_endpoint_interface = ["ec2", "ecr.api", "ecr.dkr", "eks", "kms", "logs", "elasticloadbalancing", "autoscaling", "eks-auth", "sts"]
}
Semi Private Cluster
- Enabled NAT Gateway by setting
enable_nat_gatewaytotrue - Defined the Security group permission
- Setting up the minimum VPC Endpoint requred
module "eks_cluster" {
source = "https://srin-s3-terraform-modules.s3.ap-southeast-1.amazonaws.com/terraform-kosmos-eks-v3.2.2.tar.gz"
# EKS Node Group Security Group
node_group_security_group_egress_rule = {
allow_all = {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "Allow all communication"
}
cluster-node = {
from_port = 443
to_port = 443
protocol = "all"
source_security_group_id = module.eks_cluster.aws_security_group_cluster_id
description = "Allow all communication from cluster to node"
}
}
node_group_security_group_ingress_rule = {
cluster-node = {
from_port = 443
to_port = 443
protocol = "all"
source_security_group_id = module.eks_cluster.aws_security_group_cluster_id
description = "Allow all communication from node to cluster"
}
}
# EKS Cluster Security Group
cluster_security_group_ingress_rule = {
cluster-node = {
from_port = 443
to_port = 443
protocol = "all"
source_security_group_id = module.eks_cluster.aws_security_group_node_id
description = "Allow all communication from node to cluster"
}
}
cluster_security_group_egress_rule = {
allow_all = {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "Allow all communication"
}
cluster-node = {
from_port = 443
to_port = 443
protocol = "all"
source_security_group_id = module.eks_cluster.aws_security_group_node_id
description = "Allow all communication from cluster to node"
}
}
# NAT Gateway
enable_nat_gateway = true
# VPC Endpoint
enabled_vpc_endpoint_gateway = ["s3"]
enabled_vpc_endpoint_interface = ["ec2", "ecr.api", "ecr.dkr", "eks", "kms", "logs", "elasticloadbalancing", "autoscaling", "eks-auth", "sts"]
}
Advanced Configuration
module "eks_cluster" {
source = "https://srin-s3-terraform-modules.s3.ap-southeast-1.amazonaws.com/terraform-kosmos-eks-v3.2.2.tar.gz"
fleet_name = "advanced-fleet"
cluster_name = "advanced-eks-cluster"
kosmos_owner = "platform-team"
eks_version = "1.30"
oidc_provider_arn = "arn:aws:iam::123456789:oidc-provider/console.kosmos.spcplatform.com/oidc-name"
public_access_cidrs = ["10.0.0.0/8"]
aws_region = "ap-southeast-1"
# Custom node groups
node_groups = [
{
name = "worker-nodes"
instance_type = "t3.medium"
min_size = 2
max_size = 10
desired_size = 3
}
]
# Custom bastion configuration
bastion_instance_type = "t3.small"
bastion_volume_size = 30
bastion_ssh_port = 2222
}
Resources Created
AWS Resources
- VPC: 3 public subnets, 3 private subnets, NAT Gateway, Internet Gateway
- Bastion Host: EC2 instance for secure cluster access
- KMS: Dedicated keys for S3 bucket and cluster encryption
- Security Groups: Default and EKS-specific security groups
- S3 Bucket: Encrypted bucket for logs with lifecycle policies
- IAM: Kosmos role and EKS cluster role
Kosmos Resources
- EKS Cluster: Kubernetes cluster with logging enabled
- Security Groups: EKS cluster security group
Security Features
This module implements the following security measures:
- Secrets Encryption: KMS-based encryption for cluster secrets
- Private Access: API server endpoint access control
- Network Security: VPC flow logs and security group restrictions
- Data Protection: S3 bucket encryption and lifecycle policies
- Access Control: IAM roles and policies for least privilege access
Required Permissions
The following AWS permissions are required to use this module:
KMS
kms:CreateKey,kms:DescribeKey,kms:EnableKey,kms:DisableKeykms:ScheduleKeyDeletion,kms:CancelKeyDeletionkms:CreateAlias,kms:DeleteAlias,kms:UpdateAliaskms:ListAliases,kms:PutKeyPolicy,kms:GetKeyPolicy,kms:ListKeys
IAM
iam:CreateRole,iam:GetRole,iam:DeleteRoleiam:UpdateAssumeRolePolicy,iam:AttachRolePolicy,iam:DetachRolePolicyiam:ListAttachedRolePolicies,iam:PassRolests:GetCallerIdentity
S3
s3:CreateBucket,s3:DeleteBucket,s3:PutBucketAcl,s3:GetBucketAcls3:PutBucketPolicy,s3:GetBucketPolicy,s3:PutBucketPublicAccessBlocks3:GetBucketPublicAccessBlock,s3:PutBucketVersioning,s3:GetBucketVersionings3:PutBucketLogging,s3:GetBucketLogging,s3:PutBucketLifecycleConfigurations3:GetBucketLifecycleConfiguration,s3:PutEncryptionConfigurations3:GetEncryptionConfiguration,s3:PutBucketTagging,s3:GetBucketTagging
VPC
ec2:CreateVpc,ec2:DeleteVpc,ec2:DescribeVpcs,ec2:ModifyVpcAttributeec2:CreateSubnet,ec2:DeleteSubnet,ec2:DescribeSubnetsec2:CreateRouteTable,ec2:DeleteRouteTable,ec2:AssociateRouteTableec2:DisassociateRouteTable,ec2:CreateRoute,ec2:DeleteRouteec2:ReplaceRoute,ec2:ReplaceRouteTableAssociationec2:CreateInternetGateway,ec2:AttachInternetGateway,ec2:DetachInternetGatewayec2:DeleteInternetGateway,ec2:CreateNatGateway,ec2:DeleteNatGatewayec2:DescribeNatGateways,ec2:AllocateAddress,ec2:ReleaseAddressec2:CreateSecurityGroup,ec2:DeleteSecurityGroupec2:AuthorizeSecurityGroupIngress,ec2:RevokeSecurityGroupIngressec2:AuthorizeSecurityGroupEgress,ec2:RevokeSecurityGroupEgressec2:CreateNetworkAcl,ec2:DeleteNetworkAcl,ec2:CreateNetworkAclEntryec2:DeleteNetworkAclEntry,ec2:AssociateNetworkAcl,ec2:DisassociateNetworkAclec2:CreateVpcEndpoint,ec2:DeleteVpcEndpoints,ec2:DescribeVpcEndpointsec2:CreateFlowLogs,ec2:DeleteFlowLogs,ec2:DescribeFlowLogsec2:DescribeNetworkInterfaces,ec2:DescribeTags,ec2:DescribeRouteTablesec2:DescribeVpcs,ec2:DescribeSecurityGroups,ec2:CreateTagsec2:DescribeAvailabilityZones
EKS
eks:*autoscaling:CreateAutoScalingGroup,autoscaling:UpdateAutoScalingGroupautoscaling:DeleteAutoScalingGroup,autoscaling:DescribeAutoScalingGroupslogs:CreateLogGroup,logs:PutRetentionPolicy,logs:DescribeLogGroups
Samsung Security Checklist
List of checklist that conform the Samsung Security Checklist
- EC2
- Instance metadata Service
- Ensure that the vulnerable version of Instance metadata service is not in use (only IMDS V2 should be in use, and if not necessary, Instance metadata service should be disabled)
- Instance metadata Service
- EKS
- Cluster Management
- Ensure that “Secrets encryption” is turned on
- Networking Management
- Ensure the API Server Endpoint Access is private and accept the requests only from the EKS VPC
- If the value of “API server endpoint access” is ‘Public’, ensure that the required access targets are limited.
- Logging Management
- Cluster Management
- S3 Bucket Data Protection
- In-Transit Encrypted
- Ensure that S3 buckets use encrypted communication protocol (HTTPS)
- In-Transit Encrypted
- S3 Bucket Management
- S3 Assets Management (Required Tags)
- Ensure that the required tags are attached to all the S3 buckets.
- Data Retention Policy
- Ensure that lifecycle rule is set on confidential/personal information containing S3 buckets to delete the data periodically.
- S3 Assets Management (Required Tags)
- Logging Configuration
- Enabling VPC Flow logs
- Ensure that the VPC Flow logs is enabled to log.
- Enabling VPC Flow logs
- KMS
- Key generation
- Ensure that keys are dedicated for the sole purpose
- Key Rotation Configuration
- Ensure that the Key Rotation is activated.
- Key generation
List of checklist that does not conform to the Samsung Security Checklist
- VPC Configuration
- Private Subnet Access Control
- Check if nat is connected to routetables of private subnet.
violation is due to NAT gateway being needed for EKS cluster to connect towards Kosmos' control plane & to pull container images
- Check if nat is connected to routetables of private subnet.
- Private Subnet Access Control
- Network ACLs & Security groups
- Security Group Management
- Ensure that Security Group’s inbound / outbound rules comply the following management policy.
- A Policy allowing wide range of CIDR blocks (exceeding 24 bit mask)
- Do not use anywhere outbound (0.0.0.0/0)
- A Policy allowing all ports
- Ensure that Security Group’s inbound / outbound rules comply the following management policy.
- SG Description Management
- Ensure that Inbound / Outbound rules of the Security Groups have the mandatory description
The EKS default security group is causing this violation.
- Security Group Management
- EKS
- Security Group Management
- Ensure that Cluster’s security groups only allow the communications necessary for the EKS Cluster.
The EKS default security group is not managed by Terraform.
- Security Group Management