我想限制只有属于我的 AWS 组织的主体才能访问 AWS Key Management Service(AWS KMS)密钥。
简短描述
在 AWS KMS 的基于资源的策略中,您可以将 aws:PrincipalOrgID 全局条件键与 Principal 元素一起使用。您可以在 Condition 元素中指定组织 ID,而不是组织中所有 AWS 账户 ID 的列表。
解决方法
使用 AWS 全局条件上下文键 aws:PrincipalOrgID 创建一个 AWS KMS 密钥政策,以允许 AWS 组织中的所有账户执行 AWS KMS 操作
**重要事项:**最佳做法是使用 AWS Identity and Access Management(IAM)策略授予最低权限。
在声明策略的 condition 元素中指定您的 AWS 组织 ID。此策略确保只有组织中账户的主体才能访问 AWS KMS 密钥。
要获取组织 ID,请按照以下步骤进行操作:
- 打开 AWS Organizations 控制台。
- 选择设置。
- 在组织详细信息中,复制组织 ID。
{ "Sid": "Allow use of the KMS key for organization",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"kms:Decrypt",
"kms:DescribeKey",
"kms:Encrypt",
"kms:ReEncrypt*",
"kms:GetKeyPolicy"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:PrincipalOrgID": "o-xxxxxxxxxxx"
}
}
}
此 AWS KMS 密钥政策声明允许属于 AWS 组织且 ID 为 o-xxxxxxxxxxx 的 AWS 账户的身份使用 KMS 密钥:
**注意:**aws:PrincipalOrgID 全局条件上下文键不能用于限制对 AWS 服务主体的访问。调用 API 调用的 AWS 服务由不属于 AWS 组织的内部 AWS 帐户提供。
相关信息
我如何开始使用 AWS Organizations?
如何从组织中删除成员账户?