terraform { required_version = ">= 1.5.0" required_providers { aws = { source = "hashicorp/aws" version = ">= 5.0" } } } resource "aws_security_group" "efs" { name = "${var.name}-efs-sg" description = "NFS from EKS nodes to model-weights EFS" vpc_id = var.vpc_id ingress { description = "NFS from EKS nodes" from_port = 2049 to_port = 2049 protocol = "tcp" security_groups = [var.eks_node_security_group_id] } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } tags = var.tags } resource "aws_efs_file_system" "this" { creation_token = var.name encrypted = true performance_mode = var.performance_mode throughput_mode = var.throughput_mode lifecycle_policy { transition_to_ia = "AFTER_30_DAYS" } tags = merge(var.tags, { Name = var.name }) } resource "aws_efs_mount_target" "this" { for_each = toset(var.private_subnet_ids) file_system_id = aws_efs_file_system.this.id subnet_id = each.key security_groups = [aws_security_group.efs.id] } # Access point used by inference pods (UID/GID match the container user). resource "aws_efs_access_point" "model_weights" { file_system_id = aws_efs_file_system.this.id posix_user { uid = 1000 gid = 1000 } root_directory { path = "/model-weights" creation_info { owner_uid = 1000 owner_gid = 1000 permissions = "0755" } } tags = var.tags }