Skip to content

Commit

Permalink
fix: using 2nd gen cloud function
Browse files Browse the repository at this point in the history
  • Loading branch information
cka-y committed Aug 28, 2023
1 parent b74da26 commit abecd8d
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions infra/batch/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,45 @@ resource "google_storage_bucket" "bucket" {

resource "google_storage_bucket_object" "object" {
# Workaround to force source code update of cloud function when the zip file hash is updated
name = "datasets/${filesha256("datasets.zip")}.zip" # TODO this should be a variable
bucket = google_storage_bucket.bucket.name
source = "datasets.zip" # TODO this should be a variable
metadata = {
content_hash = filebase64sha256("datasets.zip") # TODO this should be a variable
name = "datasets/${filesha256("datasets.zip")}.zip" # TODO this should be a variable
bucket = google_storage_bucket.bucket.name
source = "datasets.zip" # TODO this should be a variable
metadata = {
content_hash = filebase64sha256("datasets.zip") # TODO this should be a variable
}
}

resource "google_cloudfunctions2_function" "function" {
name = "dataset-batch-function-v2" # TODO this should be a variable
description = "Python function"
name = "dataset-batch-function-v2" # TODO this should be a variable
description = "Python function"
location = "us-central1"
build_config {
runtime = "python310" # TODO this should be a variable
entry_point = "batch_dataset" # TODO this should be a variable
runtime = "python310" # TODO this should be a variable
entry_point = "batch_dataset" # TODO this should be a variable
source {
storage_source {
bucket = google_storage_bucket.bucket.name
object = google_storage_bucket_object.object.name
bucket = google_storage_bucket.bucket.name
object = google_storage_bucket_object.object.name
}
}
environment_variables = var.function_env_variables
}
service_config {
available_memory = "256M"
timeout_seconds = 3600
available_memory = "256M"
timeout_seconds = 3600
}
}

resource "google_cloud_scheduler_job" "job" {
name = "dataset-batch-job" # TODO this should be a variable
description = "Run python function daily" # TODO this should be a variable
schedule = "*/1 * * * *" # TODO this is once a day and should be a variable
time_zone = "Etc/UTC"
attempt_deadline = "320s"
name = "dataset-batch-job" # TODO this should be a variable
description = "Run python function daily" # TODO this should be a variable
schedule = "*/1 * * * *" # TODO this is once a day and should be a variable
time_zone = "Etc/UTC"
attempt_deadline = "320s"

http_target {
http_method = "GET"
uri = google_cloudfunctions2_function.function.service_config[0].uri
http_method = "GET"
uri = google_cloudfunctions2_function.function.service_config[0].uri
oidc_token {
service_account_email = var.deployer_service_account
}
Expand Down

0 comments on commit abecd8d

Please sign in to comment.