Skip to content

Latest commit

 

History

History

hello-gcs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Python: Cloud Run - hello-gcs

A Cloud Storage triggered Python Cloud Run template.

Test locally

Install dependencies:

pip3 install -r requirements.txt

Run the function:

python3 main.py
...
 * Running on http://192.168.1.74:8080/ (Press CTRL+C to quit)
...

Inside the scripts folder, run test_local.sh to test locally:

./test_local.sh

< HTTP/1.1 204 No Content
< X-Powered-By: Express
< Date: Tue, 21 Feb 2023 12:17:25 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5

You should see the following in the service logs:

Event ID: 123451234512345
Event Type: google.cloud.storage.object.v1.finalized
Bucket: MY_BUCKET
File: MY_FILE.txt
Metageneration: 1
Created: 2020-04-23 07:38:57.230000+00:00
Updated: 2020-04-23 07:38:57.230000+00:00

Before deploying to Google Cloud

Run setup.sh to enable required services:

./setup.sh

Deploy to Google Cloud

Run deploy.sh to deploy to Google Cloud:

./deploy.sh

Test in Google Cloud

Run test_cloud.sh to test the service in Google Cloud:

./test_cloud.sh

Cleanup

When you're done, you can cleanup created resources:

./cleanup.sh