LoginSignup
0
0

More than 1 year has passed since last update.

【AWS】「CloudFront+S3+API Gateway+Lambda」でBASIC認証を実現するために、AWS SAM(CloudFormation)利用してLambda@Edge作って、権限割り振っているのに「Lambda@Edge cannot retrieve the specified Lambda function. Update the IAM policy to add permission: lambda:GetFunction for resource」言われた

Posted at

はじめに

タイトル長々と書いたが、
AWS SAM(CloudFormation)で、「「CloudFront+S3+API Gateway+Lambda」でBASIC認証」を実現しようとしたたら、「Lambda@Edge cannot retrieve the specified Lambda function. Update the IAM policy to add permission: lambda:GetFunction for resource」

と怒られて、GetFunctionの権限ないよということだった。

ただ、権限は問題なく割り振っていた。なぜだと思い対応したときのメモです。

内容

構成

「WAF + Lambda@Edge + ACM※1」と「CloudFront + S3 + (WAF + API Gateway + Lambda)※2」
※1: us-east-1指定をして作成
※2: ap-northeast-1指定をして作成

みたいな構成で、インフラ構築するためのテンプレートファイルは、
「template_lambdaedge.yaml」と「template.yaml」のように分けて対応していた。

当時は、CloudFront FunctionsでBASIC認証できなかったので上記の構成にしていた。

原因

Lambda@Edgeのバージョン指定が異なっていたことが原因

解決

AWS SAM(CloudFormation)で、Lambda@Edgeのバージョンをパラメータ指定しており、
しかも、tomlファイルに内容を保存していたため、バージョン指定の見落としだった・・・

「template.yaml」(CloudFront + S3 + (WAF + API Gateway + Lambda))を実行する際に、
Lambda@Edgeの名前と、”適切なバージョン指定”をして設定したところ
問題なく作成された。
よかったー

所感

CloudFront FunctionsでBASIC認証できるようになった現在は関係ないかもですが、
バージニアにLambda@Edge作って対応している人には役立つ内容かなと思いますー。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0