【发布时间】:2021-11-04 15:48:36
【问题描述】:
由于某种奇怪的原因,Lambda (Python3.8) 无法使用 Role 连接到 S3 存储桶。它只是返回 Timed Out 错误。它甚至不会抛出任何异常。调用此部分时超时
response = s3.list_buckets()
我什至检查了 Lambda ENI 的流日志。他们正在返回无数据。
但是,相同的设置在另一个项目中起作用。
这是代码示例:
import json
import datetime
import time
import config as cf
import boto3
import botocore
from botocore.exceptions import ClientError
def lambda_handler(event, context):
try:
# Retrieve the list of existing buckets
s3 = boto3.client('s3')
response = s3.list_buckets()
# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
print(f' {bucket["Name"]}')
except Exception as e:
print("Exception:\n" + str(e))
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
有人遇到过这样的问题吗?
非常感谢您提供一点帮助/建议,过去 2 天我一直在苦苦挣扎,我必须提交我的工作。
提前致谢。
干杯,
苏曼
【问题讨论】:
-
lambda 是否在 VPC 中运行?
-
是相同的 VPC @jellycsc
标签: python amazon-web-services amazon-s3 aws-lambda