管理对仅使用 lambda 的 KMS 密钥的访问

Managing access to KMS key to be used only a lambda

我有一个用例,其中 kms 密钥将用于加密和解密数据。我如何确保只有特定的 lambda 应该能够使用来自 AWS 策略的 kms 密钥。

我尝试在创建时在 kms 密钥策略中添加 Lambda ARN,但看起来不允许这样做。

如何实现我的用例?

步骤如下:

  1. 为 Lambda 创建一个没有附加任何权限的 IAM 角色。

  2. Select 创建密钥时 Define key usage permissions 相同。

  3. 将 IAM 角色附加到 Lambda。

  4. 开始在 Lambda 中使用 KMS 密钥。

根据 AWS KMS documentation

The default key policy that the console creates for symmetric CMKs allows you to choose IAM users and roles in the account, and external AWS accounts, and make them key users.