Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide

Prerequisite:

GCP Account
Install Google Cloud SDK
Terraform Installed on Developer Desktop
Python on Developer Desktop

In GCP Console:

Create new Project named my-first-project on GCP console

We will enable the following …


This content originally appeared on DEV Community and was authored by Jay Sheth

Prerequisite:

  1. GCP Account
  2. Install Google Cloud SDK
  3. Terraform Installed on Developer Desktop
  4. Python on Developer Desktop

In GCP Console:

  1. Create new Project named my-first-project on GCP console
    GCP Console
    GCP Console

  2. We will enable the following APIs for our project to work, run the below mentioned commands in Google Cloud CLI

  • Cloud Run
  • Artifact Registry
  • Cloud Build

    GCP commands

On Developer Desktop:

  1. Create a simple Flask Application
  • Create an app.py file

  • Create a Dockerfile

In GCP Console:

  1. Go to Artifact Registry
  2. Click on Create Repository Artifact Registry
  • Give name to repository ($REPO_NAME)
  • Select Docker in Format
  • Select Standard in Mode
  • Select Regional in Location Type
  • Select us-west1 in Region
  • Click on Create

On Developer Desktop

  1. In the folder where we created the Dockerfile; run the following commands
    Docker commands

  2. We will create Terraform project

  • Create terraform.tf for configuring the providers

  • Create main.tf containing the cloud run configuration

  • Create variable.tf containing the variables

  • Create data.tf containing the data

  • Create output.tf containing the output

  • Create terraform.tfvars containing the variable values

  • Now run the following commands in your terminal
    Terraform commands

Output

Flask application

Destroy Infrastructure

To destroy the infrastructure, run the following commands in your terminal
Terraform commands

đź‘‹đź‘‹BYEđź‘‹đź‘‹


This content originally appeared on DEV Community and was authored by Jay Sheth


Print Share Comment Cite Upload Translate Updates
APA

Jay Sheth | Sciencx (2024-07-15T18:39:41+00:00) Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide. Retrieved from https://www.scien.cx/2024/07/15/deploying-a-flask-app-on-cloud-run-with-terraform-a-comprehensive-guide/

MLA
" » Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide." Jay Sheth | Sciencx - Monday July 15, 2024, https://www.scien.cx/2024/07/15/deploying-a-flask-app-on-cloud-run-with-terraform-a-comprehensive-guide/
HARVARD
Jay Sheth | Sciencx Monday July 15, 2024 » Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide., viewed ,<https://www.scien.cx/2024/07/15/deploying-a-flask-app-on-cloud-run-with-terraform-a-comprehensive-guide/>
VANCOUVER
Jay Sheth | Sciencx - » Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/15/deploying-a-flask-app-on-cloud-run-with-terraform-a-comprehensive-guide/
CHICAGO
" » Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide." Jay Sheth | Sciencx - Accessed . https://www.scien.cx/2024/07/15/deploying-a-flask-app-on-cloud-run-with-terraform-a-comprehensive-guide/
IEEE
" » Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide." Jay Sheth | Sciencx [Online]. Available: https://www.scien.cx/2024/07/15/deploying-a-flask-app-on-cloud-run-with-terraform-a-comprehensive-guide/. [Accessed: ]
rf:citation
» Deploying a Flask App on Cloud Run with Terraform: A Comprehensive Guide | Jay Sheth | Sciencx | https://www.scien.cx/2024/07/15/deploying-a-flask-app-on-cloud-run-with-terraform-a-comprehensive-guide/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.