❯ terraform -v
Terraform v0.12.15
+ provider.google v2.20.0
+ provider.google-beta v3.0.0-beta.1
I imported this cloudbuild trigger and wrote the following TF file:
resource "google_cloudbuild_trigger" "collect" {
provider = google-beta.project-name
description = "Push to any branch"
filename = "cloudbuild.yaml"
trigger_template {
branch_name = ".*"
}
github {
owner = "organization_name"
name = "collect"
push {
branch = ".*"
}
}
}
Terraform Plan output:
❯ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
google_cloudbuild_trigger.collect: Refreshing state... [id=projects/project-name/triggers/b577ea05-46e9-48ba-9fde-24fa619c8eb1]
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# google_cloudbuild_trigger.collect will be updated in-place
~ resource "google_cloudbuild_trigger" "collect" {
create_time = "2019-11-15T19:51:57.261701992Z"
description = "Push to any branch"
disabled = false
filename = "cloudbuild.yaml"
id = "projects/project-name/triggers/b577ea05-46e9-48ba-9fde-24fa619c8eb1"
ignored_files = []
included_files = []
name = "collect"
project = "project-name"
substitutions = {}
trigger_id = "b577ea05-46e9-48ba-9fde-24fa619c8eb1"
github {
name = "collect"
owner = "organization_name"
push {
branch = ".*"
}
}
timeouts {}
+ trigger_template {
+ branch_name = ".*"
+ repo_name = "default"
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
I removed the trigger_template from the configuration as the trigger is working as expected.
Config file:
resource "google_cloudbuild_trigger" "collect" {
provider = google-beta.project-name
description = "Push to any branch"
filename = "cloudbuild.yaml"
github {
owner = "organization_name"
name = "collect"
push {
branch = ".*"
}
}
}
Terraform plan output:
❯ terraform plan
Acquiring state lock. This may take a few moments...
Error: "trigger_template": required field is not set
on cloudbuild_trigger.tf line 1, in resource "google_cloudbuild_trigger" "collect":
1: resource "google_cloudbuild_trigger" "collect" {
Terraform should want to make no changes.
Terraform errors because trigger_template is a required field, even though the imported trigger does not include this field.
terraform plan@ndmckinley Seems like a regression as you know trigger_template and github are mutually exclusive as per https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.triggers and this was the behaviour in previous versions of the google-beta provider
Assigning to @ndmckinley who made this change
Yeah, the confusion here is that it is required in GA, but one-or-the-other of trigger_template or github is allowed in beta. I'll get this fixed.
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!
Most helpful comment
Yeah, the confusion here is that it is required in GA, but one-or-the-other of trigger_template or github is allowed in beta. I'll get this fixed.