From 380d48f35d26ea4e63693d8002226c94dff9c92c Mon Sep 17 00:00:00 2001 From: Renato Rudnicki <77694243+renato-rudnicki@users.noreply.github.com> Date: Wed, 20 Dec 2023 02:01:43 -0300 Subject: [PATCH] feat: add timeout variable for cloudbuild builder (#256) --- modules/tf_cloudbuild_builder/README.md | 1 + modules/tf_cloudbuild_builder/cb.tf | 1 + modules/tf_cloudbuild_builder/variables.tf | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/modules/tf_cloudbuild_builder/README.md b/modules/tf_cloudbuild_builder/README.md index a838f312..cfbfa09b 100644 --- a/modules/tf_cloudbuild_builder/README.md +++ b/modules/tf_cloudbuild_builder/README.md @@ -34,6 +34,7 @@ This module creates: | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | bucket\_name | Custom bucket name for Cloud Build logs. | `string` | `""` | no | +| build\_timeout | Amount of time the build should be allowed to run, to second granularity. Format is the number of seconds followed by s. | `string` | `"600s"` | no | | cb\_logs\_bucket\_force\_destroy | When deleting the bucket for storing CloudBuild logs, this boolean option will delete all contained objects. If false, Terraform will fail to delete buckets which contain objects. | `bool` | `false` | no | | cloudbuild\_sa | Custom SA email to be used by the CloudBuild trigger. Defaults to being created if empty. | `string` | `""` | no | | dockerfile\_repo\_dir | The directory inside the repo where the Dockerfile is located. If empty defaults to repo root. | `string` | `""` | no | diff --git a/modules/tf_cloudbuild_builder/cb.tf b/modules/tf_cloudbuild_builder/cb.tf index bd0b11e7..b7f86241 100644 --- a/modules/tf_cloudbuild_builder/cb.tf +++ b/modules/tf_cloudbuild_builder/cb.tf @@ -53,6 +53,7 @@ resource "google_cloudbuild_trigger" "build_trigger" { # todo(bharathkkb): switch to yaml after https://github.com/hashicorp/terraform-provider-google/issues/9818 build { + timeout = var.build_timeout step { name = "gcr.io/cloud-builders/docker" args = concat( diff --git a/modules/tf_cloudbuild_builder/variables.tf b/modules/tf_cloudbuild_builder/variables.tf index acac8d46..38870bf6 100644 --- a/modules/tf_cloudbuild_builder/variables.tf +++ b/modules/tf_cloudbuild_builder/variables.tf @@ -49,6 +49,12 @@ variable "cloudbuild_sa" { default = "" } +variable "build_timeout" { + description = "Amount of time the build should be allowed to run, to second granularity. Format is the number of seconds followed by s." + type = string + default = "600s" +} + variable "cb_logs_bucket_force_destroy" { description = "When deleting the bucket for storing CloudBuild logs, this boolean option will delete all contained objects. If false, Terraform will fail to delete buckets which contain objects." type = bool