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:
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.
