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: Implements Approval Config for apply Cloud Build Trigger for tf_cloudbuild_workspace #233

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 @@ -37,6 +37,7 @@ This module creates:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| apply\_approval\_required | Whether or not to require approval for the `apply` Cloud Build trigger. | `bool` | `false` | no |
| 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 |
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" {
}
}

dynamic "approval_config" {
# only enable approval for apply and only if apply_approval_required is true
for_each = each.key == "apply" ? [1] : []
content {
approval_required = var.apply_approval_required
}
}

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 @@ -31,6 +31,12 @@ variable "trigger_location" {
default = "global"
}

variable "apply_approval_required" {
description = "Whether or not to require approval for the `apply` Cloud Build trigger."
type = bool
default = false
}

variable "create_cloudbuild_sa" {
description = "Create a Service Account for use in Cloud Build. If false `cloudbuild_sa` has to be specified."
type = bool
Expand Down