-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGCF_update_xdr_info.tf
81 lines (63 loc) · 2.5 KB
/
GCF_update_xdr_info.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
variable "update_xdr_info_prefix" {}
variable "update_xdr_info_runtime" {}
variable "update_xdr_info_memory" {}
variable "update_xdr_info_entry_point" {}
variable "update_xdr_info_timeout" {}
variable "update_xdr_info_repo" {}
# ----------------------------------------------------------------------------------------------------------------------
# Create pubsub topic and subscription
resource "google_pubsub_topic" "update_xdr_info" {
name = "${var.global_prefix}${var.update_xdr_info_prefix}-topic"
}
# ----------------------------------------------------------------------------------------------------------------------
# Upload function to GCS and create Cloud Function
resource "google_storage_bucket_object" "update_xdr_info" {
name = "update_xdr_info.zip"
source = "functions/update_xdr_info.zip"
bucket = google_storage_bucket.main.id
}
resource "google_cloudfunctions_function" "update_xdr_info" {
name = "${var.global_prefix}${var.update_xdr_info_prefix}-function"
runtime = var.update_xdr_info_runtime
service_account_email = var.service_account_email
entry_point = var.update_xdr_info_entry_point
available_memory_mb = var.update_xdr_info_memory
timeout = var.update_xdr_info_timeout
ingress_settings = "ALLOW_ALL"
source_archive_bucket = google_storage_bucket.main.name
source_archive_object = google_storage_bucket_object.update_xdr_info.name
# source_repository {
# url = var.update_xdr_info_repo
# }
event_trigger {
event_type = "google.pubsub.topic.publish"
resource = google_pubsub_topic.update_xdr_info.id
}
environment_variables = {
PROJECT_ID = var.project_id,
XDR_KEY = var.xdr_key,
XDR_KEY_ID = var.xdr_key_id,
BASE_URL = var.xdr_base_url
}
labels = {
deployment-tool = "console-cloud"
}
}
# ----------------------------------------------------------------------------------------------------------------------
# Create Cloud Scheduler Job
variable "update_xdr_info_schedule" {}
resource "google_cloud_scheduler_job" "update_xdr_info" {
name = "${var.global_prefix}${var.update_xdr_info_prefix}-scheduler"
time_zone = var.scheduler_time_zone
schedule = var.update_xdr_info_schedule
pubsub_target {
data = base64encode("{}") # e30=
topic_name = google_pubsub_topic.update_xdr_info.id
}
retry_config {
max_backoff_duration = "3600s"
max_doublings = 5
max_retry_duration = "0s"
min_backoff_duration = "5s"
}
}