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
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_ebs_volume" "csi" {
|
2020-10-14 14:29:33 +00:00
|
|
|
count = var.volumes ? 1 : 0
|
2020-03-04 15:44:51 +00:00
|
|
|
availability_zone = var.availability_zone
|
|
|
|
size = 40
|
|
|
|
|
|
|
|
tags = {
|
|
|
|
Name = "${local.random_name}-ebs"
|
|
|
|
User = data.aws_caller_identity.current.arn
|
|
|
|
}
|
|
|
|
}
|
2020-04-02 16:16:43 +00:00
|
|
|
|
|
|
|
data "template_file" "ebs_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 = "ebs-vol0"
|
|
|
|
name = "ebs-vol0"
|
2020-10-14 14:29:33 +00:00
|
|
|
external_id = "${aws_ebs_volume.csi[0].id}"
|
2020-04-02 16:16:43 +00:00
|
|
|
access_mode = "single-node-writer"
|
|
|
|
attachment_mode = "file-system"
|
|
|
|
plugin_id = "aws-ebs0"
|
|
|
|
EOT
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
access_mode = "single-node-writer"
|
|
|
|
attachment_mode = "file-system"
|
|
|
|
plugin_id = "aws-efs0"
|
|
|
|
EOT
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "local_file" "ebs_volume_hcl" {
|
2020-10-14 14:29:33 +00:00
|
|
|
count = var.volumes ? 1 : 0
|
|
|
|
content = data.template_file.ebs_volume_hcl[0].rendered
|
2020-04-02 16:16:43 +00:00
|
|
|
filename = "${path.module}/../csi/input/volume-ebs.hcl"
|
|
|
|
file_permission = "0664"
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|