我为这个基本问题道歉。我对AWS和Python都是新手。我正在尝试执行https://boto3.readthedocs.io/en/latest/guide/migrations3.html#accessing-a-bucket中给出的示例代码,但遇到错误。
import botocore
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('bucketname')
exists = True
try:
s3.meta.client.head_bucket(Bucket='bucketname')
except botocore.exceptions.ClientError as e:
# If a client error is thrown, then check that it was a 404 error.
# If it was a 404 error, then the bucket does not exist.
error_code = int(e.response['Error']['Code'])
if error_code == 404:
exists = False
日志中的错误是
"errorMessage": "Handler 'lambda_handler' missing on module 'lambda_function'"
Kishnaúu mee2004是对的,您需要定义
lambda_handler
,否则它永远不会工作,但如果您遇到以下错误:然后,您需要检查处理程序信息是否提到
lambda_function_name.lambda_handler
。您需要在代码中定义一个函数。代码缺少名为
lambda_handler
的函数。您的代码应该如下所示:相关问题 更多 >
编程相关推荐