Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

trying to use two methods from lambda API #3882

Open
codeman101 opened this issue Sep 17, 2019 · 1 comment
Open

trying to use two methods from lambda API #3882

codeman101 opened this issue Sep 17, 2019 · 1 comment

Comments

@codeman101
Copy link

I'm trying to make a script that can automatically update at lambda or a layer using these methods. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.update_function_code and https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.publish_layer_version. Specifically I'm trying upload the zip file I created with the ZipFile python module. However I'm failing to do so since boto requires the contents of the zip file be in bytes and the python Zip[File module doesn't allow 'wb' as a write mode nor can I convert the zip file to bytes with the encode method like you can with a string.

@zinged5
Copy link

zinged5 commented May 2, 2023

You could convert the zip file to bytes using 'rb' , ie:
with open(filename, 'rb') as f:
file_to_bytes =f_data.read()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants