Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to create 2nd Gen functions #304

Closed
vishnumenon opened this issue Mar 15, 2022 · 33 comments · Fixed by #409
Closed

Ability to create 2nd Gen functions #304

vishnumenon opened this issue Mar 15, 2022 · 33 comments · Fixed by #409
Labels
enhancement New feature or request

Comments

@vishnumenon
Copy link

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 vishnumenon added the enhancement New feature or request label Mar 15, 2022
@bharathkkb
Copy link
Contributor

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.

@vishnumenon
Copy link
Author

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

@jwilksy
Copy link

jwilksy commented May 16, 2022

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

@sethvargo
Copy link
Member

Hi @jwilksy

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

@DeryabinSergey
Copy link

Has someone information about release date 2ng generation?

@seanemmer
Copy link

seanemmer commented Aug 22, 2022

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!

@igor-imaginemage
Copy link

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.

@ryanwoconnor
Copy link

ryanwoconnor commented Oct 1, 2022

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

@akshayshippy
Copy link

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

@mymyparty
Copy link

@sethvargo +100500 this is also extremely useful feature (and this #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
Copy link

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

@sethvargo
Copy link
Member

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.

@akshayshippy
Copy link

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.

@mymyparty
Copy link

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.

@diervo
Copy link

diervo commented Jan 31, 2023

2gen is no longer beta yes? :)

@mymyparty
Copy link

yes, they are good for production now.

@maxpain
Copy link

maxpain commented Mar 6, 2023

Any news?

@mymyparty
Copy link

@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.

@vyshkov
Copy link

vyshkov commented Mar 20, 2023

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'


bkochendorfer added a commit to bkochendorfer/yari that referenced this issue Mar 30, 2023
The existing deploy-cloud-functions GHA is limited to only running
CloudFunction V1. This attempts to run the deploy command directly
from gcloud instead and deploys the function in multiple regions

Github Issue:
google-github-actions/deploy-cloud-functions#304
caugner added a commit to mdn/yari that referenced this issue Apr 6, 2023
* feat: Deploy cloud function in multiple regions

The existing deploy-cloud-functions GHA is limited to only running
CloudFunction V1. This attempts to run the deploy command directly
from gcloud instead and deploys the function in multiple regions

Github Issue:
google-github-actions/deploy-cloud-functions#304

* ci(stage-build): fix function deployment

Fixes typos and splits the --set-env-vars/--set-secrets options.

* Update .github/workflows/stage-build.yml

Co-authored-by: Claas Augner <[email protected]>

* Update stage-build.yml

* Update .github/workflows/stage-build.yml

Co-authored-by: Claas Augner <[email protected]>

---------

Co-authored-by: Claas Augner <[email protected]>
Co-authored-by: Claas Augner <[email protected]>
@hakontro
Copy link

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

@sydney-sisco
Copy link

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.

@riccardosalamanna
Copy link

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

@mymyparty
Copy link

mymyparty commented Jul 13, 2023

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

@danialdezfouli
Copy link

danialdezfouli commented Jul 20, 2023

I made it working by using gcloud

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

@Wazbat
Copy link

Wazbat commented Aug 31, 2023

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 }}

@fa-aman
Copy link

fa-aman commented Sep 14, 2023

Any ETA on 2nd gen support?

@hakontro
Copy link

@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

@AnandShiva
Copy link

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.

@kamikaz1k
Copy link

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

@byrondowns
Copy link

byrondowns commented May 3, 2024

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

@sethvargo
Copy link
Member

Alright, so here's the situation with 2nd generation Cloud Functions...

Creating second generation cloud functions is only available via the v2 Cloud Functions API (cloudfunctions.googleapis.com/v2), which is significantly different from the v1 endpoint. For example, compare the resource definitions of functions:

In addition to new fields, there are remove fields between the two API versions (as is expected in major version revisions). It's possible to deploy both 1st generation and 2nd generation Cloud Functions via the v2 endpoint, but the entire surface of this GitHub Action needs to change to support that, given the significantly different fields and structure (see #409).

Given the relatively little overlap, it's difficult to create an "interim" release that supports both the v1 and v2 APIs, so I think the only path forward is to do major breaking changes to the surface for the GitHub Action that supports the v2 APIs (and thus 2nd generation functions). Thoughts?

@BoscoDomingo
Copy link

Alright, so here's the situation with 2nd generation Cloud Functions...

Creating second generation cloud functions is only available via the v2 Cloud Functions API (cloudfunctions.googleapis.com/v2), which is significantly different from the v1 endpoint. For example, compare the resource definitions of functions:

* v1: https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions#resource:-cloudfunction

* v2:  https://cloud.google.com/functions/docs/reference/rest/v2/projects.locations.functions#resource:-function

In addition to new fields, there are remove fields between the two API versions (as is expected in major version revisions). It's possible to deploy both 1st generation and 2nd generation Cloud Functions via the v2 endpoint, but the entire surface of this GitHub Action needs to change to support that, given the significantly different fields and structure (see #409).

Given the relatively little overlap, it's difficult to create an "interim" release that supports both the v1 and v2 APIs, so I think the only path forward is to do major breaking changes to the surface for the GitHub Action that supports the v2 APIs (and thus 2nd generation functions). Thoughts?

@sethvargo Sounds about right to me. I would expect a major version update to come with breaking changes (that's the point) so any related tooling may also break. I'm in favour of whatever makes it easier and faster for you to ship this, especially since there's currently no "official" way to deploy a v2 Function via GH Actions.

sethvargo added a commit that referenced this issue May 22, 2024
This PR moves everything to use the `v2` API and adopts the "GEN_2"
function type. This is a major breaking change that should be released
as v3. As per our support policy, we will support v2 and v3, with v2
receiving critical bug fixes. We will drop support for v1.

- Fixes
#304
- Closes
#384
(N/A in GEN_2)
- Fixes
#373
- Closes
#399
(Cloud Functions recommends against CI/CD systems controlling IAM
permissions)
- Closes
#9
(N/A)
@maxpain
Copy link

maxpain commented May 22, 2024

Finally? Wow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.