This is a programming challenge to build a simple API and deploy it on the AWS cloud provider.
You can test the API using the below URL
Title | Create a new device |
Route | /api/devices/ |
Method | POST |
Body |
|
Title | Retrieve a device |
Route | /api/devices/{device-id} |
Method | GET |
Body | {} |
- python 3.11
- node 20.5
- serverless 3.35
1. Create a virtual environment
Go to the project root directory and run the below command to create a new Python virtual environment:
python3 -m venv <virtual-environment-name>
2. Activate the virtual environment
Run the below command to activate your virtual environment:
source ./venv/bin/activate
Now your virtual environment is ready to use
3. Install dependencies
You can install the project dependencies by the below command:
pip install -r requirements.txt
4. Test the application
You can test the application by running the following command:
python manage.py test
5. Start the server
Start the server with Django runserver
with the following command:
python manage.py runserver 0.0.0.0:<port>
Done:beer:
1. Config AWS credentials on Serverless
Run the below command to set your credentials on serverless:
serverless config credentials --provider aws --key <access-key-id> --secret <secret-access-key>
2. Install Serverless plugins
To install Serverless plugins, navigate to the project root directory and run the following command:
npm install
3. Deploy on AWS
To deploy the code on the AWS cloud provider, use the following command:
serverless deploy
Done:beer:
Key | Value |
---|---|
AWS_ACCESS_KEY_ID | AWS access key id |
AWS_SECRET_ACCESS_KEY | AWS secret key id |
AWS_DEFAULT_REGION | Your region on AWS |
NOTE: If you running the application on your local machine, you need to create a
.env
file inpython_code_challenge
directory. Otherwise, there is no need to specify environment variables.