Proof of concept using Serverless Application Model (SAM).
Install dependencies:
▶ brew install python@2
▶ pip install virtualenv
Install Docker CE (ref).
Ensure you have an AWS account and access keys configured.
Set up a Virtualenv:
▶ virtualenv ./virtualenv
▶ . virtualenv/bin/activate
▶ pip install -r requirements.txt
Test it's working:
▶ sam --version
SAM CLI, version 0.10.0
Cleanup:
▶ deactivate
Return to the Virtualenv later without reinstalling:
▶ . virtualenv/bin/activate
▶ sam --version
SAM CLI, version 0.10.0
Useful docs:
This section is based on the SAM Quick Start section.
The sam init
command initialises a serverless application with a SAM template, a folder structure inside the directory sam-app
, unit tests and so on. For more information, try sam init --help
. Note the options that can be passed to --runtime
:
▶ sam init --help
...
-r, --runtime [dotnetcore1.0|go1.x|nodejs|python|python2.7|python3.6|python3.7|ruby2.5|dotnetcore2.0|dotnetcore2.1|go|dotnet|java|nodejs4.3|nodejs6.10|java8|nodejs8.10|dotnetcore]
Lambda Runtime of your app
I ran:
▶ sam init --runtime python2.7
[+] Initializing project structure...
[SUCCESS] - Read sam-app/README.md for further instructions on how to proceed
[*] Project initialization is now complete
This creates four things:
- A "hello world" app in Python 2.7 inside
sam-app/hello_world
. - Unit tests in Pytest for it inside
sam-app/tests
. - A SAM template in
sam-app/template.yml
. - a README.md in
sam-app/README.md
with further instructions.