LoginSignup
2
0

More than 5 years have passed since last update.

aws-sam-localでランタイムの設定が無視される

Posted at

みなさん enjoy serverless してますか?
昨年aws-sam-localのβがリリースされたのでローカルテスト用に使ってみようとしたのですが
その際になぜかランタイムの設定が読み込めなかったので原因と対処法をメモしておきます。

何が起きていたか

複数lamnda functionを管理する上で、共通化できる箇所(メモリサイズやランタイムなど)はひとまとめにしたかったので、以下のようにGlobalを使って管理してました。(抜粋。実際はDynamoの設定や他にも関数があります)

template.yml
Globals:
  Function:
    Runtime: python3.6
    Timeout: 15
    MemorySize: 256
    Environment:
      Variables:
        TABLE_NAME: !Ref SamSampleDynamoTable
Resources:
  UserIndex:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.lambda_handler
      Role: #{Arn}
      CodeUri: 'functions/users/index.py'

sam local start-api を実行すると以下のWARNINGが

Ignoring UserCreate (create.lambda_handler) due to unsupported runtime ()
Ignoring UserIndex (index.lambda_handler) due to unsupported runtime ()

WARNING: Could not find function for [GET] to /users resource
WARNING: Could not find function for [POST] to /users resource

あれ、公式サイト をみても python3.6 はサポートされてるって書いてあるけどな。。と思いいろいろ調べてみると以下のようなISSUEが切られてました。
https://github.com/awslabs/aws-sam-local/issues/226

原因

現状 Global セクションにランタイムの設定が書かれている場合、無視されてしまうようです。

ベータなので(ISSUEも切られてますし)これから対応されることが予想されますが、取り急ぎ開発を進めたい方は各ファンクションにランタイムの設定を書くことで上記エラー(正確にはエラーにはなっていないですが)を回避することができます。

2
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
2
0