-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathefs.tf
54 lines (44 loc) · 1.12 KB
/
efs.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
provider "aws" {
region = var.region
}
data "aws_eks_cluster" "eks" {
name = var.cluster_name
}
output "eks_vpc_id" {
value = data.aws_eks_cluster.eks.vpc_config[0].vpc_id
}
data "aws_subnets" "private" {
filter {
name = "vpc-id"
values = [data.aws_eks_cluster.eks.vpc_config[0].vpc_id]
}
tags = {
"Name" = "private"
}
}
resource "aws_efs_file_system" "filesystem" {
creation_token = "filesystem"
lifecycle_policy {
transition_to_ia = "AFTER_30_DAYS"
}
tags = {
Name = "eks-filesystem"
}
}
resource "aws_security_group" "filesystem" {
name = "efs_security_group"
description = "Security group for EFS"
vpc_id = data.aws_eks_cluster.eks.vpc_config[0].vpc_id
ingress {
from_port = 2049
to_port = 2049
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_efs_mount_target" "filesystem" {
count = length(data.aws_subnets.private.ids)
file_system_id = aws_efs_file_system.filesystem.id
subnet_id = data.aws_subnets.private.ids[count.index]
security_groups = [aws_security_group.filesystem.id]
}