20251224
This commit is contained in:
parent
1259ba76c9
commit
6454e1b46b
19 changed files with 667 additions and 611 deletions
|
|
@ -10,37 +10,22 @@ variable "region" {
|
|||
|
||||
variable "function_name" {
|
||||
type = string
|
||||
default = "mrt-create-log-sheet"
|
||||
default = "generate-minutes"
|
||||
}
|
||||
|
||||
|
||||
# Scheduler実行用サービスアカウント
|
||||
resource "google_service_account" "cf_scheduler_sa" {
|
||||
project = var.project_id
|
||||
account_id = "mrt-scheduler-sa"
|
||||
display_name = "Cloud Functions 起動用サービスアカウント"
|
||||
}
|
||||
|
||||
# 権限を SA に付与
|
||||
resource "google_project_iam_member" "scheduler_role" {
|
||||
for_each = toset(["roles/cloudfunctions.invoker","roles/run.invoker"])
|
||||
project = var.project_id
|
||||
role = each.value
|
||||
member = "serviceAccount:${google_service_account.cf_scheduler_sa.email}"
|
||||
}
|
||||
|
||||
|
||||
# 毎月1日0時に Function を実行する Scheduler ジョブ
|
||||
resource "google_cloud_scheduler_job" "monthly_cf_trigger" {
|
||||
# 毎日3時に Function を実行する Scheduler ジョブ
|
||||
resource "google_cloud_scheduler_job" "daily_cf_trigger" {
|
||||
project = var.project_id
|
||||
name = "monthly-cf-trigger"
|
||||
description = "Invoke Cloud Function on the 1st of each month at 00:00"
|
||||
name = "daily-cf-trigger"
|
||||
description = "Invoke Cloud Function everyday at 03:00"
|
||||
region = var.region
|
||||
schedule = "0 0 1 * *"
|
||||
schedule = "0 3 * * *"
|
||||
time_zone = "Asia/Tokyo"
|
||||
|
||||
http_target {
|
||||
uri = "https://${var.region}-${var.project_id}.cloudfunctions.net/${var.function_name}"
|
||||
uri = "https://${var.region}-${var.project_id}.cloudfunctions.net/${var.function_name}/api/dailyBatch"
|
||||
http_method = "POST"
|
||||
oidc_token {
|
||||
service_account_email = google_service_account.cf_scheduler_sa.email
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue