Table
1. Download & Install Cloud SDK
Step 1 – download gcloud to your desktop
Q: How to check for your Mac is 32-bit or 64-bit?
A: Normally, if you have anything newer than 2008 Macbook, you will have 64 bit processor. You can run this on command line:
1 2 3 4 5 |
$ getconf LONG_BIT >>> 64 $ uname -m >>> arm64 |
Step 2 – run google-cloud-sdk/install.sh
1 |
$ google-cloud-sdk/install.sh |
Step 3 – run gcloud init
1 |
$ gcloud init |
If you see this on your terminal, it means you install it successfully!
1 |
Your Google Cloud SDK is configured and ready to use! |
If you see the gcloud not found error msg:
1 2 |
$ gcloud init >>> zsh: command not found: gcloud |
then try to restart your config:
1 |
$ source /Users/max/.zshrc |
run below command to set your account config:
1 2 3 |
$ gcloud config set account {email} $ gcloud auth login $ gcloud config set project {project_ID} |
Other gcloud commands
1. gcloud displays a list of your accounts.
1 |
$ gcloud auth list |
2. gcloud displays the list of your properties.
1 |
$ gcloud config list |
3. gcloud displays the projects of your properties.
1 |
$ gcloud projects list |
4. switch to other project.
1 |
$ gcloud config set project "project_ID" |
2. Prepare CloudFuncion folder
Folder structure
1 2 3 4 5 6 |
. ├── deploy.sh ├── main.py ├── requirements.txt └── templates └── submit.html |
- main.py
1 2 3 4 5 6 7 8 |
def hello_world(request): request_json = request.get_json() if request.args and "message" in request.args: return request.args.get("message") elif request_json and "message" in request_json: return request_json["message"] else: return "Hello World!" |
- deploy.sh
1 2 |
#!/bin/bash gcloud functions deploy demo --entry-point hello_world --runtime python39 --trigger-http --allow-unauthenticated |
Deploy CloudFunction with gcloud SDK
Enable the Cloud function api in Google cloud platform:
Run below command in your terminal:
1 |
bash deploy.sh |
After deployment, you can check the GCP, enter the URL, can see the “Hello World!” response.

References: