跳至內容

Lambda issue with Kms

0

In my lambda code I'm getting Calling the invoke API action failed with this message lambda was unable to decrypt the environment variables because KMS access was denied.Please check the functions KMS key settings.

已提問 5 個月前檢視次數 163 次
1 個回答
0

If you use default AWS-managed key (aws/lambda), you shouldn't have to do anything. If you use a customer managed key, then you will need to update the Lambda's role to allow access to KMS and optionally KMS resource to allow Lambda's IAM role.

## Lambda IAM
{
  "Effect": "Allow",
  "Action": [
    "kms:Decrypt",
    "kms:Encrypt",
    "kms:GenerateDataKey*",
    "kms:DescribeKey"
  ],
  "Resource": "arn:aws:kms:your-region:your-account-id:key/your-kms-key-id"
}
## KMS policy example
{
  "Sid": "AllowLambdaUseOfKey",
  "Effect": "Allow",
  "Principal": {
    "AWS": "arn:aws:iam::<your-account-id>:role/<your-lambda-execution-role-name>"
  },
  "Action": [
    "kms:Decrypt",
    "kms:Encrypt",
    "kms:GenerateDataKey*",
    "kms:DescribeKey"
  ],
  "Resource": "*"
}

專家
已回答 5 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。