Can one use application built with Python3 in lambda, and not just python2.7. Possibly looking at options around - https://gun.io/blog/announcing-zappa-serverless-python-aws-lambda/
AWS lambda documentation mentions about python2.7.
Is there some example code which I could try for python3.0 with lambda
You can now use the Python 3.9 runtime to develop your AWS Lambda functions. To use this version, specify a runtime parameter value python3.
You can run Python code in AWS Lambda. Lambda provides runtimes for Python that run your code to process events. Your code runs in an environment that includes the SDK for Python (Boto3), with credentials from an AWS Identity and Access Management (IAM) role that you manage.
AWS Lambda supports Python 3.6, 3.7 and version 3.8. As always, you should test your functions for Python 3 language compatibility before applying changes to your production functions.
Lambda functions run in a container on a well-known AMI. While you must handle the initial event with Python2.7, you can call out to anything installed on the AMI. In particular, Python3 is already installed. It's a bit complicated, but you can establish a virtualenv to take advantage of the installed python3.
For a few of the details, see http://www.cloudtrek.com.au/blog/running-python-3-on-aws-lambda/.
Edit: that link went dead. Try https://www.linkedin.com/pulse/running-python-3-aws-lambda-lyndon-swan.
Python 3.6 is now available in Ohio! (us-east-2)
I ran:
def lambda_handler(event, context): # TODO implement return sys.version
And it kicked back:
"3.6.1 (default, Mar 27 2017, 23:56:45) \n[GCC 4.9.3]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With