I am trying to create a google_cloud_run_service through Terraform for an image hosted in Artifact repository. While I am planning to use Terraform for the initial creation, then I am planning to use the cloudbuild.yaml file in the app repo for future builds. I am using the following yaml code in my Terraform file:
resource "google_cloud_run_service" "default" {
name = "default-srv"
location = "us-west2"
metadata {
namespace = var.projectId
annotations = {
"run.googleapis.com/client-name" = "terraform"
}
}
template {
spec {
containers {
image = "us-west2-docker.pkg.dev/projectId/default/default"
}
}
}
}
This is failing since the service cannot find the image without a tag and I am not sure how to get the newest image from Artifact Repository. I guess I can use the “latest” tag on the image but then I need to keep tag each auto build with latest too is that correct?
Any help/guidance would be appreciated on best practices regarding this.