mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 15:54:03 +00:00
feat(WHE-28): add terraform baseline for cloud run and scheduler
This commit is contained in:
67
infra/terraform/modules/cloud_run_service/main.tf
Normal file
67
infra/terraform/modules/cloud_run_service/main.tf
Normal file
@@ -0,0 +1,67 @@
|
||||
resource "google_cloud_run_v2_service" "this" {
|
||||
project = var.project_id
|
||||
location = var.region
|
||||
name = var.name
|
||||
|
||||
ingress = "INGRESS_TRAFFIC_ALL"
|
||||
deletion_protection = false
|
||||
|
||||
labels = var.labels
|
||||
|
||||
template {
|
||||
service_account = var.service_account_email
|
||||
|
||||
scaling {
|
||||
min_instance_count = var.min_instance_count
|
||||
max_instance_count = var.max_instance_count
|
||||
}
|
||||
|
||||
containers {
|
||||
image = var.image
|
||||
|
||||
ports {
|
||||
container_port = var.container_port
|
||||
}
|
||||
|
||||
resources {
|
||||
limits = var.limits
|
||||
}
|
||||
|
||||
dynamic "env" {
|
||||
for_each = var.env
|
||||
content {
|
||||
name = env.key
|
||||
value = env.value
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "env" {
|
||||
for_each = var.secret_env
|
||||
content {
|
||||
name = env.key
|
||||
value_source {
|
||||
secret_key_ref {
|
||||
secret = env.value
|
||||
version = "latest"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
traffic {
|
||||
percent = 100
|
||||
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_cloud_run_v2_service_iam_member" "public_invoker" {
|
||||
count = var.allow_unauthenticated ? 1 : 0
|
||||
|
||||
project = var.project_id
|
||||
location = var.region
|
||||
name = google_cloud_run_v2_service.this.name
|
||||
role = "roles/run.invoker"
|
||||
member = "allUsers"
|
||||
}
|
||||
Reference in New Issue
Block a user