Deploy Your Django App to Serverless in 10 Minutes – Absolutely Free!
Oskar Ablimit
Cloudflare Enterprise Account Executive | Engineering in Cloud Computing |@ex-AWS| @ex-Alicloud | @ex-Tencent Cloud
Hosting a Django Application to AWS Lambda with Zappa
Why Serverless??
With deploying to server, e.x., AWS ec2:?
With deploying to Serverless, e.g., aws lambda:
2. Reduced cost
Steps
1. IAM user creation:
-Need to create a new IAM user to access the lambda function
Assign two basic permission to the IAM, IAM full access power access
2. pip3 install zappa?
-Install zappa into the project virtual environment in Django?
3.pip3 install awscli
-Install awscli into the virtual environment so that zappa can interact with lambda and API gateway?
4. aws configure
-This will ask you to enter the access key and secret key?
领英推荐
5. zappa init
-This will initialize the zappa configuration
6. zappa deploy dev
-Once the database is connected to django application, run this code to deploy the django application to lambda?
-What this do is 1) create lambda function to trigger the django application 2) create an API gateway to get the request
7. Django DB configuration( sqllite does not support with zappa)
-As zappa does not support django built in sqlite, we need to change the database to an external database, in my case, I connect it to AWS RDS.?
8. zappa update dev
-If we need to update the project, this will reflect on it
9. setup custom hostname in AWS ( https://medium.com/@amirhosseinsoltani7/connect-cloudflare-to-aws-api-gateway-c64f0713b5e9 )?
As now, we only get the API link to access our project, we can set up a custom hostname in api gateway to map with the API, here is how I did it:?
Check the video here for more explanation:
Tech Enthusiastic | React js | Next js | React Native | Redux | Backend Developer | Nodejs Developer | Node | Express | Typescript | JavaScript | MySQL | MongoDB |Aws
2 个月thanks for contents its help me
Cloudflare Enterprise Account Executive | Engineering in Cloud Computing |@ex-AWS| @ex-Alicloud | @ex-Tencent Cloud
9 个月Check the brief tutorial recording here, https://www.youtube.com/watch?v=9_wWMsWlN08