Reputation: 39
I am a Terraform newbie but I have done a lot of research and cannot find an answer. I have no problem creating a Cloud Run instance using a simple Terraform file. I can set environmental variables and secrets with no problems. However, I cannot figure out how to create other settings such as "Memory allocated", "CPU allocated", etc.
My terraform file looks like:
resource "google_cloud_run_service" "myproject" {
project ="myproject"
name = "cloud-run-name"
location = "us-east1"
template {
spec {
containers {
image = "gcr.io/myproject/image"
env {
name = "VARIABLE1"
value = "variable1"
}
env {
name = "VARIABLE2"
value = "variable1"
}
}
}
}
traffic {
percent = 100
latest_revision = true
}
}
Upvotes: 2
Views: 3427
Reputation: 2211
Memory/CPU goes under template > spec > containers > resources. Timeout and concurrency under template > spec.
Here is an example:
template {
spec {
container_concurrency = var.concurrency
timeout_seconds = var.timeout
containers {
image = "gcr.io/myproject/image"
ports {
container_port = var.port
}
resources {
limits = {
cpu = "2m"
memory = "8000Mi"
}
}
}
}
}
Upvotes: 7