Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Google Cloud Functions infrastructure

Configure a Google Cloud Functions infrastructure definition with a Google Cloud connector, project, and region.

An infrastructure definition links your logical Harness environment to the actual physical resources. For Google Cloud Functions, it specifies the Google Cloud connector, project, and region Harness deploys to.


What you will learn from this topic

  • How to create an infrastructure definition for Google Cloud Functions.

  • How to configure the Google Cloud connector, project, and region, and control simultaneous deployments.


Before you begin

  • An environment to associate the infrastructure definition with.

  • A Google Cloud connector with access to the target project.

  • The Google Cloud project and region where the function deploys.


Create an environment

  1. Go to Deployments, expand the drop-down, and select Environments.

  2. Select + New Environment.

  3. Enter a name and select an environment type: Pre-Production or Production. The type affects governance policies and deployment dashboards.

  4. Select Save.

Harness opens the environment detail page with two tabs: Configuration and Infrastructure Definitions.


Create an infrastructure definition

  1. From the environment's Infrastructure Definitions tab, click + New Infrastructure, or click + Add in the stage wizard's infrastructure step.

  2. Search for and select Google Cloud Functions as the infrastructure type.

  3. Enter a Name. Harness generates the Id automatically; edit it using the pencil icon if needed.

  4. Set Storage to Inline or a Git repository.

  5. Expand Google Cloud Provider Details, then Provisioner Configuration, and select a Connector, Project, and Region.

  6. Configure Simultaneous deployments and, optionally, Scope to Specific Services.

  7. Click Save.

Top-level fields

Field
Description

Name

A name for the infrastructure definition. Harness generates the Id automatically; you can edit it using the pencil icon.

Storage

Where the infrastructure definition is stored: Inline or a Git repository.

Google Cloud provider details

Expand Google Cloud Provider Details, then Provisioner Configuration, to set the following fields.

Field
Required
Description

Connector

Yes

The Google Cloud connector Harness uses to authenticate and deploy to this project.

Project

Yes

The Google Cloud project where the function deploys.

Region

Yes

The Google Cloud region where the function deploys.

Simultaneous deployments

Field
Default
Description

Simultaneous deployments

False

By default, Harness queues deployments to the same infrastructure to avoid conflict. Enable to allow simultaneous deployments.


Authentication

The Google Cloud connector used in the Connector field supports three authentication methods: service account, OIDC, and inherit from delegate.

Service account

Harness activates the key using gcloud auth activate-service-account. To set this up, create a connector, select GCP, choose Specify credentials here, then upload or paste the service account JSON key and save.

OIDC

Harness uses a Workload Identity Pool to exchange tokens for GCP credentials. Setup requires the Workload Identity Pool ID, Workload Provider ID, GCP project ID, and the service account email to impersonate.

Required permissions for OIDC

OIDC authentication requires the iam.workloadIdentityPools.createCredentialConfig permission, plus iam.serviceAccounts.actAs on the service identity.

Inherit from delegate

This method suits delegates deployed on GKE with Workload Identity or on GCE with an attached service account. Harness runs gcloud auth list --filter=status:ACTIVE to find the active account, then uses Application Default Credentials.


IAM permissions

The connector's credentials must have the following permissions to deploy Google Cloud Functions resources.

Minimum permissions

Google Cloud Functions (Gen 2) deploys through the Cloud Run API, so the connector's credentials need both the cloudfunctions.* and run.* permissions below.

Operation
Permissions required

Create or update a function

cloudfunctions.functions.create, cloudfunctions.functions.update

List functions

cloudfunctions.functions.list

Get function deployment status

cloudfunctions.operations.get

Create or update the underlying Cloud Run service

run.services.create, run.services.update, run.services.get

Create and inspect Cloud Run revisions

run.revisions.create, run.revisions.get

Create and inspect Cloud Run routes

run.routes.create, run.routes.get

Call the Cloud Functions and Cloud Run APIs

cloudfunctions.functions.getIamPolicy, cloudfunctions.functions.testIamPermissions, run.services.getIamPolicy, run.services.testIamPermissions

Service account impersonation

iam.serviceAccounts.actAs (required on the function's service identity, even when the deployer and service identity are the same account)

Harness also needs access to the Cloud Storage bucket that hosts the function source ZIP file.

Predefined roles

Role
Purpose

roles/cloudfunctions.admin (Cloud Functions Admin)

Full access to functions, operations, and locations. Also grant a Cloud Run role such as roles/run.admin, since Google Cloud Functions Gen 2 deploys through Cloud Run.

roles/cloudfunctions.developer (Cloud Functions Developer)

Read and write access to all functions-related resources. Also grant a Cloud Run role such as roles/run.admin, since Google Cloud Functions Gen 2 deploys through Cloud Run.

roles/run.admin (Cloud Run Admin)

Full administrative access to the underlying Cloud Run service. Required for deploying Google Cloud Functions.

roles/storage.objectViewer (Storage Object Viewer)

Read access to the Cloud Storage bucket hosting the function source ZIP.

roles/storage.objectAdmin (Storage Object Admin)

Read and write access to the Cloud Storage bucket hosting the function source ZIP.


Next steps

Last updated

Was this helpful?