How to update GCP Functions source from gitlab?

Viewed 55

I have an existing GCP Function just with the default hello-world source. I would like to push updates to the Function's source from Gitlab. I have setup the gitlab-ci.yml file and necessary service accounts but I keep getting an error that the function already exists and to delete the conflicting function first or use a different function name. I am not trying to create a new function, only update the source code of an existing one.

Thank you

Here's the .gitlab-ci.yml

stages:
- deploy

deploy-cloud-function:
  stage: deploy
  image: google/cloud-sdk
  script:
    - echo $GCP_ACCOUNT_KEY > gcloud-service-key.json
    - gcloud auth activate-service-account --key-file gcloud-service-key.json
    - gcloud config set project myprojectname
    - gcloud functions deploy myfunctionname
      --source=.
      --trigger-http
      --runtime=python310

  rules:
    - if: $CI_COMMIT_BRANCH == "master"

Here's the error:

ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Ok], message=[Failed to create function, function myfunctionname already exists under 2nd gen environment. Please delete conflicting function first or deploy the function with a different name.]

0 Answers
Related