@@ -1483,72 +1483,4 @@ resource "google_project_iam_member" "service_account_workflow_act_as_binding" {
14831483 project = var. project_id
14841484 role = " roles/iam.serviceAccountUser" # iam.serviceAccounts.actAs
14851485 member = " serviceAccount:${ google_service_account . functions_service_account . email } "
1486- }
1487-
1488- # 15. functions/refresh_materialized_view
1489- # Cloud Function for refresh_materialized_view
1490- resource "google_cloudfunctions2_function" "refresh_materialized_view" {
1491- name = " refresh-materialized-view"
1492- description = " Function to refresh materialized view asynchronously."
1493- location = var. gcp_region
1494- depends_on = [google_secret_manager_secret_iam_member . secret_iam_member ]
1495-
1496- build_config {
1497- runtime = var. python_runtime
1498- entry_point = " refresh_materialized_view_function"
1499- environment_variables = {
1500- FUNCTION_SIGNATURE_TYPE = " http"
1501- }
1502- source {
1503- storage_source {
1504- bucket = google_storage_bucket. functions_bucket . name
1505- object = google_storage_bucket_object. refresh_materialized_view_zip . name
1506- }
1507- }
1508- }
1509-
1510- service_config {
1511- environment_variables = {
1512- PROJECT_ID = var.project_id
1513- QUEUE_NAME = google_cloud_tasks_queue.refresh_materialized_view_queue.name
1514- LOCATION = var.gcp_region
1515- }
1516- available_memory = " 512Mi"
1517- timeout_seconds = 60
1518- available_cpu = 1
1519- max_instance_request_concurrency = 10
1520- max_instance_count = 5
1521- min_instance_count = 0
1522- service_account_email = google_service_account. functions_service_account . email
1523- ingress_settings = " ALLOW_ALL"
1524- vpc_connector = data. google_vpc_access_connector . vpc_connector . id
1525- vpc_connector_egress_settings = " PRIVATE_RANGES_ONLY"
1526- }
1527- }
1528-
1529- # IAM entry for invoking the refresh_materialized_view function
1530- resource "google_cloudfunctions2_function_iam_member" "refresh_materialized_view_invoker" {
1531- project = var. project_id
1532- location = var. gcp_region
1533- cloud_function = google_cloudfunctions2_function. refresh_materialized_view . name
1534- role = " roles/cloudfunctions.invoker"
1535- member = " serviceAccount:${ google_service_account . functions_service_account . email } "
1536- }
1537-
1538- # Task queue to invoke refresh_materialized_view function
1539- resource "google_cloud_tasks_queue" "refresh_materialized_view_queue" {
1540- name = " refresh-materialized-view-queue-${ var . environment } "
1541- location = var. gcp_region
1542-
1543- rate_limits {
1544- max_concurrent_dispatches = 10
1545- max_dispatches_per_second = 5
1546- }
1547-
1548- retry_config {
1549- max_attempts = 5
1550- min_backoff = " 10s"
1551- max_backoff = " 60s"
1552- max_doublings = 2
1553- }
15541486}
0 commit comments