You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "olehborysevych (via GitHub)" <gi...@apache.org> on 2023/04/11 16:32:40 UTC

[GitHub] [beam] olehborysevych commented on a diff in pull request #25793: Automation: Tour of Beam infrastructure deployment

olehborysevych commented on code in PR #25793:
URL: https://github.com/apache/beam/pull/25793#discussion_r1163071505


##########
learning/tour-of-beam/terraform/cloud_functions/main.tf:
##########
@@ -0,0 +1,59 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+resource "google_cloudfunctions_function" "cloud_function" {
+  count                 = length(var.entry_point_names)
+  name                  = "${var.environment}_${var.entry_point_names[count.index]}"
+  runtime               = "go116"
+  available_memory_mb   = 128
+  project               = var.project_id
+  service_account_email = var.service_account_id
+  source_archive_bucket = var.source_archive_bucket
+  source_archive_object = var.source_archive_object
+  region                = var.region
+  ingress_settings      = "ALLOW_ALL"
+  # Get the source code of the cloud function as a Zip compression
+  trigger_http = true
+  # Name of the function that will be executed when the Google Cloud Function is triggered
+  entry_point = var.entry_point_names[count.index]
+
+  environment_variables = {
+    DATASTORE_PROJECT_ID=var.project_id
+    GOOGLE_PROJECT_ID=var.project_id
+    PLAYGROUND_ROUTER_HOST=var.pg_router_host
+  }
+
+  timeouts {
+    create = "20m"
+    delete = "20m"
+  }
+
+}

Review Comment:
   Thank you @damondouglas for your comments. It gave us a chance to reflect on decisions we made when working on ToB backend in the early stages of project.
   While Ruslan works on addressing your other comments, I would like to answer those related to cloud functions. 
   We never thought of our set of backend functions as a REST-like api. Also the Cloud Function framework neither requires nor encourages to implement REST API's. 
   GCF HTTP triggers do not have notion of HTTP methods validation so we will need to add routing for different methods inside function code that kind of breaks the idea that 
   one cloud function should perform a simple single task and will also complicate testing and affect the posibility of separate deployment of cloud functions.
   There is way to benefit from introducing OpenAPI specs into ToB project. We can use managed Cloud Endpoint or API Gateway services generated from OpenApi specification that will route our requests to backend cloud functions.
   We can also use this spec to generate flutter clients for frontend. Unfortunatelly This wasn't foreseen in planning and design stage. I created a backlog item for this change, but it will require discussion and planning and will not be resolved in 
   scope of this PR. https://github.com/apache/beam/issues/26221



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org