在 Amazon ECS 任務定義中指定 FSx for Windows File Server 檔案系統 - Amazon Elastic Container Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

在 Amazon ECS 任務定義中指定 FSx for Windows File Server 檔案系統

若要將 FSx for Windows File Server 檔案系統磁碟區用於您的容器,請在任務定義中指定磁碟區並掛載點組態。以下任務定義 JSON 片段說明容器 volumesmountPoints 物件的語法。

{ "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

類型:字串

必要:是

授權憑證選項:

domain

類型:字串

必要:是

AWS Directory Service for Microsoft Active Directory (AWS Managed Microsoft AD) 目錄或自我託管 EC2 Active Directory 託管的完整網域名稱。

儲存 FSx for Windows File Server 磁碟區憑證的方法

有兩種不同的方法可存放憑證,以便與憑證參數搭配使用。

  • AWS Secrets Manager 秘密

    您可以使用其他類型的秘密類別,在 AWS Secrets Manager 主控台中建立此登入資料。您可以為每個鍵/值對、使用者名稱/管理員以及密碼/密碼新增一列。

  • Systems Manager 參數

    您可以在 Systems Manager 參數主控台中建立此憑證,方法是在下列範例程式碼片段的表單中輸入文字。

    { "username": "admin", "password": "password" }

任務定義 FSxWindowsFileServerVolumeConfiguration 參數中的 credentialsParameter 保留秘密 ARN 或 Systems Manager 參數 ARN。如需詳細資訊,請參閱 《Secrets Manager 使用者指南》中的什麼是 AWS Secrets ManagerSystems Manager 使用者指南中的Systems Manager 參數存放區