2020-03-04 15:44:51 +00:00
|
|
|
resource "aws_efs_file_system" "csi" {
|
2020-10-14 14:29:33 +00:00
|
|
|
count = var.volumes ? 1 : 0
|
2020-03-16 01:53:11 +00:00
|
|
|
creation_token = "${local.random_name}-CSI"
|
2020-03-04 15:44:51 +00:00
|
|
|
|
|
|
|
tags = {
|
|
|
|
Name = "${local.random_name}-efs"
|
|
|
|
User = data.aws_caller_identity.current.arn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_efs_mount_target" "csi" {
|
2020-10-14 14:29:33 +00:00
|
|
|
count = var.volumes ? 1 : 0
|
|
|
|
file_system_id = aws_efs_file_system.csi[0].id
|
2020-03-04 15:44:51 +00:00
|
|
|
subnet_id = data.aws_subnet.default.id
|
2020-10-14 14:29:33 +00:00
|
|
|
security_groups = [aws_security_group.nfs[0].id]
|
2020-03-04 15:44:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 16:16:43 +00:00
|
|
|
data "template_file" "efs_volume_hcl" {
|
2020-10-14 14:29:33 +00:00
|
|
|
count = var.volumes ? 1 : 0
|
2020-04-02 16:16:43 +00:00
|
|
|
template = <<EOT
|
|
|
|
type = "csi"
|
|
|
|
id = "efs-vol0"
|
|
|
|
name = "efs-vol0"
|
2020-10-14 14:29:33 +00:00
|
|
|
external_id = "${aws_efs_file_system.csi[0].id}"
|
2020-04-02 16:16:43 +00:00
|
|
|
plugin_id = "aws-efs0"
|
2021-04-07 17:42:26 +00:00
|
|
|
|
|
|
|
capability {
|
|
|
|
access_mode = "single-node-writer"
|
|
|
|
attachment_mode = "file-system"
|
2020-04-02 16:16:43 +00:00
|
|
|
}
|
|
|
|
|
2021-04-07 17:42:26 +00:00
|
|
|
capability {
|
|
|
|
access_mode = "single-node-reader"
|
|
|
|
attachment_mode = "file-system"
|
|
|
|
}
|
|
|
|
|
|
|
|
EOT
|
2020-04-02 16:16:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "local_file" "efs_volume_hcl" {
|
2020-10-14 14:29:33 +00:00
|
|
|
count = var.volumes ? 1 : 0
|
|
|
|
content = data.template_file.efs_volume_hcl[0].rendered
|
2020-04-02 16:16:43 +00:00
|
|
|
filename = "${path.module}/../csi/input/volume-efs.hcl"
|
|
|
|
file_permission = "0664"
|
|
|
|
}
|