Skip to main content

Google Cloud Functions

GCP Functions example

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set gcp-ts-functions
cd pulumi-examples/gcp-ts-functions

An example of deploying an HTTP Google Cloud Function endpoint using TypeScript.

Prerequisites#

  1. Install Pulumi
  2. Configure GCP credentials
  3. Install Node.js

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init gcp-fn
  2. Configure your GCP project and region:

    Terminal window
    pulumi config set gcp:project <projectname>
    pulumi config set gcp:region <region>
  3. Install dependencies:

    Terminal window
    npm install
  4. Deploy the stack:

    Terminal window
    pulumi up
    Previewing changes:
    ...
    Performing changes:
    ...
    info: 6 changes performed:
    + 6 resources created
    Update duration: 39.65130324s
  5. Check the deployed function endpoint:

    Terminal window
    pulumi stack output url
    curl "$(pulumi stack output url)"
    https://us-central1-pulumi-development.cloudfunctions.net/greeting-function-7f95447
    Greetings from Google Cloud Functions!

Cleaning up#

Once you’re finished experimenting, destroy your stack and remove it to avoid incurring any additional cost:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.