@@ -36,6 +36,9 @@ locals {
3636
3737 function_feed_sync_dispatcher_transitland_config = jsondecode (file (" ${ path . module } /../../functions-python/feed_sync_dispatcher_transitland/function_config.json" ))
3838 function_feed_sync_dispatcher_transitland_zip = " ${ path . module } /../../functions-python/feed_sync_dispatcher_transitland/.dist/feed_sync_dispatcher_transitland.zip"
39+
40+ function_operations_api_config = jsondecode (file (" ${ path . module } /../../functions-python/operations_api/function_config.json" ))
41+ function_operations_api_zip = " ${ path . module } /../../functions-python/operations_api/.dist/operations_api.zip"
3942}
4043
4144locals {
@@ -116,6 +119,13 @@ resource "google_storage_bucket_object" "feed_sync_dispatcher_transitland_zip" {
116119 source = local. function_feed_sync_dispatcher_transitland_zip
117120}
118121
122+ # 7. Operations API
123+ resource "google_storage_bucket_object" "operations_api_zip" {
124+ bucket = google_storage_bucket. functions_bucket . name
125+ name = " operations-api-${ substr (filebase64sha256 (local. function_operations_api_zip ), 0 , 10 )} .zip"
126+ source = local. function_operations_api_zip
127+ }
128+
119129# Secrets access
120130resource "google_secret_manager_secret_iam_member" "secret_iam_member" {
121131 for_each = local. unique_secret_keys
@@ -582,6 +592,49 @@ resource "google_cloudfunctions2_function" "feed_sync_dispatcher_transitland" {
582592 }
583593}
584594
595+ resource "google_cloudfunctions2_function" "operations_api" {
596+ name = " ${ local . function_operations_api_config . name } "
597+ description = local. function_operations_api_config . description
598+ location = var. gcp_region
599+ depends_on = [google_secret_manager_secret_iam_member . secret_iam_member ]
600+
601+ build_config {
602+ runtime = var. python_runtime
603+ entry_point = local. function_operations_api_config . entry_point
604+ source {
605+ storage_source {
606+ bucket = google_storage_bucket. functions_bucket . name
607+ object = google_storage_bucket_object. operations_api_zip . name
608+ }
609+ }
610+ }
611+ service_config {
612+ environment_variables = {
613+ PROJECT_ID = var.project_id
614+ PYTHONNODEBUGRANGES = 0
615+ GOOGLE_CLIENT_ID = var.authorization_google_client_id
616+ }
617+ available_memory = local. function_operations_api_config . available_memory
618+ timeout_seconds = local. function_operations_api_config . timeout
619+ available_cpu = local. function_operations_api_config . available_cpu
620+ max_instance_request_concurrency = local. function_operations_api_config . max_instance_request_concurrency
621+ max_instance_count = local. function_operations_api_config . max_instance_count
622+ min_instance_count = local. function_operations_api_config . min_instance_count
623+ service_account_email = google_service_account. functions_service_account . email
624+ ingress_settings = local. function_operations_api_config . ingress_settings
625+ vpc_connector = data. google_vpc_access_connector . vpc_connector . id
626+ vpc_connector_egress_settings = " PRIVATE_RANGES_ONLY"
627+ dynamic "secret_environment_variables" {
628+ for_each = local. function_operations_api_config . secret_environment_variables
629+ content {
630+ key = secret_environment_variables. value [" key" ]
631+ project_id = var. project_id
632+ secret = " ${ upper (var. environment )} _${ secret_environment_variables . value [" key" ]} "
633+ version = " latest"
634+ }
635+ }
636+ }
637+ }
585638
586639# IAM entry for all users to invoke the function
587640resource "google_cloudfunctions2_function_iam_member" "tokens_invoker" {
0 commit comments