Boto3: Documentation incorrect for Lambda's create_function

Created on 3 Aug 2015  Â·  13Comments  Â·  Source: boto/boto3

I've been trying to use Lambda's create_function by supplying a zip as an argument Code={'ZipFile': ...}, but have encountered problems with the documentation.

The documentation says:
ZipFile (bytes) -- A base64-encoded .zip file containing your deployment package. For more information about creating a .zip file, go to Execution Permissions in the AWS Lambda Developer Guide .

Two problems I encountered:

  1. Did not work when encoding zip in base64, but instead worked when I passed the bytes directly.
  2. The page linked to (Execution Permissions) does not even contain the word zip

I'm guessing boto instead encodes the file to base64 itself?

thanks

documentation

Most helpful comment

for anyone stumbling on this late, syntax looks like:

import os
import boto3

boto3.client('lambda').create_function(
    ... ,
    Code={
        'ZipFile': open('my_file.zip', 'rb').read()
        },
    ...
)

All 13 comments

Exactly. We're using the same docs that they have in their API reference (http://docs.aws.amazon.com/lambda/latest/dg/API_FunctionCode.html), but all the AWS SDKs automatically base64 encode this value for you. We'll get the docs updated.

ok, thanks

This particular issue made me lost a few hours today...

This just cost me some time and frustration… I hope it can be fixed soon.

Note that not only does create_function do the Base64 encoding automatically (and fails if the input is already encoded) but also it does _not_ actually accept a parameter named Code with the value being a dict. Rather it expects the parameter ZipFile and rejects Code.

Update: whoops, sorry, I was confusing create_function and update_function_code. Never mind on that.

3 months later and still no update to the docs? Come on now, would have saved me an hour.

@jamesls Can you please update the doc?

+1 to this, 'update_function_code' has the same issue

for anyone stumbling on this late, syntax looks like:

import os
import boto3

boto3.client('lambda').create_function(
    ... ,
    Code={
        'ZipFile': open('my_file.zip', 'rb').read()
        },
    ...
)

almost a year and still no improvement to the documentation.
thanks @ryantuck your example syntax really helped.

Thank you @ryantuck !

Thanks @ryantuck !

Thank you @ryantuck !

Was this page helpful?
0 / 5 - 0 ratings