

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

# 基準 KMS 金鑰政策
<a name="baseline-KMS-key-policy"></a>

下列 KMS 金鑰政策涵蓋最常見的部署案例：具有委派管理員和 AWS 受管應用程式的 IAM Identity Center 執行個體 AWS Control Tower，包括 SSO 到 Amazon EC2 執行個體和自訂工作流程。建立 IAM Identity Center 的客戶受管 KMS 金鑰時，請使用此政策做為起點。如果您需要更精細的存取控制，例如將金鑰限制在特定 IAM Identity Center 執行個體或應用程式，請參閱 [進階 KMS 金鑰政策陳述式](advanced-kms-policy.md)。請注意，如果使用多區域金鑰，則應在所有複本中使用相同的政策，以協助確保一致的授權。

若要使用此政策，請將下列預留位置值取代為您自己的值：
+ `{{111122223333}}` — IAM Identity Center 執行個體的帳戶 AWS ID ( AWS Organizations 管理帳戶）。
+ `{{444455556666}}` — 委派管理 AWS 帳戶的帳戶 ID。如果您不使用委派的管理，請移除此委託人。

 由於 AWS IAM Identity Center 要求 KMS 金鑰與服務位於相同的 AWS 帳戶中，因此下列陳述式會使用 `${aws:ResourceOrgID}`和 `${aws:ResourceAccount}`變數，而非常值。如果您想要的話，您可以將這些變數取代為 AWS 組織 ID 和 AWS 帳戶 ID。

```
{
  "Version": "2012-10-17", 		 	 	 
  "Statement": [
    {
      "Sid": "AllowIdentityCenterAdminAccounts",
      "Effect": "Allow",
      "Principal": {
        "AWS": [
          "arn:aws:iam::{{111122223333}}:root",
          "arn:aws:iam::{{444455556666}}:root"
        ]
      },
      "Action": "kms:*",
      "Resource": "*"
    },
    {
      "Sid": "AllowIdentityCenterAndIdentityStoreToDescribeKey",
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "identitystore.amazonaws.com",
          "sso.amazonaws.com"
        ]
      },
      "Action": "kms:DescribeKey",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:SourceAccount": "${aws:ResourceAccount}"
        }
      }
    },
    {
      "Sid": "AllowIdentityCenterAndIdentityStoreToUseKey",
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "identitystore.amazonaws.com",
          "sso.amazonaws.com"
        ]
      },
      "Action": [
        "kms:Decrypt",
        "kms:ReEncryptTo",
        "kms:ReEncryptFrom",
        "kms:GenerateDataKeyWithoutPlaintext"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:SourceAccount": "${aws:ResourceAccount}"
        },
        "ForAnyValue:StringEquals": {
          "kms:EncryptionContextKeys": [
            "aws:sso:instance-arn",
            "aws:identitystore:identitystore-arn"
          ]
        }
      }
    },
    {
      "Sid": "AllowOrgPrincipalsViaIdentityCenterAndIdentityStore",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "kms:Decrypt",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "${aws:ResourceOrgID}"
        },
        "StringLike": {
          "kms:ViaService": [
            "sso.*.amazonaws.com",
            "identitystore.*.amazonaws.com"
          ]
        },
        "ForAnyValue:StringEquals": {
          "kms:EncryptionContextKeys": [
            "aws:sso:instance-arn",
            "aws:identitystore:identitystore-arn"
          ]
        }
      }
    },
    {
      "Sid": "AllowManagedApps",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "kms:Decrypt",
      "Resource": "*",
      "Condition": {
        "Bool": {
          "aws:PrincipalIsAWSService": "true"
        },
        "StringEquals": {
          "aws:SourceOrgID": "${aws:ResourceOrgID}"
        },
        "StringLike": {
          "kms:ViaService": [
            "identitystore.*.amazonaws.com",
            "sso.*.amazonaws.com"
          ]
        },
        "ForAnyValue:StringEquals": {
          "kms:EncryptionContextKeys": [
            "aws:sso:instance-arn",
            "aws:identitystore:identitystore-arn"
          ]
        }
      }
    }
  ]
}
```

此政策包含五個陳述式。下表說明每個陳述式的功能。


| 陳述式 | 用途 | 
| --- | --- | 
| AllowIdentityCenterAdminAccounts | 將完整的 KMS 金鑰許可授予 IAM Identity Center 管理帳戶和委派的管理帳戶。這包括金鑰管理動作，例如修改金鑰政策和排程金鑰刪除。如果這些帳戶中的管理員在其身分型政策中具有必要的許可，則可以管理和使用金鑰。 | 
| AllowIdentityCenterAndIdentityStoreToDescribeKey | 允許 IAM Identity Center 和 Identity Store 服務主體擷取金鑰中繼資料。這對於在不執行加密或解密的情況下驗證金鑰的服務操作是必要的。aws:SourceAccount 條件有助於確保只有 IAM Identity Center 執行個體可以使用 KMS 金鑰。 | 
| AllowIdentityCenterAndIdentityStoreToUseKey | 允許 IAM Identity Center 和 Identity Store 服務主體使用 金鑰進行加密操作，例如加密、解密和重新加密資料。aws:SourceAccount 條件有助於確保只有 IAM Identity Center 執行個體可以使用 KMS 金鑰。 | 
| AllowOrgPrincipalsViaIdentityCenterAndIdentityStore | 允許 AWS 組織中的 IAM 主體透過 IAM Identity Center 和 Identity Store 服務解密資料。這涵蓋使用轉送存取工作階段 (FAS) 與 IAM Identity Center 整合 AWS 服務互動的應用程式管理員。 | 
| AllowManagedApps | 允許 AWS 受管應用程式透過 IAM Identity Center 和 Identity Store 解密受 KMS 金鑰保護的資料。 | 

在 中使用下列 IAM 政策陳述式[步驟 4：設定 KMS 金鑰跨帳戶使用的 IAM 政策](identity-center-customer-managed-keys.md#configure-iam-policies-kms-key)，以允許委派管理員透過 IAM Identity Center 服務 APIs 使用 KMS 金鑰。將範例金鑰 ARN 取代為您實際的 KMS 金鑰 ARN。範例中的萬用字元區域可容納多區域 KMS 金鑰的所有複本。

對於 IAM Identity Center 管理以外的跨帳戶使用案例，例如 SSO 到 Amazon EC2 執行個體或 AWS 受管應用程式的管理，範圍`AllowCrossAccountKMSKeyUse`僅限於 `kms:Decrypt` 並移除`AllowListKMSKeyAliases`陳述式。

```
{
  "Version": "2012-10-17", 		 	 	 
  "Statement": [
    {
      "Sid": "AllowCrossAccountKMSKeyUse",
      "Effect": "Allow",
      "Action": [
        "kms:Encrypt",
        "kms:Decrypt",
        "kms:GenerateDataKeyWithoutPlaintext",
        "kms:DescribeKey"
      ],
      "Resource": [
        "arn:aws:kms:{{*}}:{{111122223333}}:key/{{mrk-1234abcd-12ab-34cd-56ef-1234567890ab}}"
      ]
    },
    {
      "Sid": "AllowListKMSKeyAliases",
      "Effect": "Allow",
      "Action": "kms:ListAliases",
      "Resource": "*"
    }
  ]
}
```