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

google_cloudbuild_trigger not accepting repository-related information when using webhook_config and filename #10085

Closed
giefferre opened this issue Sep 16, 2021 · 6 comments
Assignees
Labels

Comments

@giefferre
Copy link

giefferre commented Sep 16, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.0.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/google v3.84.0

Affected Resource(s)

  • google_cloudbuild_trigger

Terraform Configuration Files

resource "google_cloudbuild_trigger" "webhooktrigger" {
  name = format("%s-myapp-webhook-trigger", var.environment)

  webhook_config {
    secret = google_secret_manager_secret_version.webhook.name
  }

  filename = format("cloudbuild/%s.yaml", var.cloudbuild_filename)

  # There is no way I can specify the repository (in this case on 
  # Github, but same happens for GCP hosted repos)
  # neither the branch name or tags to trigger the build for.
  # This is in fact possible using the GCP console in the browser!
}

Expected Behavior

I expected to have a way to specify the source repository configuration for the webhook to use for the build.

Actual Behavior

The webhook has been created but it does not point to a repository configuration (name AND branch or tag).

This is in fact possible using the online console, please see attached screenshot

Screenshot 2021-09-16 at 16 22 01

Steps to Reproduce

  1. terraform apply

References

@giefferre giefferre added the bug label Sep 16, 2021
@edwardmedia edwardmedia self-assigned this Sep 16, 2021
@edwardmedia
Copy link
Contributor

@giefferre have you checked out trigger_template to see if that helps?

@giefferre
Copy link
Author

@giefferre have you checked out trigger_template to see if that helps?

Hi @edwardmedia and thanks for the prompt reply.

Of course I had checked, but as the reference you linked says:

One of trigger_template, github, pubsub_config or webhook_config must be provided.

So it is NOT compatible as the webhook_config is present.

@edwardmedia
Copy link
Contributor

edwardmedia commented Sep 16, 2021

@giefferre can you try something like below?

resource "google_cloudbuild_trigger" "webhook-trigger" {
  webhook_config {
      secret = "projects/573164781234/secrets/webhook-secret/versions/1"
  }
  name = "tfbuild"
    build {
        step {
            name = "gcr.io/cloud-builders/gsutil"
            args = ["cp", "gs://mybucket/remotefile.zip", "localfile.zip"]
            timeout = "120s"
        }
        source {
            repo_source {
                repo_name = "https://github.com/edwardmedia/cbloud"
                branch_name = "master"
            }
        }
    }
}

@giefferre
Copy link
Author

giefferre commented Sep 17, 2021

@edwardmedia this would not be the same.

I specifically need the filename property as the Cloud Build steps are defined in such a file (located on the github repo).

If I also add the build block and keep the filename Terraform errors as

Either a filename or build template must be provided.

(source)

@edwardmedia
Copy link
Contributor

edwardmedia commented Sep 17, 2021

@giefferre I see. Currently this is not supported in the provider. source_to_build block needs to be added in the resource to support the request payload like below. Please file an enhancement to request the feature. Closing this issue accordingly

{
 "sourceToBuild": {
    "ref": "master",
    "uri": "https://github.com/edwardmedia/cbloud",
    "repoType":"GITHUB"
 },
 "filename": "cloudbuild.yaml",
 "name": "tfbuild2",
 "webhookConfig": {
  "secret": "projects/573164781234/secrets/webhook-secret/versions/1"
 }
}

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants