Skip to main content

Google Cloud Functions in Python deployed with C#

A minimal C# Pulumi program using Google Cloud Functions.

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-cs-functions
cd pulumi-examples/gcp-cs-functions

This example deploys a Google Cloud Function implemented in Python. The Pulumi program is implemented in C#.

Prerequisites#

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

Deploying the example#

  1. Create a new stack, which is an isolated deployment target for this example:

    Terminal window
    pulumi stack init dev
  2. Set the GCP project and region:

    Terminal window
    pulumi config set gcp:project <your-gcp-project>
    pulumi config set gcp:region <gcp-region>
  3. Run pulumi up to preview and deploy changes:

    Terminal window
    pulumi up
    Previewing changes:
    ...
    Performing changes:
    ...
    info: 10 changes performed:
    + 10 resources created
    Update duration: 45s
  4. Check the deployed function endpoint:

    Terminal window
    pulumi stack output PythonEndpoint
    curl "$(pulumi stack output PythonEndpoint)"
    https://us-central1-test-1234.cloudfunctions.net/python-func-742a512
    Hello World!
  5. From there, feel free to experiment. Simply making edits and running pulumi up will incrementally update your stack.

Cleaning up#

Once you are done, you can destroy all of the resources, and the stack:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.