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 with count fails #4618

Open
jackivanov opened this issue Oct 4, 2019 · 2 comments
Open

google_cloudbuild_trigger with count fails #4618

jackivanov opened this issue Oct 4, 2019 · 2 comments

Comments

@jackivanov
Copy link

jackivanov commented Oct 4, 2019

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 v0.12.6
+ provider.google v2.16.0
+ provider.null v2.1.2
+ provider.random v2.2.0

Affected Resource(s)

  • google_cloudbuild_trigger

Terraform Configuration Files

resource "google_cloudbuild_trigger" "devops" {
  count    = 5
  project  = google_project.main.id
  filename = "test.yaml"

  trigger_template {
    project_id  = google_project.main.id
    repo_name   = google_sourcerepo_repository.main[count.index].name
    branch_name = "master"
  }
}

Debug Output

Panic Output

Expected Behavior

Terraform creates 5 cloud build triggers

Actual Behavior

Terraform fails to create build triggers.

Error: Error creating Trigger: googleapi: Error 409: trigger (158XXX61352, trigger) already exists

  on modules/env/devops-cloudbuild.tf line 1, in resource "google_cloudbuild_trigger" "devops":
   1: resource "google_cloudbuild_trigger" "devops" {



Error: Error creating Trigger: googleapi: Error 409: trigger (158XXX61352, trigger) already exists

  on modules/env/devops-cloudbuild.tf line 1, in resource "google_cloudbuild_trigger" "devops":
   1: resource "google_cloudbuild_trigger" "devops" {



Error: Error creating Trigger: googleapi: Error 409: trigger (158XXX61352, trigger) already exists

  on modules/env/devops-cloudbuild.tf line 1, in resource "google_cloudbuild_trigger" "devops":
   1: resource "google_cloudbuild_trigger" "devops" {



Error: Error creating Trigger: googleapi: Error 409: trigger (158XXX61352, trigger) already exists

  on modules/env/devops-cloudbuild.tf line 1, in resource "google_cloudbuild_trigger" "devops":
   1: resource "google_cloudbuild_trigger" "devops" {

Steps to Reproduce

  1. terraform apply

Important Factoids

References

This is more likely a race condition in google, but we would have to create a workaround. hashicorp/terraform#14258 may help to solve the issue

b/270752232

@ghost ghost added the bug label Oct 4, 2019
@nat-henderson
Copy link
Contributor

It looks like you can't create more than one build trigger at a time. That would be an upstream bug, but we could work on a workaround, maybe using the locking mechanisms we have already.

@prabenzom
Copy link

This should be working now.. you just need to add something like

name = "devops-trigger-${count.index}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants