Skip to content

Instantly share code, notes, and snippets.

@Titasmonk
Titasmonk / gist:bfc6bc66fb67071b4e324db2f35d2166
Last active October 23, 2019 06:29
ToObservableCollection
# New gist
# New line
# another line
@Titasmonk
Titasmonk / zabbix_api_connect.py
Created June 30, 2020 07:35
connect to zabbix api not depending on if you have pyzabbix or py-zabbix installed
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)
@Titasmonk
Titasmonk / iam.tf
Last active August 18, 2022 12:57
GCP-Cloud-SQL-Instance-Backup-to-Bucket
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"
}
@Titasmonk
Titasmonk / schedule.tf
Created August 9, 2022 09:18
GCP-Cloud-SQL-Instance-Backup-to-Bucket
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
}
@Titasmonk
Titasmonk / storage.tf
Last active August 18, 2022 12:56
GCP-Cloud-SQL-Instance-Backup-to-Bucket
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"
@Titasmonk
Titasmonk / terraform.tfvars
Created August 9, 2022 09:21
GCP-Cloud-SQL-Instance-Backup-to-Bucket
project_id = "PROJECT_ID"
region = "europe-west3"
@Titasmonk
Titasmonk / variables.tf
Created August 9, 2022 09:21
GCP-Cloud-SQL-Instance-Backup-to-Bucket
variable "project_id" {
type = string
description = "Project ID of GCP organization"
}
variable "region" {
type = string
description = "Region of GCP organization"
}
@Titasmonk
Titasmonk / workflows.tf
Last active August 12, 2022 11:21
GCP-Cloud-SQL-Instance-Backup-to-Bucket
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
#