1. Packages
  2. Google Cloud (GCP) Classic
  3. How-to Guides
  4. Provisioning an OIDC Provider in Google Cloud for Pulumi Cloud
Google Cloud Classic v7.28.0 published on Friday, Jun 21, 2024 by Pulumi

Provisioning an OIDC Provider in Google Cloud for Pulumi Cloud

gcp logo
Google Cloud Classic v7.28.0 published on Friday, Jun 21, 2024 by Pulumi

    View Code Deploy this example with Pulumi

    This example will create OIDC configuration between Pulumi Cloud and Google Cloud, specifically demonstrating connectivity with Pulumi ESC. The program automates the process detailed in the Google Cloud documentation for the following activities:

    Prerequisites

    Running the Example

    Clone the examples repo and navigate to the folder for this example.

    git clone https://github.com/pulumi/examples.git
    cd examples/gcp-py-oidc-provider-pulumi-cloud
    

    Next, to deploy the application and its infrastructure, follow these steps:

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

      pulumi stack init dev
      
    2. Set your Pulumi ESC environment name and the name of your GCP Project:

      pulumi config set environmentName <your-environment-name> # replace with your environment name
      pulumi config set gcp:project <your-project-id> # replace with your GCP project ID
      
    3. Install requirements.

      python3 -m venv venv
      venv/bin/pip install -r requirements.txt
      
    4. Run pulumi up -y. Once the program completes, it will output a YAML template for you to use in the next step.

    Validating the OIDC Configuration

    This next section will walk you through validating your OIDC configuration using Pulumi ESC.

    1. Start by creating a new Pulumi ESC environment.
    2. Then, copy the template definition from the output in the CLI and paste it into your environment.
    3. Save your environment file and run the pulumi env open <your-pulumi-org>/<your-environment> command in the CLI. You should see output similar to the following:
    $ pulumi env open myOrg/myEnvironment
    {
      "environmentVariables": {
        "GOOGLE_PROJECT": 111111111111
        "CLOUDSDK_AUTH_ACCESS_TOKEN": "ya29...."
      },
      "gcp": {
        "login": {
          "accessToken": "ya29.....",
          "expiry": "2023-11-09T11:12:41Z",
          "project": 111111111111,
          "tokenType": "Bearer"
        }
      }
    }
    

    Clean-Up Resources

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

    $ pulumi destroy
    $ pulumi stack rm
    
    gcp logo
    Google Cloud Classic v7.28.0 published on Friday, Jun 21, 2024 by Pulumi