Skip to content

Instantly share code, notes, and snippets.

View matiasba's full-sized avatar

matiasba

  • Argentina
View GitHub Profile
@matiasba
matiasba / cloudflare-ddns.sh
Created June 8, 2022 19:00
Bash script for DDNS using cloudflare DNS service, with options for enabling https proxy
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service from anywhere
# DNS redord needs to be pre-created on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@matiasba
matiasba / zabbix_aws_asg_deregister.py
Last active December 6, 2022 15:42
This lambda function allows to deregister a host based on a "EC2 Instance Terminate Successful" event on AWS. It requires an EventBridge with the following configuration as trigger Event pattern: { "source": [ "aws.autoscaling" ], "detail-type": [ "EC2 Instance Terminate Successful" ] }
import json
import urllib3
from datetime import date
def lambda_handler(event, context):
today = date.today().strftime("%Y-%m-%d")
# Parse the EC2 instance ID from the event data
instance_id = event['detail']['EC2InstanceId']
# create urllib3 pool to make HTTP requests