LoginSignup
0
0

More than 3 years have passed since last update.

sam buildのエラー解消【EventInvokeConfig】

Last updated at Posted at 2020-08-27

Lambdaの再試行回数を制御するために、SAMテンプレートにEventInvokeConfigの定義を追加した際に、sam buildでエラーを吐くようになりました。

samのテンプレートは以下のような感じです。

template.yaml
Resources:
  Function:
    Type: AWS::Serverless::Function
    Properties:
      EventInvokeConfig: # 追加
        MaximumRetryAttempts: 0  # 追加

ビルドすると「EventInvokeConfigはAWS::Serverless::Functionにて定義されていません」という旨のエラーが、、、

$ sam build

Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.39.0/libexec/lib/python3.7/site-packages/samcli/lib/samlib/wrapper.py", line 71, in run_plugins
    parser.parse(template_copy, all_plugins)  # parse() will run all configured plugins
  File "/usr/local/Cellar/aws-sam-cli/0.39.0/libexec/lib/python3.7/site-packages/samcli/lib/samlib/wrapper.py", line 140, in parse
    raise InvalidDocumentException(document_errors)
samtranslator.model.exceptions.InvalidDocumentException: [InvalidResourceException('Function', 'property EventInvokeConfig not defined for resource of type AWS::Serverless::Function')]

〜略〜

当事象についてGitHubにIssueがありました。
Property EventInvokeConfig not defined for resource of type AWS::Serverless::Function #1747
aws-sam-cli 0.40.0までのバージョンでは、うまく動作しないみたいです。

ということなのでaws-sam-cliをバージョンアップしましょう。

$ sam --version
SAM CLI, version 0.39.0

$ brew upgrade aws-sam-cli
Updating Homebrew..
 略

$ sam --version
SAM CLI, version 1.1.0

これでsam buildでエラーが発生せず、ビルドできるようになりました。
適度にアップデート内容を確認して、必要に応じてバージョンアップすることが大切ですね。

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