简体   繁体   中英

Cannot put object to S3 using aws lambda running on Greengrass

I am trying to store some sensor data to S3 from RPi using AWS Greengrass and Lambda running on the edge device.My code is very basic now with the objective of checking the S3 write. Though I am getting an exception for my lambda when I try to run my code in Greengrass(Though it works when I run the Lambda from console).

I am not able to understand why this is happening while the Lambda only runs in Greengrass environment but it does not give me the same issue while running the Lambda standalone.Any help will be very much appreciated.

I tried to reinstall Greengrass in the Raspberry Pi with no luck and also checked the Lambda permission but all seems correct to me.

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'.

Any luck get your issue fixed? I run into the same issu with boto3.client("s3"), the client cannot get initiated. But the same code worked for my dynamodb client. really strange.

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

My problem was with this python package being too new, python3-botocore, i was running a version beyond what my release should have had. https://github.com/boto/botocore https://packages.debian.org/bullseye/python3-botocore

[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

Usually, this error occurs when the python libs /packages are not available. you may check the boto3 version check using

pip show boto3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM