Skip to content
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module "cloud_run" {
| container\_concurrency | Concurrent request limits to the service | `number` | `null` | no |
| domain\_map\_annotations | Annotations to the domain map | `map(string)` | `{}` | no |
| domain\_map\_labels | A set of key/value label pairs to assign to the Domain mapping | `map(string)` | `{}` | no |
| build\_config | Optional Cloud Build configuration for building the container image from source instead of using a prebuilt image. Includes source location, base image, environment variables, and more. | `object({ source_location = optional(string), function_target = optional(string), image_uri = optional(string), base_image = optional(string), enable_automatic_updates = optional(bool), worker_pool = optional(string), environment_variables = optional(map(string)), service_account = optional(string) })` | `{}` | no |
| encryption\_key | CMEK encryption key self-link expected in the format projects/PROJECT/locations/LOCATION/keyRings/KEY-RING/cryptoKeys/CRYPTO-KEY. | `string` | `null` | no |
| env\_secret\_vars | [Beta] Environment variables (Secret Manager) | <pre>list(object({<br> name = string<br> value_from = set(object({<br> secret_key_ref = map(string)<br> }))<br> }))</pre> | `[]` | no |
| env\_vars | Environment variables (cleartext) | <pre>list(object({<br> value = string<br> name = string<br> }))</pre> | `[]` | no |
Expand Down Expand Up @@ -98,6 +99,8 @@ module "cloud_run" {
| service\_status | Status of the created service |
| service\_url | The URL on which the deployed service is available |
| verified\_domain\_name | List of Custom Domain Name |
| build\_name | The Cloud Build name of the latest successful deployment of the Service. |


<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Expand Down
14 changes: 14 additions & 0 deletions modules/v2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,20 @@ resource "google_cloud_run_v2_service" "main" {
}
} // template

dynamic "build_config" {
for_each = var.build_config != null ? [var.build_config] : []
content {
source_location = try(build_config.value.source_location, null)
function_target = try(build_config.value.function_target, null)
image_uri = try(build_config.value.image_uri, null)
base_image = try(build_config.value.base_image, null)
enable_automatic_updates = try(build_config.value.enable_automatic_updates, null)
worker_pool = try(build_config.value.worker_pool, null)
service_account = try(build_config.value.service_account, null)
environment_variables = try(build_config.value.environment_variables, null)
}
} //build_config

annotations = var.service_annotations
client = var.client.name
client_version = var.client.version
Expand Down
6 changes: 6 additions & 0 deletions modules/v2/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ output "apphub_service_uri" {
}
description = "Service URI in CAIS style to be used by Apphub."
}


output "build_name" {
description = "The Cloud Build name of the latest successful deployment of the Service."
value = try(google_cloud_run_v2_service.main.build_config[0].name, null)
}
14 changes: 14 additions & 0 deletions modules/v2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,17 @@ variable "execution_environment" {
}
}

variable "build_config" {
description = "Optional Cloud Build configuration for Cloud Run. This block enables building a container image from source using Cloud Build instead of specifying a prebuilt container image."
type = object({
source_location = optional(string)
function_target = optional(string)
image_uri = optional(string)
base_image = optional(string)
enable_automatic_updates = optional(bool)
worker_pool = optional(string)
environment_variables = optional(map(string))
service_account = optional(string)
})
default = null
}
Loading