SAMでlambdaアプリケーションを作成する① IT by NHM - 2021-02-162021-02-16 チュートリアル: Hello World アプリケーションのデプロイhttps://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html 上記を実行した際のログから確認するに下記に関連する権限が必要 API Gateway: HTTPアクセスCloud Formation: 関数デプロイS3:デプロイ用IAM:LambdaロールLambda:関数実行 sam deploy --guide実行した時のログから考えるにあながち間違っていないはず。 CloudFormation stack changeset ------------------------------------------------------------------------------------------------------------- Operation LogicalResourceId ResourceType Replacement ------------------------------------------------------------------------------------------------------------- + Add HelloWorldFunctionHelloWo AWS::Lambda::Permission N/A rldPermissionProd + Add HelloWorldFunctionRole AWS::IAM::Role N/A + Add HelloWorldFunction AWS::Lambda::Function N/A + Add ServerlessRestApiDeployme AWS::ApiGateway::Deployme N/A xxx nt + Add ServerlessRestApiProdStag AWS::ApiGateway::Stage N/A e + Add ServerlessRestApi AWS::ApiGateway::RestApi N/A ------------------------------------------------------------------------------------------------------------- たぶん↓のような感じでCloudFormationが動作しているはず。 Lambda実行できるパーミッションを取得取得したパーミッションを保持した IAMロールを作成Lambdaに関数登録API GatewayにデプロイAPI GatewayにデプロイしたAPIのステージをプロダクションに設定Rest APIでアクセスできるように設定 で、エンドポイントにアクセスするとHelloWorldが返ってくる。 CloudFormation outputs from deployed stack -------------------------------------------------------------------------------------------------------------- Outputs -------------------------------------------------------------------------------------------------------------- Key HelloWorldFunctionIamRole Description Implicit IAM Role created for Hello World function Value arn:aws:iam::xxx:role/sam-app-HelloWorldFunctionRole-xxx Key HelloWorldApi Description API Gateway endpoint URL for Prod stage for Hello World function Value https://xxx.execute-api.ap-northeast-1.amazonaws.com/Prod/hello/ Key HelloWorldFunction Description Hello World Lambda Function ARN Value arn:aws:lambda:ap-northeast-1:xxx:function:sam-app- HelloWorldFunction-xxx Share on Facebook Share Share on TwitterTweet Share on Pinterest Share Share on LinkedIn Share Share on Digg Share Tags: AWS / CLI / CloudFormation / Docker / IAM / Lambda / S3 / SAM