みずラテ

牛乳と水を2対1で。

【AWS】Lambda was unable to decrypt the environment variables because KMS access was denied.の解決

状況

AWS SAMにてlambda関数を使ったAPIを作成中、lambdaのテストを実行したところ以下の文言が出てエラーとなった。

API アクションの呼び出しに失敗しました。エラーメッセージ: Lambda was unable to decrypt the environment variables because KMS access was denied. Please check the function's KMS key settings. KMS Exception: AccessDeniedExceptionKMS Message: The ciphertext refers to a customer master key that does not exist, does not exist in this region, or you are not allowed to access.

実行時の環境

  • python 3.7
  • layerは使っていない
  • SQS, S3, CloudWatch Logsのアクセス権限は付与していた。
  • バージニア北部では同関数は動作したが、東京リージョンに持ってきたときにエラーが起きた

解決

この辺の記事を参考
github.com

なんてことはない。もう一回作り直せば消えるとのこと。
ということで、SAMで作ったCloudformationのスタックを一度削除して、もう一度スタックを作り直した。

f:id:taris777:20191223083000p:plain

あっけなく成功。


以上です。