How to set up Django on Cloud Run with Terraform
HTML-код
- Опубликовано: 7 авг 2024
- Code for this episode → goo.gle/30jsxcX
Django is a free and open source web application framework, written in Python that can help you build apps. After building your web-based app with Django, how long does it take to deploy to Google Cloud Platform? In this episode of Serverless Expeditions Extended, Craig and Martin will teach you how to quickly deploy your Django-based web app to Google Cloud Run. Watch to learn how Craig uses a Terraform script to automate the deployment process and save Martin’s Saturday!
Chapters:
0:00 - Intro
1:45 - Setting up Django with Terraform
2:38 - Step 1, Activate Google Cloud
2:55 - Step 2, Set up variables
3:10 - Step 3, Activate your service APIs
3:24 - Step 4, Create a custom service account
3:40 - Step 5, Create your database
4:09 - Step 6, Create your secrets
4:25 - Step 7, Prepare your secrets for Django
5:00 - Step 8, Expand Service Account permissions
5:21 - Step 9, Populate your secrets
6:08 - Step 10, Create your Cloud Run service
6:23 - Step 11, Specify Cloud Run permissions
6:38 - Step 12, Grant access to your database
7:02 - Step 13, Run migrations and prepare static files
7:46 - Step 14, View final output
8:27 - Editing the settings.py file
10:16 - Applying the Terraform manifest
13:07 - Wrap-up
Checkout more episodes of Serverless Expeditions → goo.gle/ServerlessExpeditions
Subscribe to Google Cloud Tech → goo.gle/GoogleCloudTech
#ServerlessExpeditions #ServerlessExpeditionsExtended #CloudRun
product: Cloud - Serverless Computing - Cloud Run; fullname: Martin Omander; Наука
Awesome!! This is just what I was looking for. Certainly, deploying a Django app is no joke
We're happy to hear that! Let us know how if goes.
Does that terraform module detect code changes in Django app?
No. terraform has nothing to do with apps (in this case django).
It always took so much time when I wanted to deploy my django app on cloud run but with the Terraform flow explained in the videos, django apps will be deployed and running live in no time. Please in future also make a video for CI/CD integration along with this
Glad to hear you found it useful and thank you for the suggestion!
This is a great video, but you mentioned that this supports continuous deployment but according to all the instructions you’ve provide it doesn’t.
If perform all the steps you’ve highlighted and the try update the Index.html file and run the last command you recommended you will not see the changes reflected in the deployments.
Can you explain what steps you missed for continuous deployment?
If you run the cloudbuild full manifest in the repo, you'll get all your code updates. If you run terraform apply, you'll get all your infra updates. Hope this helps!
@@katiemclaughlin5167 - thanks for your reply. If you attempt the same solution with just a simple upgrade to Django==4.1.1, you'll find that your proposal does not work. The build step will fail to connect to the cloud sql instance and it does not collect the static files. Please may I request Google to upgrade the docs and tutuorial
there needs to be a course with terraform and GCP ... I only have came across terraform and was courses :/
Super content
Good question! In the 0001_createsuperuser.py file you'll find a call to `User.objects.create_superuser()`, which uses the hardcoded value "admin" for the username. Martin and I were only treating its password as sensitive - but you could change this for your apps to also conceal the superuser's username.
It's in a data migration, check out the 0001_create_superuser.py file in the repo for the details!
Great video.. But complex code and functionality for a beginner like me.. It would be better if things are summarized at the end for better understanding for beginner coders like me