Lec*_*dal 5 python amazon-web-services boto3 aws-lambda
在AWS Lambda上尝试使用boto3启动和停止RDS实例时,我收到了一个有趣的错误 - 'RDS' object has no attribute 'stop_db_instance': AttributeError
即使是最简单的代码也会抛出此错误,例如
import boto3
def lambda_handler(event, context):
boto3.client('rds').stop_db_instance(DBInstanceIdentifier='myInstanceID')
Run Code Online (Sandbox Code Playgroud)
我正在使用python3.6运行时,因此根据此页面上提供的信息,boto3 1.4.4应该可用(我假设已经有了正确的方法 - https://boto3.readthedocs.io/en/latest/reference/services /rds.html#RDS.Client.stop_db_instance)
任何建议都很赞赏!
我在本地和lambda上使用boto3==1.4.1和botocore==1.4.64接收相同的错误.
AWS Lambda必须使用旧的botocore库.我尝试使用boto3==1.4.4
,并botocore==1.5.75和它的工作.
因此,决定上传我自己的zip包含最新的boto3和botocore(如上所述),它的工作原理.
UPDATE
这是我的aws lambda代码片段 -
import botocore
import boto3
def lambda_handler(event, context):
print("Version is {}".format(botocore.__version__))
boto3.client('rds').stop_db_instance(DBInstanceIdentifier='myInstanceID')
Run Code Online (Sandbox Code Playgroud)
output:版本是1.5.52
和1.5.52负责stop_db_instance在rds模块中没有属性.因此,手动创建具有最新版本的zip将起到作用.
谢谢
| 归档时间: |
|
| 查看次数: |
4532 次 |
| 最近记录: |