{"Version":"2012-10-17","Id":"key-consolepolicy-3","Statement":[{"Sid":"Enable IAM User Permissions","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::ACCOUNT_NUMBER:root"},"Action":"kms:*","Resource":"*"},{"Sid":"Allow creating encrypted EBS volumes for EC2 use","Effect":"Allow","Principal":{"AWS":["arn:aws:iam::ACCOUNT_NUMBER:role/gke-CLUSTER_ID-management","arn:aws:iam::ACCOUNT_NUMBER:user/AWS_USER","arn:aws:iam::ACCOUNT_NUMBER:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"]},"Action":["kms:GenerateDataKeyWithoutPlaintext","kms:Decrypt"],"Resource":"*","Condition":{"StringEquals":{"kms:CallerAccount":"ACCOUNT_NUMBER","kms:ViaService":"ec2.AWS_REGION.amazonaws.com"}}},{"Sid":"Allow attaching encrypted EBS volumes for EC2 Use","Effect":"Allow","Principal":{"AWS":["arn:aws:iam::ACCOUNT_NUMBER:role/CLUSTER_ID-management","arn:aws:iam::ACCOUNT_NUMBER:role/CLUSTER_ID-controlplane","arn:aws:iam::ACCOUNT_NUMBER:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"]},"Action":["kms:CreateGrant","kms:ListGrants","kms:RevokeGrant"],"Resource":"*","Condition":{"StringEquals":{"kms:CallerAccount":"ACCOUNT_NUMBER","kms:ViaService":"ec2.AWS_REGION.amazonaws.com"}}}]}
请替换以下内容:
ACCOUNT_NUMBER:您的 AWS 账号,例如 1234567890。
CLUSTER_ID:GKE on AWS 管理集群 ID,例如 gke-12345678。
AWS_USER:您的 AWS 用户名。
AWS_REGION:GKE on AWS 集群在其中运行的 AWS 区域,例如 us-east1。
配置资源以使用客户管理的 CMK
本部分介绍如何为 GKE on AWS 组件配置客户管理的 CMK。在升级现有组件之前,请参阅将 CMK 与现有集群结合使用。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Using a customer managed CMK to encrypt volumes\n\nGKE on AWS uses the AWS Key Management Service (KMS) to encrypt\nEBS volumes. GKE on AWS 1.7 and higher supports encrypting volumes\nwith customer managed\n[Customer Master Keys](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk)\n(CMKs). GKE on AWS versions 1.6.x and lower support\n[AWS Managed Customer Master Keys](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk) only.\n\nThis topic describes how to set up customer managed CMK to encrypt volumes. If\nyou don't set up customer managed CMK, GKE on AWS uses AWS managed\nCMKs by default.\n\nOverview\n--------\n\nThe following GKE on AWS components support customer managed\nCMK encrypted volumes:\n\n- Bastion host root volume\n- Management service root volumes\n- Management service etcd data volumes\n- User cluster control plane root volumes\n- User cluster control plane etcd data volumes\n- User cluster node root volumes\n\nYou specify keys in your management service, cluster, and node pool\nconfiguration.\n\nPrerequisites\n-------------\n\nTo use customer managed CMK for GKE on AWS root volumes, you need the following:\n\n- Permissions to create or use an AWS KMS key policy. For more information, see [Using key policies in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html).\n\nCreate a key policy\n-------------------\n\nYour AWS KMS keys must have a key policy that allows GKE on AWS to\ncreate and read volumes encrypted with a customer managed CMK. An example policy\nis provided in the following section. To create the policy, perform the\nfollowing the steps:\n\n1. From your `anthos-aws` directory, use\n `terraform` to get the ID of your management service.\n\n ```sh\n cd anthos-aws\n terraform output cluster_id\n ```\n The output includes your management service ID. In the example below, the ID is `gke-12345abc`. \n\n terraform output cluster_id\n gke-12345abc\n\n \u003cbr /\u003e\n\n2. [Create an AWS KMS key policy](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html)\n with the following contents:\n\n {\n \"Version\": \"2012-10-17\",\n \"Id\": \"key-consolepolicy-3\",\n \"Statement\": [\n {\n \"Sid\": \"Enable IAM User Permissions\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e:root\"\n },\n \"Action\": \"kms:*\",\n \"Resource\": \"*\"\n },\n {\n \"Sid\": \"Allow creating encrypted EBS volumes for EC2 use\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"AWS\": [\n \"arn:aws:iam::\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e:role/gke-\u003cvar translate=\"no\"\u003eCLUSTER_ID\u003c/var\u003e-management\",\n \"arn:aws:iam::\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e:user/\u003cvar translate=\"no\"\u003eAWS_USER\u003c/var\u003e\",\n \"arn:aws:iam::\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling\"\n ]\n },\n \"Action\": [\n \"kms:GenerateDataKeyWithoutPlaintext\",\n \"kms:Decrypt\"\n ],\n \"Resource\": \"*\",\n \"Condition\": {\n \"StringEquals\": {\n \"kms:CallerAccount\": \"\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e\",\n \"kms:ViaService\": \"ec2.\u003cvar translate=\"no\"\u003eAWS_REGION\u003c/var\u003e.amazonaws.com\"\n }\n }\n },\n {\n \"Sid\": \"Allow attaching encrypted EBS volumes for EC2 Use\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"AWS\": [\n \"arn:aws:iam::\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e:role/\u003cvar translate=\"no\"\u003eCLUSTER_ID\u003c/var\u003e-management\",\n \"arn:aws:iam::\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e:role/\u003cvar translate=\"no\"\u003eCLUSTER_ID\u003c/var\u003e-controlplane\",\n \"arn:aws:iam::\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling\"\n ]\n },\n \"Action\": [\n \"kms:CreateGrant\",\n \"kms:ListGrants\",\n \"kms:RevokeGrant\"\n ],\n \"Resource\": \"*\",\n \"Condition\": {\n \"StringEquals\": {\n \"kms:CallerAccount\": \"\u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e\",\n \"kms:ViaService\": \"ec2.\u003cvar translate=\"no\"\u003eAWS_REGION\u003c/var\u003e.amazonaws.com\"\n }\n }\n }\n ]\n }\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eACCOUNT_NUMBER\u003c/var\u003e: your AWS account number--- for example, `1234567890`.\n - \u003cvar translate=\"no\"\u003eCLUSTER_ID\u003c/var\u003e: your GKE on AWS management cluster ID--- for example `gke-12345678`.\n - \u003cvar translate=\"no\"\u003eAWS_USER\u003c/var\u003e: your AWS user name.\n - \u003cvar translate=\"no\"\u003eAWS_REGION\u003c/var\u003e: The AWS region where your GKE on AWS clusters run--- for example `us-east1`.\n\nConfiguring resources to use a customer managed CMK\n---------------------------------------------------\n\nThis section explains how to configure customer managed CMK for\nGKE on AWS components. Before upgrading existing components, see\n[Using CMK with existing clusters](#upgrade-existing).\n\n### Bastion host and management service\n\nYou configure a customer managed CMK for your bastion host root volume,\nmanagement service root volume, and management service etcd data volumes in your\n`anthos-gke.yaml` before setting up the management service. For more\ninformation, see,\n[Integrating existing infrastructure](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/integrating-existing-infrastructure)\nand the\n[AWSManagementService](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/awsmanagementservice#rootvolume)\nreference.\n\n### User cluster control plane volumes\n\nYou configure a customer managed CMK for your user cluster control plane and\netcd data volumes in your [AWSCluster](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/awscluster)\ndefinition. For more information, see\n[Creating a custom user cluster](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/creating-custom-user-cluster).\n\n### User cluster node root volumes\n\nYou configure a customer managed CMK on user cluster node root volumes in your\n[AWSNodePool](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/awsnodepools)\ndefinition. For more information, see\n[Creating a custom user cluster](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/creating-custom-user-cluster).\n\n### Using CMK with existing clusters\n\n| **Caution:** If you enable a customer managed CMK on an existing management service or user cluster control plane *etcd* data volume, you will lose cluster configuration. To encrypt etcd data volumes, you must create a new management service or user clusters.\n\nYou can add customer managed CMK configuration to the following existing\ncomponents:\n\n- Bastion host root volume\n- Management service root volumes\n- User cluster control plane root volumes\n- User cluster node root volumes\n\nGKE on AWS recreates these volumes after an upgrade or configuration\nchange. To add customer managed CMK configuration to existing components,\nfollow the instructions in\n[Upgrading GKE on AWS](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/upgrading). When you\nmodify your resource configuration, modify the following fields:\n\nWhen you complete the upgrade, GKE on AWS creates new resources with\nthe customer managed CMK volumes attached.\n\nWhat's next\n-----------\n\n- [Create a custom user cluster](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/creating-custom-user-cluster).\n- [Upgrade GKE on AWS](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/upgrading)"]]