Skip to content

Instantly share code, notes, and snippets.

@koorukuroo
Created November 13, 2025 22:54
Show Gist options
  • Select an option

  • Save koorukuroo/d01ee2b157884381c63392608e6499b9 to your computer and use it in GitHub Desktop.

Select an option

Save koorukuroo/d01ee2b157884381c63392608e6499b9 to your computer and use it in GitHub Desktop.
# terraform/eks.tf
# EKS 클러스터 모듈
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 19.0"
cluster_name = var.cluster_name
cluster_version = var.cluster_version
# VPC/서브넷 연결
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
# 컨트롤 플레인(마스터) 서브넷 (옵션이지만 명시)
control_plane_subnet_ids = module.vpc.public_subnets
# EKS API 서버를 퍼블릭으로 접근 가능하게
cluster_endpoint_public_access = true
# Managed Node Group 설정
eks_managed_node_groups = {
main = {
min_size = 2
max_size = 4
desired_size = 2
instance_types = ["t3.medium"]
capacity_type = "ON_DEMAND"
labels = {
Environment = "lab"
Application = "fastapi"
}
tags = {
Name = "${var.cluster_name}-node"
}
}
}
tags = {
Environment = "lab"
Terraform = "true"
}
}
# EKS Node Group이 ECR에서 이미지를 가져올 수 있도록 IAM 정책 부착
resource "aws_iam_policy_attachment" "eks_ecr_policy" {
name = "${var.cluster_name}-ecr-readonly"
roles = [module.eks.eks_managed_node_groups["main"].iam_role_name]
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment