terraform-google-modules/terraform-google-bootstrap

Cloubuild module: Support source repositories connected to external sources

BundyQ opened this issue · 7 comments

My client is looking to use the cloudbuild module to setup their build pipelines on Google infrastructure and is currently using Google source repositories connected to external Bitbucket repositories. I was hoping to provide a configuration for these external repositories to the Terraform module to connect them and use Cloud Build in favor of something like Bitbucket pipelines. Is there any way we can use repos that are not on GSR natively?

Hi @BundyQ
Currently I believe the only way is by mirroring to GSR from BitBucket. We support Github App triggers natively but I don't see a native option for BitBucket. @rjerrems do you know if this is possible?

Mirroring is what we were trying to do but we were wondering whether we could configure the mirroring GSRs using Terraform.

If you configure mirroring may need to do some steps manually, roughly from memory you need to do something like this:

  1. Create SSH key and copy public key
  2. Create cloud identity user with IAM permissions on repos & upload public key for that user
  3. Configure mirroring in tool of choice, in this case Bitbucket using that key

It is also possible to do it using a cookie as per the approach here https://cloud.google.com/solutions/mirroring-gitlab-repositories-to-cloud-source-repositories

I did some digging but I don't see an API endpoint either. Also saw this SO post so if there is no API support, native TF support is also probably not an option.

I found the manual steps and the SO post before but tried to avoid it as I tried to automate the whole thing.

If you configure mirroring may need to do some steps manually, roughly from memory you need to do something like this:

1. Create SSH key and copy public key

2. Create cloud identity user with IAM permissions on repos & upload public key for that user

3. Configure mirroring in tool of choice, in this case Bitbucket using that key

It is also possible to do it using a cookie as per the approach here https://cloud.google.com/solutions/mirroring-gitlab-repositories-to-cloud-source-repositories

In that case, having a few manual steps seems to be the only option. Hopefully there will be an API to support this feature at all sometime in the future as Bharath mentioned. Thank you guys for taking the time to answer this. 🙂

No worries, I will close this off for now.

Hi! Is there any continuation regarding this request?