Skip to content

Event-driven image resizing using Cloud Storage, Eventarc, and Cloud Run

Notifications You must be signed in to change notification settings

eddiehale3/gcp-image-resize-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Cloud Image Resize Demo

This project demonstrates how to trigger CloudRun using an Eventarc rule from Cloud Storage.

Architecture

Usage

Requirements

Before using this project, you must ensure the following pre-requisites are fulfilled:

  1. Terraform is installed on the machine where Terraform is executed.
  2. The Service Account you execute with has the right permissions
  3. The necessary APIs are active on the project

Security

In order to execute this project you must have:

  1. A Service Account with roles to deploy GCP resources using Terraform.

    • Documentation on Service Accounts here
    • Roles needed:
      • roles/eventarc.admin
      • roles/run.admin
      • roles/iam.securityAdmin
      • roles/iam.securityReviewer
      • roles/iam.serviceAccountAdmin
      • roles/iam.serviceAccountUser
      • roles/storage.admin
  2. A Service Account Key associated with the Service Account from #1. Then update credentials under terraform/main.tf to point to this json file.

Build and upload image to GCR

To build the CloudRun container:

  1. Install Docker and the pack tool.

  2. Build a container from your function using the Functions buildpacks:

cd src && npm i
pack build \
  --builder gcr.io/buildpacks/builder:v1 \
  --env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
  --env GOOGLE_FUNCTION_TARGET=imageResize \
  gcr.io/PROJECT_ID/IMAGE_NAME

Where PROJECT_ID is your GCP project ID and IMAGE_NAME is the name of your image.

  1. Upload to your Google Cloud project image repository using gcloud credential helper
docker push gcr.io/PROJECT_ID/IMAGE_NAME

Where PROJECT_ID is your GCP project ID and IMAGE_NAME is the name of your image.

  1. Update image variable in terraform/variables.tf with this image name

About

Event-driven image resizing using Cloud Storage, Eventarc, and Cloud Run

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published