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

feat: add support for approval_config only for the "xxx-apply" trigger #216

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/tf_cloudbuild_workspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This module creates:
| artifacts\_bucket\_name | Custom bucket name for Cloud Build artifacts. | `string` | `""` | no |
| buckets\_force\_destroy | When deleting the bucket for storing CloudBuild logs/TF state, this boolean option will delete all contained objects. If false, Terraform will fail to delete buckets which contain objects. | `bool` | `false` | no |
| cloudbuild\_apply\_filename | Optional Cloud Build YAML definition used for terraform apply. Defaults to using inline definition. | `string` | `null` | no |
| cloudbuild\_apply\_manual\_approval | This is only for the 'xxx-apply' trigger. If this is set on a build, it will become pending when it is run, and will need to be explicitly approved to start. | `bool` | `false` | no |
| cloudbuild\_env\_vars | Optional list of environment variables to be used in builds. List of strings of form KEY=VALUE expected. | `list(string)` | `[]` | no |
| cloudbuild\_ignored\_files | Optional list. Changes only affecting ignored files will not invoke a build. | `list(string)` | `[]` | no |
| cloudbuild\_included\_files | Optional list. Changes affecting at least one of these files will invoke a build. | `list(string)` | `[]` | no |
Expand Down
8 changes: 8 additions & 0 deletions modules/tf_cloudbuild_workspace/cb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ resource "google_cloudbuild_trigger" "triggers" {
}
}

# approval_config
dynamic "approval_config" {
for_each = each.key == "apply" && var.cloudbuild_apply_manual_approval ? [1] : []
content {
approval_required = var.cloudbuild_apply_manual_approval
}
}

substitutions = merge(local.default_subst, var.substitutions)
service_account = local.cloudbuild_sa
filename = local.default_triggers_explicit[each.key]
Expand Down
6 changes: 6 additions & 0 deletions modules/tf_cloudbuild_workspace/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ variable "cloudbuild_ignored_files" {
default = []
}

variable "cloudbuild_apply_manual_approval" {
description = "This is only for the 'xxx-apply' trigger. If this is set on a build, it will become pending when it is run, and will need to be explicitly approved to start."
type = bool
default = false
}

variable "buckets_force_destroy" {
description = "When deleting the bucket for storing CloudBuild logs/TF state, this boolean option will delete all contained objects. If false, Terraform will fail to delete buckets which contain objects."
type = bool
Expand Down