gcloud functions deploy <NAME>

Create or update a Google Cloud Function

Arguments

NameDescription
NAMEID of the function or fully qualified identifier for the function

Options

NameDescription
--account <ACCOUNT>Google Cloud Platform user account to use for invocation. Overrides the default *core/account* property value for this command invocation
--allow-unauthenticatedIf set, makes this a public function. This will allow all callers, without checking authentication
--billing-project <BILLING_PROJECT>The Google Cloud Platform project that will be charged quota for operations performed in gcloud. If you need to operate on one project, but need quota against a different project, you can use this flag to specify the billing project. If both `billing/quota_project` and `--billing-project` are specified, `--billing-project` takes precedence. Run `$ gcloud config set --help` to see more information about `billing/quota_project`
--build-env-vars-file <FILE_PATH>Path to a local YAML file with definitions for all build environment variables. All existing build environment variables will be removed before the new build environment variables are added
--clear-build-env-varsRemove all build environment variables
--clear-env-varsRemove all environment variables
--clear-labelsRemove all labels. If `--update-labels` is also specified then `--clear-labels` is applied first. + For example, to remove all labels: + $ {command} --clear-labels + To set the labels to exactly "foo" and "baz": + $ {command} --clear-labels --update-labels foo=bar,baz=qux
--clear-max-instancesClears the maximum instances setting for the function
--clear-vpc-connectorClears the VPC connector field
--configuration <CONFIGURATION>The configuration to use for this command invocation. For more information on how to use configurations, run: `gcloud topic configurations`. You can also use the CLOUDSDK_ACTIVE_CONFIG_NAME environment variable to set the equivalent of this flag for a terminal session
--egress-settings <EGRESS_SETTINGS>Egress settings controls what traffic is diverted through the VPC Access Connector resource. By default `private-ranges-only` will be used. _EGRESS_SETTINGS_ must be one of: *private-ranges-only*, *all*
--entry-point <ENTRY_POINT>Name of a Google Cloud Function (as defined in source code) that will be executed. Defaults to the resource name suffix, if not specified. For backward compatibility, if function with given name is not found, then the system will try to use function named "function". For Node.js this is name of a function exported by the module specified in `source_location`
--env-vars-file <FILE_PATH>Path to a local YAML file with definitions for all environment variables. All existing environment variables will be removed before the new environment variables are added
--flags-file <YAML_FILE>A YAML or JSON file that specifies a *--flag*:*value* dictionary. Useful for specifying complex flag values with special characters that work with any command interpreter. Additionally, each *--flags-file* arg is replaced by its constituent flags. See $ gcloud topic flags-file for more information
--flatten <KEY>Flatten _name_[] output resource slices in _KEY_ into separate records for each item in each slice. Multiple keys and slices may be specified. This also flattens keys for *--format* and *--filter*. For example, *--flatten=abc.def* flattens *abc.def[].ghi* references to *abc.def.ghi*. A resource record containing *abc.def[]* with N elements will expand to N records in the flattened output. This flag interacts with other flags that are applied in this order: *--flatten*, *--sort-by*, *--filter*, *--limit*
--format <FORMAT>Set the format for printing command output resources. The default is a command-specific human-friendly output format. The supported formats are: `config`, `csv`, `default`, `diff`, `disable`, `flattened`, `get`, `json`, `list`, `multi`, `none`, `object`, `table`, `text`, `value`, `yaml`. For more details run $ gcloud topic formats
--helpDisplay detailed help
--ignore-file <IGNORE_FILE>Override the .gcloudignore file and use the specified file instead
--impersonate-service-account <SERVICE_ACCOUNT_EMAIL>For this gcloud invocation, all API requests will be made as the given service account instead of the currently selected account. This is done without needing to create, download, and activate a key for the account. In order to perform operations as the service account, your currently selected account must have an IAM role that includes the iam.serviceAccounts.getAccessToken permission for the service account. The roles/iam.serviceAccountTokenCreator role has this permission or you may create a custom role. Overrides the default *auth/impersonate_service_account* property value for this command invocation
--ingress-settings <INGRESS_SETTINGS>Ingress settings controls what traffic can reach the function.By default `all` will be used. _INGRESS_SETTINGS_ must be one of: *all*, *internal-only*, *internal-and-gclb*
--log-httpLog all HTTP server requests and responses to stderr. Overrides the default *core/log_http* property value for this command invocation
--max-instances <MAX_INSTANCES>Sets the maximum number of instances for the function. A function execution that would exceed max-instances times out
--memory <MEMORY>Limit on the amount of memory the function can use. + Allowed values are: 128MB, 256MB, 512MB, 1024MB, and 2048MB. By default, a new function is limited to 256MB of memory. When deploying an update to an existing function, the function will keep its old memory limit unless you specify this flag
--project <PROJECT_ID>The Google Cloud Platform project ID to use for this invocation. If omitted, then the current project is assumed; the current project can be listed using `gcloud config list --format='text(core.project)'` and can be set using `gcloud config set project PROJECTID`. + `--project` and its fallback `core/project` property play two roles in the invocation. It specifies the project of the resource to operate on. It also specifies the project for API enablement check, quota, and billing. To specify a different project for quota and billing, use `--billing-project` or `billing/quota_project` property
--quietDisable all interactive prompts when running gcloud commands. If input is required, defaults will be used, or an error will be raised. Overrides the default core/disable_prompts property value for this command invocation. This is equivalent to setting the environment variable `CLOUDSDK_CORE_DISABLE_PROMPTS` to 1
--region <REGION>The Cloud region for the function. Overrides the default `functions/region` property value for this command invocation
--remove-build-env-vars <KEY>List of build environment variables to be removed
--remove-env-vars <KEY>List of environment variables to be removed
--remove-labels <KEY>List of label keys to remove. If a label does not exist it is silently ignored. If `--update-labels` is also specified then `--remove-labels` is applied first.Label keys starting with `deployment` are reserved for use by deployment tools and cannot be specified manually
--retryIf specified, then the function will be retried in case of a failure
--runtime <RUNTIME>Runtime in which to run the function. + Required when deploying a new function; optional when updating an existing function. + Choices: + - `nodejs10`: Node.js 10 - `nodejs12`: Node.js 12 - `python37`: Python 3.7 - `python38`: Python 3.8 - `go111`: Go 1.11 - `go113`: Go 1.13 - `java11`: Java 11 - `nodejs6`: Node.js 6 (deprecated) - `nodejs8`: Node.js 8 (deprecated)
--service-account <SERVICE_ACCOUNT>The email address of the IAM service account associated with the function at runtime. The service account represents the identity of the running function, and determines what permissions the function has. + If not provided, the function will use the project's default service account
--set-build-env-vars <KEY=VALUE>List of key-value pairs to set as build environment variables. All existing build environment variables will be removed first
--set-env-vars <KEY=VALUE>List of key-value pairs to set as environment variables. All existing environment variables will be removed first
--source <SOURCE>Location of source code to deploy. + Location of the source can be one of the following three options: + * Source code in Google Cloud Storage (must be a `.zip` archive), * Reference to source repository or, * Local filesystem path (root directory of function source). + Note that, depending on your runtime type, Cloud Functions will look for files with specific names for deployable functions. For Node.js, these filenames are `index.js` or `function.js`. For Python, this is `main.py`. + If you do not specify the `--source` flag: + * The current directory will be used for new function deployments. * If the function was previously deployed using a local filesystem path, then the function's source code will be updated using the current directory. * If the function was previously deployed using a Google Cloud Storage location or a source repository, then the function's source code will not be updated. + The value of the flag will be interpreted as a Cloud Storage location, if it starts with `gs://`. + The value will be interpreted as a reference to a source repository, if it starts with `https://`. + Otherwise, it will be interpreted as the local filesystem path. When deploying source from the local filesystem, this command skips files specified in the `.gcloudignore` file (see `gcloud topic gcloudignore` for more information). If the `.gcloudignore` file doesn't exist, the command will try to create it. + The minimal source repository URL is: `https://source.developers.google.com/projects/${PROJECT}/repos/${REPO}` + By using the URL above, sources from the root directory of the repository on the revision tagged `master` will be used. + If you want to deploy from a revision different from `master`, append one of the following three sources to the URL: + * `/revisions/${REVISION}`, * `/moveable-aliases/${MOVEABLE_ALIAS}`, * `/fixed-aliases/${FIXED_ALIAS}`. + If you'd like to deploy sources from a directory different from the root, you must specify a revision, a moveable alias, or a fixed alias, as above, and append `/paths/${PATH_TO_SOURCES_DIRECTORY}` to the URL. + Overall, the URL should match the following regular expression: + ``` ^https://source\.developers\.google\.com/projects/ (?<accountId>[^/]+)/repos/(?<repoName>[^/]+) (((/revisions/(?<commit>[^/]+))|(/moveable-aliases/(?<branch>[^/]+))| (/fixed-aliases/(?<tag>[^/]+)))(/paths/(?<path>.*))?)?$ ``` + An example of a validly formatted source repository URL is: + ``` https://source.developers.google.com/projects/123456789/repos/testrepo/ moveable-aliases/alternate-branch/paths/path-to=source ``` +
--stage-bucket <STAGE_BUCKET>When deploying a function from a local directory, this flag's value is the name of the Google Cloud Storage bucket in which source code will be stored. Note that if you set the `--stage-bucket` flag when deploying a function, you will need to specify `--source` or `--stage-bucket` in subsequent deployments to update your source code. To use this flag successfully, the account in use must have permissions to write to this bucket. For help granting access, refer to this guide: https://cloud.google.com/storage/docs/access-control/
--timeout <TIMEOUT>The function execution timeout, e.g. 30s for 30 seconds. Defaults to original value for existing function or 60 seconds for new functions. Cannot be more than 540s. See $ gcloud topic datetimes for information on duration formats
--trace-token <TRACE_TOKEN>Token used to route traces of service requests for investigation of issues. Overrides the default *core/trace_token* property value for this command invocation
--trigger-bucket <TRIGGER_BUCKET>Google Cloud Storage bucket name. Every change in files in this bucket will trigger function execution
--trigger-event <EVENT_TYPE>Specifies which action should trigger the function. For a list of acceptable values, call `gcloud functions event-types list`
--trigger-httpFunction will be assigned an endpoint, which you can view by using the `describe` command. Any HTTP request (of a supported type) to the endpoint will trigger function execution. Supported HTTP request types are: POST, PUT, GET, DELETE, and OPTIONS
--trigger-resource <RESOURCE>Specifies which resource from `--trigger-event` is being observed. E.g. if `--trigger-event` is `providers/cloud.storage/eventTypes/object.change`, `--trigger-resource` must be a bucket name. For a list of expected resources, call `gcloud functions event-types list`
--trigger-topic <TRIGGER_TOPIC>Name of Pub/Sub topic. Every message published in this topic will trigger function execution with message contents passed as input data. Note that this flag does not accept the format of projects/PROJECT_ID/topics/TOPIC_ID. Use this flag to specify the final element TOPIC_ID. The PROJECT_ID will be read from the active configuration
--update-build-env-vars <KEY=VALUE>List of key-value pairs to set as build environment variables
--update-env-vars <KEY=VALUE>List of key-value pairs to set as environment variables
--update-labels <KEY=VALUE>List of label KEY=VALUE pairs to update. If a label exists its value is modified, otherwise a new label is created. + Keys must start with a lowercase character and contain only hyphens (`-`), underscores (```_```), lowercase characters, and numbers. Values must contain only hyphens (`-`), underscores (```_```), lowercase characters, and numbers. + Label keys starting with `deployment` are reserved for use by deployment tools and cannot be specified manually
--user-output-enabledPrint user intended output to the console. Overrides the default *core/user_output_enabled* property value for this command invocation. Use *--no-user-output-enabled* to disable
--verbosity <VERBOSITY>Override the default verbosity for this command. Overrides the default *core/verbosity* property value for this command invocation. _VERBOSITY_ must be one of: *debug*, *info*, *warning*, *error*, *critical*, *none*
--vpc-connector <VPC_CONNECTOR>The VPC Access connector that the function can connect to. It can be either the fully-qualified URI, or the short name of the VPC Access connector resource. If the short name is used, the connector must belong to the same project. The format of this field is either `projects/${PROJECT}/locations/${LOCATION}/connectors/${CONNECTOR}` or `${CONNECTOR}`, where `${CONNECTOR}` is the short name of the VPC Access connector