Skip to content

ccorcos/gcloud-function-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Cloud Function Boilerplate

Setup

  • Signup for Google Cloud
  • Create a new project project.
  • Install the gcloud cli tool.
     brew cask install google-cloud-sdk
  • Login
     gcloud auth login
  • Find the project id you just created and set it as the current project.
     gcloud projects list
     gcloud config set project translator-246304

Development

  • (optional) If you want to use gcloud services, you'll need to create some credentials.
     gcloud iam service-accounts create chet-dev
  • Add an owner policy
     gcloud projects add-iam-policy-binding translator-246304 --member "serviceAccount:chet-dev@translator-246304.iam.gserviceaccount.com" --role "roles/owner"
  • Create the credentials file.
     gcloud iam service-accounts keys create credentials.json --iam-account chet-dev@translator-246304.iam.gserviceaccount.com
  • Start the development server (you may have to build the first bundle npm run build before you do this.)
     npm start
  • Test that its working
     curl curl http://localhost:8080/

Deploying

  • Read about it here
  • Build the TypeScript files:
     npm run build
  • Edit the package.json deploy script to reference the name of the function you want to deploy. Currently, it's called translate.
  • Deploy
     npm run deploy
  • The deployment should log an endpoint url that you can test.
     curl https://us-central1-translator-246304.cloudfunctions.net/translate

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published