LoginSignup
0
0

More than 3 years have passed since last update.

boto3でno attributeのエラーがでたときはバージョンを確認しよう

Posted at

boto3のエラー

boto3のput_function_event_invoke_configを使用したところ、

import botocore
import boto3

client = boto3.client('lambda')
response = client.put_function_event_invoke_config(
    FunctionName=FunctionName,
    MaximumRetryAttempts=0,
)

以下のエラーが発生

AttributeError: 'Lambda' object has no attribute 'put_function_event_invoke_config'

翻訳すると

AttributeError: 'Lambda' オブジェクトには 'put_function_event_invoke_config' 属性がありません。

とのこと。

lambdaに以下を追記して、boto3とbotocoreのバージョンを確認しました。

    print('botocore vertion is {0}'.format(botocore.__version__))
    print('boto3 vertion is {0}'.format(boto3.__version__))

これが結果

botocore vertion is 1.12.253
boto3 vertion is 1.14.57

現在のバージョンを以下で確認したところ・・
Releases · boto/boto3 · GitHub
Releases · boto/botocore · GitHub

botocoreが半年以上古いようです。

botocoreを最新化する

以下の記事の通りで最新化できます。

【AWS】Lambdaでのbotoの使い方と最新botoの使用方法

ServerlessFrameworkの場合は、serverless-python-requirementsのプラグインを入れてrequirement.txtにboto3botocoreを追記することで、最新化できます。

以下の記事が参考になります。
【Tips】Serverless Frameworkで最新のboto3をインストールしたLambda Layerをデプロイする

解決

botocoreを最新化することで、エラーが解消しました。

参考

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