AWS SAMで timed out after 3 seconds

関数を実行時に下記エラーが発生した。
タイムアウトの問題なので3秒以上に設定したい。

Function 'YourFunction' timed out after 3 seconds

デフォルトに関しては template.yaml のGlobalsにて設定されています。

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3

変更するのには、上記のTimeout値を変更するか、
特定の関数に対してだけ設定したいのならば、templete.yaml にて対象のProperties内にTimeoutを設定すれば良さそうです。

Resources:
  YourFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: your_directory/
      Handler: app.lambda_handler
      Runtime: python3.9
      Architectures:
        - x86_64
      Events:
        FunctionName:
          Type: Api
          Properties:
            Path: /endpoint
            Method: get
+     Timeout: 90

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です