artemrys / google-cloud-functions-deploy

GitHub repository mirror for custom pipeline to deploy Google Cloud Functions. https://bitbucket.org/ArtemRys/google-cloud-functions-deploy
Apache License 2.0
4 stars 0 forks source link

Allow unauthenticated functions #17

Closed yonner closed 1 year ago

yonner commented 1 year ago

For some reason passing the "--allow-unauthenticated" in the EXTRA_ARGS doesnt work and gives the error : -

WARNING: Setting IAM policy failed, try "gcloud alpha functions add-iam-policy-binding v1 --region=europe-west1 --member=allUsers --role=roles/cloudfunctions.invoker"

Would it be possible to add another variable in the pipe : -

"ALLOW_UNAUTHENTICATED" : 'true'

Which defaults to 'false' which calls the above gcloud alpha function, or some how parses the "--allow-unauthenticated" and does the same?

Thank you

Jason

artemrys commented 1 year ago

Thanks Jason for the feedback, I'll check it out next week.

artemrys commented 1 year ago

@yonner actually, passing --allow-unauthenticated works for me, this is my config below. Mind sharing yours so I can reproduce the issue? I am not positive that specifying --allow-unauthenticated will help to resolve the issue for you.

push: &push
  step:
    name: GCF Deploy
    image: python:3.6.7
    script:
      - pipe: docker://artemrys/google-cloud-functions-deploy:latest
        variables:
          KEY_FILE: $KEY_FILE
          PROJECT: $PROJECT
          FUNCTION_NAME: 'hello_world'
          ENTRY_POINT: 'hello_world'
          RUNTIME: 'python37'
          EXTRA_ARGS: '--allow-unauthenticated'
    services:
    - docker

pipelines:
  branches:
    master:
    - <<: *push
yonner commented 1 year ago

@artemrys Thanks for the response, my script is pretty much the same as yours : -

- pipe: docker://artemrys/google-cloud-functions-deploy:latest
                variables:
                  KEY_FILE: $KEY_FILE
                  PROJECT: $PROJECT
                  FUNCTION_NAME: 'v1'
                  ENTRY_POINT: 'v1'
                  RUNTIME: 'nodejs14'
                  EXTRA_ARGS: '--region=europe-west1 --env-vars-file env.yaml --allow-unauthenticated'

INFO: Starting deployment GCP Cloud Function... gcloud functions deploy v1 --project=my-project --runtime=nodejs14 --entry-point=v1 --source . --trigger-http --region=europe-west1 --env-vars-file env.yaml --allow-unauthenticated --verbosity=warning Created .gcloudignore file. See gcloud topic gcloudignore for details. Deploying function (may take a while - up to 2 minutes)... WARNING: Setting IAM policy failed, try "gcloud alpha functions add-iam-policy-binding v1 --region=europe-west1 --member=allUsers --role=roles/cloudfunctions.invoker" ..............................................................................................................................done.

artemrys commented 1 year ago

@yonner I was able to reproduce the issue, my service account had "Owner" permissions for testing purposes, I changed it to "Editor" and reproduced the issue. Also, I found an article in Google's troubleshooting section here, please check it out, I think it should resolve your issue.

Also, I updated the underlying Google Cloud SDK image to the latest image and pushed a new image (0.3.0) to Dockerhub, so please be aware if you are using :latest tag.

yonner commented 1 year ago

@artemrys I managed to set up my deployment service accounts so that the --allow-unauthenticated works. Thanks for the help, i will close this issue.