Skip to content

Instantly share code, notes, and snippets.

@tomlarkworthy
Created April 9, 2020 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomlarkworthy/c5fd6a5d5ced2e497d799a4f42124958 to your computer and use it in GitHub Desktop.
Save tomlarkworthy/c5fd6a5d5ced2e497d799a4f42124958 to your computer and use it in GitHub Desktop.
# Cloud Run Camunda service
resource "google_cloud_run_service" "camunda" {
name = "camunda"
location = local.config.region
template {
spec {
# Use locked down Service Account
service_account_name = google_service_account.camunda.email
containers {
image = null_resource.camunda_cloudsql_image.triggers.image
resources {
limits = {
# Default of 256Mb is not enough to start Camunda
memory = "2Gi"
}
}
env {
name = "DB_URL"
# Complicated DB URL to Cloud SQL
# See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory
value = "jdbc:postgresql:///${google_sql_database.database.name}?cloudSqlInstance=${google_sql_database_instance.camunda-db.connection_name}&socketFactory=com.google.cloud.sql.postgres.SocketFactory"
}
env {
name = "DB_DRIVER"
value = "org.postgresql.Driver"
}
env {
name = "DB_USERNAME"
value = google_sql_user.user.name
}
env {
name = "DB_PASSWORD"
value = google_sql_user.user.password
}
# Test instance of Cloud SQL has low connection limit
# So we turn down the connection pool size
env {
name = "DB_CONN_MAXACTIVE"
value = "5"
}
env {
name = "DB_CONN_MAXIDLE"
value = "5"
}
env {
name = "DB_CONN_MINIDLE"
value = "0"
}
}
}
metadata {
annotations = {
"autoscaling.knative.dev/maxScale" = "1" # no clusting
"run.googleapis.com/cloudsql-instances" = google_sql_database_instance.camunda-db.connection_name
}
}
}
traffic {
percent = 100
latest_revision = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment