diff --git a/README.md b/README.md index 35184a2d7e1a6531d8b840c101e43b68091c64a8..ce61e550e01fb8e5f70976a333d71ff31d7a43c3 100644 --- a/README.md +++ b/README.md @@ -181,5 +181,4 @@ module "webapp" { Originally, the module did not deploy images except on the very first use (using `gcr.io/cloudrun/hello:latest`). -Currently, the module deploys the image from `image_name` if specified, otherwise keep the -current image, if that doesn't exist fall-back to the "hello" image. +Currently, the module deploys the image from the mandatory variable `image_name`. diff --git a/locals.tf b/locals.tf index 07c2f120a4d1717eed2897d20cef31429482bca7..ce0b188ba911aa7a69fb843aec59e06d4b73be2b 100644 --- a/locals.tf +++ b/locals.tf @@ -51,11 +51,4 @@ locals { [trimsuffix(trimprefix(google_cloud_run_service.webapp.status[0].url, "https://"), "/")], var.allow_unauthenticated_invocations ? local.dns_names : [], ) - - # If a cloud run revision is present, get the full URL of the deployed image. - existing_image_name = ( - data.google_cloud_run_service.webapp.template != null ? - data.google_cloud_run_service.webapp.template[0].spec[0].containers[0].image : - "" - ) } diff --git a/main.tf b/main.tf index 99ff371ac769354996248d40e1017d389aca831c..1a0923c04bbeda74e5493df4e3c5ed67e4aa8306 100644 --- a/main.tf +++ b/main.tf @@ -111,11 +111,7 @@ resource "google_cloud_run_service" "webapp" { service_account_name = google_service_account.webapp.email containers { - image = coalesce( - var.image_name, - local.existing_image_name, - "gcr.io/cloudrun/hello:latest", - ) + image = var.image_name resources { limits = { diff --git a/variables.tf b/variables.tf index 27b9a281ee243f5a56c28a6239c76fabc701d109..8940782fbc3998ea048eb92005be20470e9367a4 100644 --- a/variables.tf +++ b/variables.tf @@ -306,9 +306,9 @@ EOL variable "image_name" { type = string - default = "" - description = <<-EOL - Optional. The docker image that will be deployed. If unset, the value of - existing_image_name is preferred. -EOL + description = "The URL of the container image to be deployed." + validation { + condition = length(var.image_name) > 0 + error_message = "The image_name value must be a valid URL to a container image." + } }