在 Amazon ECS 任务定义中指定适用于 Windows File Server 的 FSx 文件系统
要为容器使用 FSx for Windows File Server 文件系统卷,请在任务定义中指定卷和挂载点配置。以下任务定义 JSON 代码段显示容器的 volumes
和 mountPoints
对象的语法。
{ "containerDefinitions": [ { "entryPoint": [ "powershell", "-Command" ], "portMappings": [], "command": ["New-Item -Path C:\\fsx-windows-dir\\index.html -ItemType file -Value '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>It Works!</h2> <p>You are using Amazon FSx for Windows File Server file system for persistent container storage.</p>' -Force"], "cpu": 512, "memory": 256, "image": "mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019", "essential": false, "name": "container1", "mountPoints": [ { "sourceVolume": "fsx-windows-dir", "containerPath": "C:\\fsx-windows-dir", "readOnly": false } ] }, { "entryPoint": [ "powershell", "-Command" ], "portMappings": [ { "hostPort": 443, "protocol": "tcp", "containerPort": 80 } ], "command": ["Remove-Item -Recurse C:\\inetpub\\wwwroot\\* -Force; Start-Sleep -Seconds 120; Move-Item -Path C:\\fsx-windows-dir\\index.html -Destination C:\\inetpub\\wwwroot\\index.html -Force; C:\\ServiceMonitor.exe w3svc"], "mountPoints": [ { "sourceVolume": "fsx-windows-dir", "containerPath": "C:\\fsx-windows-dir", "readOnly": false } ], "cpu": 512, "memory": 256, "image": "mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019", "essential": true, "name": "container2" } ], "family": "fsx-windows", "executionRoleArn": "arn:aws:iam::111122223333:role/ecsTaskExecutionRole", "volumes": [ { "name": "fsx-windows-dir", "fsxWindowsFileServerVolumeConfiguration": { "fileSystemId": "fs-0eeb5730b2EXAMPLE", "authorizationConfig": { "domain": "example.com", "credentialsParameter": "arn:arn-1234" }, "rootDirectory": "share" } } ] }
FSxWindowsFileServerVolumeConfiguration
-
类型:对象
必需:否
当您使用 FSx for Windows File Server 文件系统进行任务存储时,指定此参数。
fileSystemId
-
类型:字符串
必需:是
要使用的 FSx for Windows File Server 文件系统 ID。
rootDirectory
-
类型:字符串
必需:是
FSx for Windows File Server 文件系统中要作为主机内的根目录挂载的目录。
authorizationConfig
-
credentialsParameter
-
类型:字符串
必需:是
授权凭据选项:
-
Secrets Manager 密钥的 Amazon Resource Name (ARN)。
-
Secrets Manager 参数的 Amazon Resource Name (ARN)。
-
domain
-
类型:字符串
必需:是
由 Amazon Directory Service for Microsoft Active Directory(Amazon Managed Microsoft AD)目录托管的完全限定域名或自托管 EC2 Active Directory。
存储 FSx for Windows File Server 卷凭证的方法
存储凭据的凭据有两种不同的方法,以便与凭据参数一起使用。
-
Amazon Secrets Manager 密钥
此凭据可以在 Amazon Secrets Manager 控制台中使用其他密钥类型类别。您可以为每个键/值对、用户名/管理员和密码/
password
添加一行。 -
Systems Manager 参数
通过以下示例代码片段中的形式输入文本,可以在 Systems Manager 参数控制台中创建此凭证。
{ "username": "admin", "password":
"password"
}
任务定义 FSxWindowsFileServerVolumeConfiguration
参数中的 credentialsParameter
将保存密钥 ARN 或 Systems Manager 参数 ARN。有关更多信息,请参阅 Secrets Manager用户指南中的什么是 Amazon Secrets Manager以及 Systems Manager 用户指南中的 Systems Manager 参数存储。