Terraform scripts to perform below actions:
- Create a Cloud SQL instance in GCP
- Create CloudRun service with britetest docker image(defaults to srikanthreddypailla/learning:britetest1)
- Configures CloudRun service to connect with Cloud SQL Instance
- Allows unauthenticated invocations for public API or website
Pre-requisites before you deploy:
-
Before we deply make sure to enable below mentioned api's in GCP
- Service Usage API: serviceusage.googleapis.com
- Cloud Run Admin API: run.googleapis.com
- Cloud SQL Admin API: sqladmin.googleapis.com
-
In the repo root create keys.json file which should contain service accout keys. Refer https://cloud.google.com/iam/docs/keys-create-delete on how to create service account and get keys
-
Generate OMDB API key from https://www.omdbapi.com/apikey.aspx, you will need this key when you run terraform apply
Deployment: From root of the repo run below commands
terraform init
terraform plan
terraform apply
: This will take aprox 15 mins (Creating CloudSQL takes the most of the time)
Once deployment is successful, go to GCP console and then go to the CloudRun service, in the service details you will find the url, which when you open will direct to FastAPI Swagger UI.