简体   繁体   English

无法使用 Terraform 在 ECS 任务定义容器上挂载 EFS 卷

[英]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.使用 terraform,我正在尝试将 EFS 卷附加到容器。 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.我已经尝试了一切,但无论我做什么, root_directory选项似乎都被忽略了。

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.谢谢你。

As per the documentation :根据文档

Directory within the Amazon EFS file system to mount as the root directory inside the host. Amazon EFS 文件系统内的目录,作为主机内的根目录挂载。 If this parameter is omitted, the root of the Amazon EFS volume will be used.如果省略此参数,将使用 Amazon EFS 卷的根。 Specifying / will have the same effect as omitting this parameter.指定 / 将具有与省略此参数相同的效果。 This argument is ignored when using authorization_config .使用authorization_config时忽略此参数。

You are specifying authorization_config which means it is ignoring the root_directory setting.您正在指定authorization_config这意味着它忽略了root_directory设置。 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.由于您没有做任何事情,而是禁用了默认情况下已在authorization_config authorization_config

The authorization_config is for use with an EFS Access Point. authorization_config用于 EFS 接入点。 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.如果您使用的是 EFS 接入点,您将在接入点设置中指定安装位置,这就是 Terraform 忽略您当前的root_directory设置的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM