# Class CloudFunction (1.24.0)

1.24.0 (latest) 1.23.0 1.22.0 1.21.0 1.20.4 1.19.0 1.18.1 1.16.5 1.15.0 1.14.0 1.13.2 1.12.0 1.11.0 1.10.1 1.9.0 1.8.3 1.7.0 1.6.0 1.5.2 1.4.0 1.3.1 1.2.0 1.1.1 1.0.4 0.7.2 0.6.1 0.5.1 0.4.0 0.1.0

    CloudFunction(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Describes a Cloud Function that contains user computation
executed in response to an event. It encapsulate function and
triggers configurations.

This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.

.. _oneof: <https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields>

| ## Attributes ||
|---|---|
| **Name** | **Description** |
| `name` | `str` A user-defined name of the function. Function names must be unique globally and match pattern `projects/*/locations/*/functions/*` |
| `description` | `str` User-provided description of a function. |
| `source_archive_url` | `str` The Google Cloud Storage URL, starting with `gs://`, pointing to the zip archive which contains the function. This field is a member of `oneof`_ `source_code`. |
| `source_repository` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.SourceRepository` \*\*Beta Feature\*\* The source repository where a function is hosted. This field is a member of `oneof`_ `source_code`. |
| `source_upload_url` | `str` The Google Cloud Storage signed URL used for source uploading, generated by calling \[google.cloud.functions.v1.GenerateUploadUrl\]. The signature is validated on write methods (Create, Update) The signature is stripped from the Function object on read methods (Get, List) This field is a member of `oneof`_ `source_code`. |
| `https_trigger` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.HttpsTrigger` An HTTPS endpoint type of source that can be triggered via URL. This field is a member of `oneof`_ `trigger`. |
| `event_trigger` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.EventTrigger` A source that fires events in response to a condition in another service. This field is a member of `oneof`_ `trigger`. |
| `status` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.CloudFunctionStatus` Output only. Status of the function deployment. |
| `entry_point` | `str` The name of the function (as defined in source code) that will be executed. Defaults to the resource name suffix (ID of the function), if not specified. |
| `runtime` | `str` The runtime in which to run the function. Required when deploying a new function, optional when updating an existing function. For a complete list of possible choices, see the \`\``gcloud`\` command reference |
| `timeout` | `google.protobuf.duration_pb2.Duration` The function execution timeout. Execution is considered failed and can be terminated if the function is not completed at the end of the timeout period. Defaults to 60 seconds. |
| `available_memory_mb` | `int` The amount of memory in MB available for a function. Defaults to 256MB. |
| `service_account_email` | `str` The email of the function's service account. If empty, defaults to `{project_id}@appspot.gserviceaccount.com`. |
| `update_time` | `google.protobuf.timestamp_pb2.Timestamp` Output only. The last update timestamp of a Cloud Function. |
| `version_id` | `int` Output only. The version identifier of the Cloud Function. Each deployment attempt results in a new version of a function being created. |
| `labels` | `MutableMapping[str, str]` Labels associated with this Cloud Function. |
| `environment_variables` | `MutableMapping[str, str]` Environment variables that shall be available during function execution. |
| `build_environment_variables` | `MutableMapping[str, str]` Build environment variables that shall be available during build time. |
| `network` | `str` Deprecated: use vpc_connector |
| `max_instances` | `int` The limit on the maximum number of function instances that may coexist at a given time. In some cases, such as rapid traffic surges, Cloud Functions may, for a short period of time, create more instances than the specified max instances limit. If your function cannot tolerate this temporary behavior, you may want to factor in a safety margin and set a lower max instances value than your function can tolerate. See the \`Max Instances |
| `min_instances` | `int` A lower bound for the number function instances that may coexist at a given time. |
| `vpc_connector` | `str` The VPC Network Connector that this cloud function can connect to. It can be either the fully-qualified URI, or the short name of the network connector resource. The format of this field is `projects/*/locations/*/connectors/*` This field is mutually exclusive with `network` field and will eventually replace it. See \`the VPC documentation |
| `vpc_connector_egress_settings` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.CloudFunction.VpcConnectorEgressSettings` The egress settings for the connector, controlling what traffic is diverted through it. |
| `ingress_settings` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.CloudFunction.IngressSettings` The ingress settings for the function, controlling what traffic can reach it. |
| `kms_key_name` | `str` Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources. It must match the pattern `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. If specified, you must also provide an artifact registry repository using the `docker_repository` field that was created with the same KMS crypto key. The following service accounts need to be granted the role 'Cloud KMS CryptoKey Encrypter/Decrypter (roles/cloudkms.cryptoKeyEncrypterDecrypter)' on the Key/KeyRing/Project/Organization (least access preferred). 1. Google Cloud Functions service account (service-{project_number}@gcf-admin-robot.iam.gserviceaccount.com) - Required to protect the function's image. 2. Google Storage service account (service-{project_number}@gs-project-accounts.iam.gserviceaccount.com) - Required to protect the function's source code. If this service account does not exist, deploying a function without a KMS key or retrieving the service agent name provisions it. For more information, see https://cloud.google.com/storage/docs/projects#service-agents and https://cloud.google.com/storage/docs/getting-service-agent#gsutil. Google Cloud Functions delegates access to service agents to protect function resources in internal projects that are not accessible by the end user. |
| `build_worker_pool` | `str` Name of the Cloud Build Custom Worker Pool that should be used to build the function. The format of this field is `projects/{project}/locations/{region}/workerPools/{workerPool}` where `{project}` and `{region}` are the project id and region respectively where the worker pool is defined and `{workerPool}` is the short name of the worker pool. If the project id is not the same as the function, then the Cloud Functions Service Agent (`service-`) must be granted the role Cloud Build Custom Workers Builder (`roles/cloudbuild.customworkers.builder`) in the project. |
| `build_id` | `str` Output only. The Cloud Build ID of the latest successful deployment of the function. |
| `build_name` | `str` Output only. The Cloud Build Name of the function deployment. `projects/`. |
| `secret_environment_variables` | `MutableSequence[https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.SecretEnvVar]` Secret environment variables configuration. |
| `secret_volumes` | `MutableSequence[https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.SecretVolume]` Secret volumes configuration. |
| `source_token` | `str` Input only. An identifier for Firebase function sources. Disclaimer: This field is only supported for Firebase function deployments. |
| `docker_repository` | `str` User-managed repository created in Artifact Registry to which the function's Docker image will be pushed after it is built by Cloud Build. May optionally be encrypted with a customer-managed encryption key (CMEK). If unspecified and `docker_registry` is not explicitly set to `CONTAINER_REGISTRY`, GCF will create and use a default Artifact Registry repository named 'gcf-artifacts' in the region. It must match the pattern `projects/{project}/locations/{location}/repositories/{repository}`. Cross-project repositories are not supported. Cross-location repositories are not supported. Repository format must be 'DOCKER'. |
| `docker_registry` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.CloudFunction.DockerRegistry` Docker Registry to use for this deployment. As of March 2025, `CONTAINER_REGISTRY` option is no longer available in response to Container Registry's deprecation: https://cloud.google.com/artifact-registry/docs/transition/transition-from-gcr Please use Artifact Registry instead, which is the default choice. If unspecified, it defaults to `ARTIFACT_REGISTRY`. If `docker_repository` field is specified, this field should either be left unspecified or set to `ARTIFACT_REGISTRY`. |
| `automatic_update_policy` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.CloudFunction.AutomaticUpdatePolicy` This field is a member of `oneof`_ `runtime_update_policy`. |
| `on_deploy_update_policy` | `https://docs.cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.types.CloudFunction.OnDeployUpdatePolicy` This field is a member of `oneof`_ `runtime_update_policy`. |
| `build_service_account` | `str` A service account the user provides for use with Cloud Build. The format of this field is `projects/{projectId}/serviceAccounts/{serviceAccountEmail}`. |

## Classes

### AutomaticUpdatePolicy

    AutomaticUpdatePolicy(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Security patches are applied automatically to the runtime
without requiring the function to be redeployed.

### BuildEnvironmentVariablesEntry

    BuildEnvironmentVariablesEntry(
        mapping=None, *, ignore_unknown_fields=False, **kwargs
    )

The abstract base class for a message.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `kwargs` | `dict` Keys and values corresponding to the fields of the message. |
| `mapping` | ``Union[dict, `.Message`]`` A dictionary or message to be used to determine the values for this message. |
| `ignore_unknown_fields` | `Optional(bool)` If True, do not raise errors for unknown fields. Only applied if `mapping` is a mapping type or there are keyword parameters. |

### DockerRegistry

    DockerRegistry(value)

Docker Registry to use for storing function Docker images.

### EnvironmentVariablesEntry

    EnvironmentVariablesEntry(mapping=None, *, ignore_unknown_fields=False, **kwargs)

The abstract base class for a message.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `kwargs` | `dict` Keys and values corresponding to the fields of the message. |
| `mapping` | ``Union[dict, `.Message`]`` A dictionary or message to be used to determine the values for this message. |
| `ignore_unknown_fields` | `Optional(bool)` If True, do not raise errors for unknown fields. Only applied if `mapping` is a mapping type or there are keyword parameters. |

### IngressSettings

    IngressSettings(value)

Available ingress settings.

This controls what traffic can reach the function.

If unspecified, ALLOW_ALL will be used.

### LabelsEntry

    LabelsEntry(mapping=None, *, ignore_unknown_fields=False, **kwargs)

The abstract base class for a message.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `kwargs` | `dict` Keys and values corresponding to the fields of the message. |
| `mapping` | ``Union[dict, `.Message`]`` A dictionary or message to be used to determine the values for this message. |
| `ignore_unknown_fields` | `Optional(bool)` If True, do not raise errors for unknown fields. Only applied if `mapping` is a mapping type or there are keyword parameters. |

### OnDeployUpdatePolicy

    OnDeployUpdatePolicy(mapping=None, *, ignore_unknown_fields=False, **kwargs)

Security patches are only applied when a function is
redeployed.

### VpcConnectorEgressSettings

    VpcConnectorEgressSettings(value)

Available egress settings.

This controls what traffic is diverted through the VPC Access
Connector resource. By default PRIVATE_RANGES_ONLY will be used.