本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
為 Amazon ECS 的 Fargate 暫時性儲存建立加密金鑰
建立客戶受管金鑰來加密儲存在 Fargate 暫時性儲存體上的資料。
注意
Fargate 暫時性儲存加密搭配客戶受管金鑰不適用於 Windows 任務叢集。
使用客戶受管金鑰的 Fargate 暫時性儲存加密不適用於platformVersions
早於 的 1.4.0
。
Fargate 會在僅供 Fargate 使用的暫時性儲存體上保留空間,且不會向您收取該空間的費用。配置可能與非客戶受管金鑰任務不同,但總空間保持不變。您可以在 等工具中檢視此變更df
。
Fargate 暫時性儲存不支援多區域金鑰。
Fargate 暫時性儲存不支援 KMS 金鑰別名。
若要建立客戶受管金鑰 (CMK) 來加密 Fargate 中的暫時性儲存 AWS KMS,請遵循下列步驟。
-
導覽至 https://https://console.aws.amazon.com/kms
。 -
請遵循《 AWS Key Management Service 開發人員指南》中建立金鑰的指示。
-
建立 AWS KMS 金鑰時,請務必在金鑰政策中提供 Fargate 服務相關的 AWS KMS 操作許可。政策中必須允許下列 API 操作,才能將客戶受管金鑰與 Amazon ECS 叢集資源搭配使用。
-
kms:GenerateDataKeyWithoutPlainText
‐ 呼叫 從提供的金鑰GenerateDataKeyWithoutPlainText
產生加密的資料 AWS KMS 金鑰。 -
kms:CreateGrant
‐ 將授予新增至客戶受管金鑰。授予控制對指定 AWS KMS 金鑰的存取,該金鑰允許存取授予 Amazon ECS Fargate 所需的操作。如需使用授權的詳細資訊,請參閱 AWS Key Management Service 開發人員指南。這可讓 Amazon ECS Fargate 執行下列動作:-
呼叫
Decrypt
AWS KMS 以取得加密金鑰,以解密暫時性儲存資料。 -
設定淘汰委託人以允許 服務至
RetireGrant
。
-
-
kms:DescribeKey
‐ 提供客戶受管金鑰詳細資訊,以允許 Amazon ECS 驗證金鑰是否對稱且已啟用。
下列範例顯示您要套用至目標 AWS KMS 金鑰以進行加密的金鑰政策。若要使用範例政策陳述式,請以您自己的資訊取代
使用者輸入預留位置
。一如往常,只設定您需要的許可,但您需要為至少一個使用者提供 AWS KMS 許可,以避免錯誤。{ "Sid": "Allow generate data key access for Fargate tasks.", "Effect": "Allow", "Principal": { "Service":"fargate.amazonaws.com" }, "Action": [ "kms:GenerateDataKeyWithoutPlaintext" ], "Condition": { "StringEquals": { "kms:EncryptionContext:aws:ecs:clusterAccount": [ "
customerAccountId
" ], "kms:EncryptionContext:aws:ecs:clusterName": [ "clusterName
" ] } }, "Resource": "*" }, { "Sid": "Allow grant creation permission for Fargate tasks.", "Effect": "Allow", "Principal": { "Service":"fargate.amazonaws.com" }, "Action": [ "kms:CreateGrant" ], "Condition": { "StringEquals": { "kms:EncryptionContext:aws:ecs:clusterAccount": [ "customerAccountId
" ], "kms:EncryptionContext:aws:ecs:clusterName": [ "clusterName
" ] }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "Decrypt" ] } }, "Resource": "*" }, { "Sid": "Allow describe key permission for cluster operator - CreateCluster and UpdateCluster.", "Effect": "Allow", "Principal": { "AWS":"arn:aws:iam::customerAccountId
:role/customer-chosen-role
" }, "Action": [ "kms:DescribeKey" ], "Resource": "*" }Fargate 任務使用
aws:ecs:clusterAccount
和aws:ecs:clusterName
加密內容金鑰搭配 金鑰進行密碼編譯操作。客戶應新增這些許可,以限制對特定帳戶和/或叢集的存取。當您指定叢集時,請使用叢集名稱而非 ARN。如需詳細資訊,請參閱 AWS KMS 開發人員指南中的加密內容。
建立或更新叢集時,您可以選擇使用 條件金鑰
fargateEphemeralStorageKmsKeyId
。此條件金鑰可讓客戶更精細地控制 IAM 政策。fargateEphemeralStorageKmsKeyId
組態的更新只會在新的服務部署上生效。以下是允許客戶僅將許可授予一組特定核准 AWS KMS 金鑰的範例。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecs:CreateCluster", "ecs:UpdateCluster" ], "Resource": "*", "Condition": { "StringEquals": { "ecs:fargate-ephemeral-storage-kms-key": "arn:aws:kms:
us-west-2
:111122223333
:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
" } } } ] }接下來是拒絕嘗試移除已與叢集建立關聯的 AWS KMS 金鑰的範例。
{ "Version": "2012-10-17", "Statement": { "Effect": "Deny", "Action": [ "ecs:CreateCluster", "ecs:UpdateCluster" ], "Resource": "*", "Condition": { "Null": { "ecs:fargate-ephemeral-storage-kms-key": "true" } } } }
客戶可以使用
describe-cluster
、 或 AWS CLIdescribe-tasks
describe-services
命令,查看其未受管任務或服務任務是否使用 金鑰加密。如需詳細資訊,請參閱《 AWS KMS 開發人員指南》中的 的條件金鑰 AWS KMS。
-