deploy-cloud-functions icon indicating copy to clipboard operation
deploy-cloud-functions copied to clipboard

Ability to create 2nd Gen functions

Open vishnumenon opened this issue 2 years ago • 31 comments

TL;DR

I'd love to take advantage of the new 2nd Gen cloud functions, and it'd be great to deploy them with github actions. Ideally, I'd like to specify the generation of the cloud function as an input in the yaml. Is there currently any way to deploy a 2nd Gen cloud function with a github action, using this repo or another one?

Detailed design

Something like `gen: 2` as an input option would be perfect

Additional information

No response

vishnumenon avatar Mar 15 '22 03:03 vishnumenon

Thanks for the FR @vishnumenon We will need to update this action to support the v2 endpoint. In the interim, you should be able to use setup-gcloud and https://cloud.google.com/sdk/gcloud/reference/beta/functions/deploy#--gen2 as a workaround.

bharathkkb avatar Mar 15 '22 15:03 bharathkkb

@bharathkkb Sounds good, I'll give that approach a try! Thanks!

vishnumenon avatar Mar 15 '22 18:03 vishnumenon

@bharathkkb Is there an update on when this Action will support the ability to set it to deploy using Gen2?

jwilksy avatar May 16 '22 17:05 jwilksy

Hi @jwilksy

Cloud Functions are still in Preview (https://cloud.google.com/functions/docs/2nd-gen/overview).

sethvargo avatar May 16 '22 18:05 sethvargo

Has someone information about release date 2ng generation?

DeryabinSergey avatar Jul 24 '22 23:07 DeryabinSergey

This is now in GA - https://cloud.google.com/blog/products/serverless/cloud-functions-2nd-generation-now-generally-available

Can the maintainers provide an update on if/when this will be supported? Thanks!

seanemmer avatar Aug 22 '22 21:08 seanemmer

I created this PR to see if we can have this available through this action. I'm available to contribute to this. Please let me know what else is necessary here.

igor-imaginemage avatar Aug 29 '22 15:08 igor-imaginemage

This feature would be tremendously helpful. Any ETA on this?

ryanwoconnor avatar Oct 01 '22 01:10 ryanwoconnor

+1 would be super helpful to have this as part of the existing github action

akshayshippy avatar Oct 24 '22 15:10 akshayshippy

@sethvargo +100500 this is also extremely useful feature (and this https://github.com/google-github-actions/deploy-cloud-functions/issues/350)

It is unclear when Google Cloud Repositories will support Cloud Functions gen 2 that is why Deploy Cloud Functions actions is only one options for convenient deployment.

mymyparty avatar Dec 06 '22 21:12 mymyparty

Right now i see errors related to Functions gen 2 like: cannot create a function because it already exists in gen 2

mymyparty avatar Dec 06 '22 21:12 mymyparty

We do not currently support Cloud Functions gen2. If you need support for gen2, you can use the setup-gcloud action and run a gcloud command manually.

sethvargo avatar Dec 06 '22 21:12 sethvargo

We do not currently support Cloud Functions gen2. If you need support for gen2, you can use the setup-gcloud action and run a gcloud command manually.

@sethvargo I think most of us in this thread understand this is not currently supported and the possible alternative(s). I think we'd more like to know if this would be available in the near future vs. later (next weeks vs. months/years), so we can accordingly plan to rewrite our pipelines or simply hold off until the feature becomes available within github actions itself.

akshayshippy avatar Dec 07 '22 14:12 akshayshippy

If you are interested in Cloud Functions gen 2 and perhaps you write in Go, then it is ok to configure following Github Actions:

  • Google Cloud Platform Auth (workload identity provider)
  • Set up Cloud SDK (gcloud cli)

and your deployment command might look like gcloud functions deploy my-cloud-function --gen2 --runtime=go119 --region=us-central1 --source=.

having configured alternatives, i could say that options above are much easier to configure than others.

mymyparty avatar Dec 07 '22 15:12 mymyparty

2gen is no longer beta yes? :)

diervo avatar Jan 31 '23 03:01 diervo

yes, they are good for production now.

mymyparty avatar Feb 07 '23 08:02 mymyparty

Any news?

maxpain avatar Mar 06 '23 15:03 maxpain

@maxpain i would suggest you use gcloud tool and a little bit of custom steps in GitHub Actions pipelines. It is pretty easy and works well for awhile.

mymyparty avatar Mar 06 '23 18:03 mymyparty

I made its working by using gcloud

Here is an example:

    steps:
    - uses: actions/checkout@v3
    - run: ls
    - id: 'auth'
      name: 'Authenticate to Google Cloud'
      uses: 'google-github-actions/auth@v1'
      with:
        workload_identity_provider: 'projects/${{ vars.PROJECT_NUMBER }}/locations/global/workloadIdentityPools/idpool/providers/idprovider'
        service_account: ${{ vars.GCP_GITHUB_SERVICE_ACCOUNT }}
        token_format: 'access_token'
    - name: 'Set up Cloud SDK'
      uses: 'google-github-actions/setup-gcloud@v1'
      with:
        version: '>= 363.0.0'
    - name: 'Use gcloud CLI'
      run: 'gcloud info'
    - name: 'Use to deploy a cloud function gen 2'
      run: 'gcloud functions deploy httptest1 --gen2 --runtime=nodejs18 --region=us-central1 --source=backend/service-secured-test --trigger-http --allow-unauthenticated --entry-point=helloHttp --memory=256MB --timeout=60s'


vyshkov avatar Mar 20 '23 17:03 vyshkov

@sethvargo @bharathkkb are you planning to add support for this in the (near) future?

hakontro avatar Apr 18 '23 11:04 hakontro

So I have to use a workaround to deploy a gen2 function? It shouldn't be this hard to add CD to a cloud function.

sydney-sisco avatar Jun 20 '23 21:06 sydney-sisco

+1 i'd be very interested on this too 😄

riccardosalamanna avatar Jul 13 '23 12:07 riccardosalamanna

above you can find solutions for Golang and Node, nothing difficult to use that for other runtimes.

mymyparty avatar Jul 13 '23 14:07 mymyparty

I made it working by using gcloud

can we still have the curl for testing the output URL? @vyshkov

danialdezfouli avatar Jul 20 '23 23:07 danialdezfouli

I made it working by using gcloud

can we still have the curl for testing the output URL?

It's not pretty, but you should be able to get the URL via the gcloud functions describe utility

For example

- nam: Get url
  id: get-url
  run: echo "url=$(gcloud functions describe function-name-here --gen2 --region europe-west2 --format json | jq .url -r)" >> $GITHUB_OUTPUT

Just make sure you get the name and region right

The above step will store the url of the function under "url" which you can reference like this

${{ steps.get-url.outputs.url }}

Wazbat avatar Aug 31 '23 15:08 Wazbat

Any ETA on 2nd gen support?

fa-aman avatar Sep 14 '23 15:09 fa-aman

@fa-aman I recommend just switching to the gcloud action like @vyshkov proposes above, it's basically the same syntax but without the limitation on gen1

hakontro avatar Sep 15 '23 14:09 hakontro

I would love to contribute to the gen2 feature support if it's just a concern of bandwidth and no other technical or roadmap limitations @sethvargo @bharathkkb. Let us know, please.

AnandShiva avatar Oct 03 '23 07:10 AnandShiva

Nudge on the 2nd gen pls…or I guess if you can point to a interim solution, thank you

kamikaz1k avatar May 03 '24 01:05 kamikaz1k

+1 on this too, support for 2nd gen would help us a lot

byrondowns avatar May 03 '24 02:05 byrondowns