在 Amazon ECS 任务定义中指定 Amazon EFS 文件系统 - Amazon Elastic Container Service
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

在 Amazon ECS 任务定义中指定 Amazon EFS 文件系统

要为容器使用 Amazon EFS 文件系统卷,您必须在任务定义中指定卷和挂载点配置。以下任务定义 JSON 代码段显示容器的 volumesmountPoints 对象的语法。

{ "containerDefinitions": [ { "name": "container-using-efs", "image": "public.ecr.aws/amazonlinux/amazonlinux:latest", "entryPoint": [ "sh", "-c" ], "command": [ "ls -la /mount/efs" ], "mountPoints": [ { "sourceVolume": "myEfsVolume", "containerPath": "/mount/efs", "readOnly": true } ] } ], "volumes": [ { "name": "myEfsVolume", "efsVolumeConfiguration": { "fileSystemId": "fs-1234", "rootDirectory": "/path/to/my/data", "transitEncryption": "ENABLED", "transitEncryptionPort": integer, "authorizationConfig": { "accessPointId": "fsap-1234", "iam": "ENABLED" } } } ] }
efsVolumeConfiguration

类型:对象

必需:否

使用 Amazon EFS 卷时将指定此参数。

fileSystemId

类型:字符串

必需:是

要使用的 Amazon EFS 文件系统 ID。

rootDirectory

类型:字符串

必需:否

Amazon EFS 文件系统中要作为主机内的根目录挂载的目录。如果忽略此参数,将使用 Amazon EFS 卷的根目录。指定/与忽略此参数效果相同。

重要

如果在 authorizationConfig 中指定了 EFS 访问点,则必须省略根目录值,或者将其设置为 /,以便在 EFS 访问点上强制执行设置的路径。

transitEncryption

类型:字符串

有效值:ENABLED | DISABLED

必需:否

指定是否对 Amazon ECS 主机和 Amazon EFS 服务器之间传输的 Amazon EFS 数据启用加密。如果使用 Amazon EFS IAM 授权,则必须启用传输加密。如果忽略此参数,将使用默认值DISABLED。有关更多信息,请参阅《Amazon Elastic File System 用户指南》中的加密传输中的数据

transitEncryptionPort

类型:整数

必需:否

在 Amazon ECS 主机和 Amazon EFS 服务器之间发送加密数据时要使用的端口。如果未指定传输加密端口,将使用 Amazon EFS 挂载帮助程序使用的端口选择策略。有关更多信息,请参阅《Amazon Elastic File System 用户指南》中的 EFS 挂载帮助程序

authorizationConfig

类型:对象

必需:否

Amazon EFS 文件系统的授权配置详细信息。

accessPointId

类型:字符串

必需:否

要使用的接入点 ID。如果指定了访问点,则必须省略在 efsVolumeConfiguration 中指定的根目录值,或者将其设置为 /,以便在 EFS 访问点上强制执行设置的路径。如果使用接入点,则必须在EFSVolumeConfiguration中启用传输加密。有关更多信息,请参阅《Amazon Elastic File System 用户指南》中的使用 Amazon EFS 接入点

iam

类型:字符串

有效值:ENABLED | DISABLED

必需:否

指定挂载 Amazon EFS 文件系统时是否使用在任务定义中定义的 Amazon ECS 任务 IAM 角色。如果启用,则必须在EFSVolumeConfiguration中启用传输加密。如果忽略此参数,将使用默认值DISABLED。有关更多信息,请参阅适用于任务的 IAM 角色