Open yerb-loreal opened 1 year ago
As far as I know, event with the latest version of the provider (5.2.0 today, beta or not), google_cloudbuild_trigger can't be used to create a real manual invocation trigger because
@yerb-loreal was this newly impossible in 5.2.0
due to a new validation or other change or has this been the case in prior versions as well?
It's been the case in v4 too.
I haven't had a go reproducing this, but from the error mentioned above:
one of bitbucket_server_trigger_config,github,pubsub_config,repository_event_config,source_to_build,trigger_template,webhook_config must be specified`
it sounds like the AtLeastOneOf
provider-side validation misses a use cases/combinations of fields when using manual approval via approval_config and needs to be updated, i.e is a bug.
I encounter the same issue.
After manually creating a manuel Cloud Build trigger, I've imported it.
When I write the same TF code from the state, I have these errors :
╷
│ Error: Missing required argument
│
│ with google_cloudbuild_trigger.main,
│ on trigger.tf line 1, in resource "google_cloudbuild_trigger" "main":
│ 1: resource "google_cloudbuild_trigger" "main" {
│
│ "pubsub_config": one of `bitbucket_server_trigger_config,github,pubsub_config,repository_event_config,source_to_build,trigger_template,webhook_config` must be specified
╵
When I add the following block (for example) :
webhook_config {
secret = var.secret
}
the plan is "successful" :
# google_cloudbuild_trigger.main will be updated in-place
~ resource "google_cloudbuild_trigger" "main" {
id = "projects/xxxxxxxxx/locations/yyyyyyyyy/triggers/zzzzzzzzzzzzzzzzzzzzzzzz"
name = "mongo-ha-restore"
tags = []
# (8 unchanged attributes hidden)
~ build {
tags = []
+ timeout = "600s"
# (2 unchanged attributes hidden)
# (4 unchanged blocks hidden)
}
- timeouts {}
+ webhook_config {
+ secret = "toto"
}
# (1 unchanged block hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Hi,
I've found a little trick.
Based on what the error message says, we need, at least, one of these elements :
bitbucket_server_trigger_config
github
pubsub_config
repository_event_config
source_to_build
trigger_template
webhook_config
After differents tries, I've used the repository_event_config
coupled with the correct lifecycle
association.
So, simply adding this block does the trick :
...
repository_event_config {}
lifecycle {
ignore_changes = [
repository_event_config
]
}
...
Hi,
I've found a little trick.
Based on what the error message says, we need, at least, one of these elements :
bitbucket_server_trigger_config github pubsub_config repository_event_config source_to_build trigger_template webhook_config
After differents tries, I've used the
repository_event_config
coupled with the correctlifecycle
association.So, simply adding this block does the trick :
... repository_event_config {} lifecycle { ignore_changes = [ repository_event_config ] } ...
it works, thanks
it also works with:
webhook_config {
secret = ""
}
lifecycle {
ignore_changes = [ webhook_config ]
}
Community Note
Description
Hi,
The context
Our project uses two types of triggers:
We use distinct GCP project for environments (dev, integration, production). Docker images are generated by a single project and this one has "build" triggers (and "deploy" triggers). Other projects have only "deploy" triggers (and constraints over images that can be deployed) but no "build" triggers. So it makes no sense for these projects to declare Git repositories as all they need is an access to an artifact registry repository. However...
The problem
As far as I know, event with the latest version of the provider (5.2.0 today, beta or not),
google_cloudbuild_trigger
can't be used to create a real manual invocation trigger becauseHere is a screenshot of what I'd like to obtain.
Here are trigger definitions obtained with
gcloud builds triggers list
.What I can create with GCP Console (useless but kept simple):
What I can create with
google_cloudbuild_trigger
usingtrigger_template
using
source_to_build
So, the current workaround is to define "deploy" triggers with
trigger_template
orsource_to_build
but it requires to declare a source repository in every project, even if it's not used.New or Affected Resource(s)
Potential Terraform Configuration
References
b/307910874