Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to mount an EFS volume on an ECS task definition container using Terraform

Using terraform, I am trying to attach an EFS volume to a container. I would specify a folder to mount on rather than the root path. I have tried everything but no matter what I do, the root_directory option seems to be ignored.

This is my task definition snippet:

resource "aws_ecs_task_definition" "ecs_task_def" {
  family                = "application"
  container_definitions = jsonencode([
    {
      ...
    },
    {
      name : "redis",
      mountPoints = [
        {
          "readOnly" : null,
          "containerPath" : "/bitnami/redis/data",
          "sourceVolume" : "efs"
        }
      ],
      ...
    }
  ])
  ...

  volume {
    name = "efs"

    efs_volume_configuration {
      file_system_id     = var.ecs_efs_filesystem_id
      transit_encryption = "DISABLED"
      root_directory     = "/some/path/here"
      authorization_config {
        iam = "DISABLED"
      }
    }
  }
}

No matter what I try to do, the container always mounts on the at the root. I have tried creating the folders myself but nothing changes. No matter what I do, I always end up with this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

every single time!

I would appreciate it if someone could tell where I could be going wrong. Thank you.

>Solution :

As per the documentation:

Directory within the Amazon EFS file system to mount as the root directory inside the host. If this parameter is omitted, the root of the Amazon EFS volume will be used. Specifying / will have the same effect as omitting this parameter. This argument is ignored when using authorization_config.

You are specifying authorization_config which means it is ignoring the root_directory setting. Since you aren’t doing anything but disabling something that is already disabled by default inside the authorization_config you should try just deleting the authorization_config entirely.

The authorization_config is for use with an EFS Access Point. If you were using an EFS Access Point you would specify the mount location in the Access Point settings, which is why Terraform is ignoring your current root_directory setting.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading