Google Cloud Functions in Python, Go, and TypeScript deployed with TypeScript
Basic example of a serverless GCP functions in TypeScript, Python and Go
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set gcp-ts-serverless-rawcd pulumi-examples/gcp-ts-serverless-rawThis example deploys three Google Cloud Functions. “Hello World” functions are implemented in Python, Go, and TypeScript. The Pulumi program is implemented in TypeScript.
Prerequisites#
Deploying the example#
-
Create a new stack:
Terminal window pulumi stack init testing -
Configure your GCP project and region:
Terminal window pulumi config set gcp:project <your-gcp-project>pulumi config set gcp:region <gcp-region> -
Install dependencies:
Terminal window npm install -
Deploy the stack:
Terminal window pulumi upPreviewing changes:...Performing changes:...info: 6 changes performed:+ 6 resources createdUpdate duration: 1m14s -
Test the deployed functions:
Terminal window curl $(pulumi stack output pythonEndpoint)curl $(pulumi stack output goEndpoint)curl $(pulumi stack output tsEndpoint)"Hello World!""Hello World!""Hello World!"
Cleaning up#
Once you’re finished experimenting, destroy your stack and remove it to avoid incurring any additional cost:
pulumi destroypulumi stack rmTypeScript notes#
In the typescriptfunc folder you’ll notice more than a function. Some configuration is needed to inform GCP how to build TypeScript for the Node.js runtime environment. See this example from Google for more details.