Skip to main content

Google Cloud Functions in Python and Go

Basic example of a serverless Python and Go GCP functions (in Python)

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-py-serverless-raw
cd pulumi-examples/gcp-py-serverless-raw

This example deploys two Google Cloud Functions. “Hello World” functions are implemented in Python and Go. The Pulumi program is implemented in Python.

Prerequisites#

  1. Install Pulumi
  2. Configure GCP credentials
  3. Install Python

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Configure the project:

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

    Terminal window
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
  4. Preview and deploy changes:

    Terminal window
    pulumi up
    info: 6 changes performed:
    + 6 resources created
    Update duration: 1m14s
  5. Test it out:

    Terminal window
    curl $(pulumi stack output python_endpoint)
    curl $(pulumi stack output go_endpoint)
    "Hello World!"

Cleaning up#

Once you’re finished experimenting, destroy your stack and remove it:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.