Programatically creating a cloudbuild v2 host connection via code

Hello community, I would like to please ask for some guidance on creating a Host connection from a GCP project to a GitHub organization through a GitHubApp that is not GCP’s official app and via code Go Client Library and I am struggling with it to make it happen.

I explain a bit more in detail:

  • I am building a cloud wrapper which is a tool for handling cloud services automatically under the hood without the developer having to manually create cloud triggers / cloud run deployments. So with just a few clicks, get a boilerplate web application deployed up and running.
  • The idea is that most of the configuration I will do on behalf of the user, for that I already got a GitHub app for my platform and a GCP Service account configured with all the roles necessary.
  • I am facing some challenges to do the following configuration via Go Client Library:
    •   CreateConnection
      

      A Host connection on v2 of Cloud build.

    • Using Go Client library:

      "cloud.google.com/go/cloudbuild/apiv2/cloudbuildpb"
      "cloud.google.com/go/cloudbuild/apiv2"
      
    • Not using default Cloud Build official, GitHubApp, but using my own platforms GitHub App (requesting all the same permissions as the google app will need)

    • Grabbing the Private Key from my GHApp, creating a user access token, storing the access token in a Secret, and passing the secret + the installation app id to the cloudbuildv2pb.CreateConnectionRequest

    • Granting necessary permissions to Cloud build service account to manage secrets.

I can also manually request to the user, under a config stage, to manually do this:

Or simply in the gcloud cli, but I want to see if its possible to automate.

The result I get when trying to create the connection is that the application id is invalid:

invalid installation ID 51XXXXXX

Please if you could assist, I tried searching for this issue with no luck, also ChatGPT doesn’t have the proper knowledge on this api’s.

Maybe its not possible to use an external GithubApp and its always required to use the google cloud one? But in that case, my doubt is, then why is the api methods available in the public api library?

Thanks in advance