【问题标题】:Cannot put object to S3 using aws lambda running on Greengrass无法使用在 Greengrass 上运行的 aws lambda 将对象放入 S3
【发布时间】:2022-03-11 18:06:11
【问题描述】:

我正在尝试使用在边缘设备上运行的 AWS Greengrass 和 Lambda 从 RPi 将一些传感器数据存储到 S3。我的代码现在非常基本,目的是检查 S3 写入。虽然当我尝试在 Greengrass 中运行我的代码时,我的 lambda 出现异常(虽然它在我从控制台运行 Lambda 时有效)。

我无法理解为什么只有 Lambda 会发生这种情况 在 Greengrass 环境中运行,但它没有给我同样的问题 在独立运行 Lambda 时。非常感谢任何帮助。

我尝试在 Raspberry Pi 中重新安装 Greengrass,但没有成功,还检查了 Lambda 权限,但对我来说一切似乎都是正确的。

import greengrasssdk
import platform
from threading import Timer
from botocore.exceptions import ClientError
import time
import boto3,logging
some_binary_data = b'Here we have some more data from BB'
s3 = boto3.resource('s3')
object = s3.Object('XXXXXX','Testing')
object.put(Body=some_binary_data)


Error Message:
The code abends while executing object.put(Body=some_binary_data)
[2019-07-19T11:13:19.749+02:00]
[FATAL]-lambda_runtime.py:353,Failed to initialize Lambda runtime due to 
exception: An HTTP Client raised and unhandled exception:
'module' object has no attribute 'wait_for_read'.

【问题讨论】:

    标签: python-2.7 amazon-s3 boto3 greengrass


    【解决方案1】:

    你的问题解决了吗? 我遇到与 boto3.client("s3") 相同的问题,客户端无法启动。但是相同的代码适用于我的 dynamodb 客户端。真的很奇怪。

    s3_client = boto3.client('s3')
    logging.debug("s3_upload: client loaded.")
    s3_client.upload_file(img_local_path, S3_BUCKET, S3_KEY+file_name)
    

    【讨论】:

      【解决方案2】:

      我的问题是这个 python 包太新了,python3-botocore,我运行的版本超出了我的版本应该有的版本。 https://github.com/boto/botocore https://packages.debian.org/bullseye/python3-botocore

      【讨论】:

        猜你喜欢
        • 2021-10-14
        • 2015-04-09
        • 2017-09-04
        • 2019-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-11
        相关资源
        最近更新 更多