Reference website: https://www.cloudresumeapi.dev
Pre-requisites
- A Google Cloud Platform account and a project
- The Terraform CLI
- The text editor I used is Visual Studio Code
1.πTo get started, I set up your GCP and GitHub
- A project and service account in GCP
- A GitHub repository
- A Firestore database - set up a table named
Resumes
containing sample resume data
2. Create a JSON Resume
Use this schema to create your own JSON resume.
3. Clone the project repository to your local machine and change directory to the project directory
Create the infrastructure using Terraform
provider.tf
variables.tf
terraform.tfvars
main.tf
4. Create the function using Python
Google Cloud Functions: Fetch and return resume data based on an id. Utilize HTTP Trigger with anonymous access.
main.py
requirements.txt
(define the dependencies - these will be installed when the function is deployed)
In the main.py
you have to import Flask
- used for web development, including the jsnoify method used in the script and google-cloud-firestore
- used to interact with Firestore
functions-framework=3.*
-The functions-framework is a set of libraries for writing lightweight, portable Python functions that can run in various environments, including Google Cloud Functions, your local development machine, or other cloud environments. It provides a consistent execution environment and request context, and allows you to focus on writing your function logic rather than worrying about the infrastructure.
5. Initialize the Terraform project
Once you have configured the project, you can upload the Terraform configuration to Google Cloud Platform by running the following command:
|
|
To check the changes that will be made to your infrastructure.
|
|
When prompted, review the changes and type yes
to confirm that you want to apply the changes.
5. Create the Cloud Build for CI/CD :building_construction:
- I authorized Cloud Build to access the GitHub repository
- I created a trigger to build the function when a new commit is pushed to the repository
- I created the cloudbuild.yaml file to define the build steps
6. Test the API
API URL: https://europe-west2-cloud-resume-api-418008.cloudfunctions.net/cloudresumeapi-1 Or open the terminal and run the following command:
|
|