This starter kit shows how to deploy a serverless REST API on AWS using:
- Python
- Miniconda
- Poetry
- FastAPI
- Serverless framework
This project was inspired by Cox65 with some improvements.
All the following installation steps for the first time only
- Make sure to setup
makeon your OS, if you are not able to setupmake, please use commands on theMakefile
- If you havent install Nodejs before please install it.
- It is recommended to install LTS versions.
- Note: the project is using Nodejs v16.20.2 but any Nodejs newer versions should be fine.
When you have Nodejs installed, let install the node_modules:
npm iOr if you have make:
make install-serverless- If you havent install Python before please install it.
- Note: the project is using Python3.9 but any Python3 newer versions should be fine.
- If you are using Linux:
curl -sL \
"https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" > \
"Miniconda3.sh"
bash Miniconda3.sh- If you are using MacOS:
curl -sL \
"https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" > \
"Miniconda3.sh"
bash Miniconda3.sh- If you are using Windows:
Go to this page: https://repo.anaconda.com/miniconda/ and download and install the latest .exe package
Note: when install miniconda, please read carefully its instruction, it is pretty straight forward
conda env create -f environment.ymlconda activate serverless_envpoetry installor if you have make:
make install-python-requirementsNow its time to go to the next steps!
- If you havent activated your
condaenvironment, let's activate it:
conda activate serverless_env- Run the following command to start local server
npx sls offlineor if you have make:
make serve
- Testing:
curl localhost:3000/dev/healthOr you can visit this link using your browser.
It should return:
{"status":"OK"}
- If you have a Serverless account
Please use code on main branch which is default:
git checkout main
git checkout -b your_branch
After that, open the serverless.yaml file, change org and app to your org and app respectively!
Note: Read more about Setup an Serverless account here
And run the following command:
npx serverless loginThen you will be able to login using your browsers.
If you havent created an app before, please go to your Serverless dashboard and create a new project, it must have same name as your app name (on the serverless.yaml file):
In this example:
- If you do not have Serverless account:
git checkout without_serverless_account
git checkout -b your_branchAnd then go to the Deployment step.
Note: If you havent activated your conda environment, let's activate it:
conda activate serverless_envRun the following command to deploy
make deploy
Run the following command to test your endpoint (the default path is health):
curl your-serverless-endpointHere your-serverless-endpoint is the endpoint that you can get from the Deployment step above.
Note: If you havent activated your conda environment, let's activate it:
conda activate serverless_envIf you want to remove your app, run the following command:
npx sls remove
Or if you have make:
make remove





