-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca761dd
commit 9acf6c3
Showing
7 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
resource "random_pet" "efs" { | ||
length = 2 | ||
} | ||
|
||
resource "aws_efs_file_system" "storage_class" { | ||
creation_token = "${var.namespace}-${random_pet.efs.id}" | ||
encrypted = true | ||
performance_mode = "generalPurpose" | ||
throughput_mode = "elastic" | ||
|
||
|
||
tags = { | ||
Name = "${var.namespace}-efs-${random_pet.efs.id}" | ||
} | ||
} | ||
|
||
resource "aws_efs_backup_policy" "storage_class" { | ||
file_system_id = aws_efs_file_system.storage_class.id | ||
|
||
backup_policy { | ||
status = "DISABLED" | ||
} | ||
} | ||
|
||
resource "aws_security_group" "storage_class_nfs" { | ||
name = "nfs-security-group" | ||
description = "Security group for NFS traffic" | ||
vpc_id = var.vpc_id | ||
|
||
ingress { | ||
description = "NFS inbound" | ||
from_port = 2049 | ||
to_port = 2049 | ||
protocol = "tcp" | ||
security_groups = [var.primary_workers_security_group_id] | ||
} | ||
|
||
tags = { | ||
Name = "nfs-security-group" | ||
} | ||
} | ||
|
||
|
||
resource "aws_efs_mount_target" "storage_class" { | ||
for_each = { for subnet in var.private_subnets : subnet => subnet } | ||
file_system_id = aws_efs_file_system.storage_class.id | ||
subnet_id = each.value | ||
security_groups = [aws_security_group.storage_class_nfs.id] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "efs_id" { | ||
value = aws_efs_file_system.storage_class.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
variable "namespace" { | ||
description = "The namespace to use for the efs resource" | ||
type = string | ||
} | ||
|
||
variable "private_subnets" { | ||
description = "A list of the subnets in which the aws_efs_mount_target will be deployed." | ||
type = list(string) | ||
} | ||
|
||
variable "primary_workers_security_group_id" { | ||
description = "The security group ID of the primary workers." | ||
type = string | ||
} | ||
|
||
variable "vpc_id" { | ||
description = "The ID of the VPC in which the storage_class_nfs security group will be deployed." | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters