This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_workflows_workflow" "cloud_sql_export_workflow" { | |
name = "cloud_sql_export_workflow" | |
region = "europe-west3" | |
description = "Create a cloud sql export" | |
service_account = google_service_account.cloud_sql_export_workflow_sva.id | |
source_contents = <<-EOF | |
# | |
# Exports all specified projects GCP CloudSQL instances data to GCP Storage Bucket | |
# Titas Monkevicius | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "project_id" { | |
type = string | |
description = "Project ID of GCP organization" | |
} | |
variable "region" { | |
type = string | |
description = "Region of GCP organization" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project_id = "PROJECT_ID" | |
region = "europe-west3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_storage_bucket" "cloud_sql_export_bucket" { | |
location = var.region | |
requester_pays = false | |
name = "${var.project_id}-cloud_sql_export_bucket" | |
project = var.project_id | |
storage_class = "NEARLINE" | |
lifecycle_rule { | |
action { | |
type = "Delete" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_cloud_scheduler_job" "cloud_sql_export_job" { | |
name = "cloud_sql_export_job" | |
description = "Cloud SQL scheduler invoker" | |
schedule = "0 12 * * 7" | |
time_zone = "<Timezone>" | |
attempt_deadline = "500s" | |
retry_config { | |
retry_count = 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_service_account" "cloud_sql_export_workflow_sva" { | |
account_id = "cloud-sql-export-workflow-sva" | |
display_name = "Cloud SQL Workflows Service Account" | |
} | |
resource "google_service_account" "cloud_sql_export_scheduler_sva" { | |
account_id = "cloud-sql-export-scheduler-sva" | |
display_name = "Cloud SQL scheduler Service Account" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_zabbix_connection(zbx_url, zbx_user, zbx_password): | |
""" | |
Sometimes pyzabbix and py-zabbix library can replace each other. | |
This is a wrapper, we don't care about what pip-module we install. | |
Return ZabbixAPI object | |
""" | |
# pyzabbix library, with user\password in login method. It's GOOD library | |
logging.debug("Try connect to Zabbix by pyzabbix...") | |
try: | |
zbx_pyzabbix = ZabbixAPI(zbx_url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# New gist | |
# New line | |
# another line |