Skip to content

Instantly share code, notes, and snippets.

View unbelauscht's full-sized avatar

unbelauscht unbelauscht

  • Germany
View GitHub Profile
@unbelauscht
unbelauscht / cleanaccount.py
Last active July 15, 2021 11:50
clean twitter account
#!/usr/bin/env python3
import time
import twitter
DELAY = 1
# Get your's here: https://developer.twitter.com/en/apps
api = twitter.Api(
consumer_key='',
@unbelauscht
unbelauscht / ovh-dc-monitoring.py
Last active May 11, 2020 19:54
Parser to print the OVH status visual monitoring status
#!/usr/bin/env python3
# Example output:
# ###############
#
# GRA1: LV1 -> G131B11:
# 1 server down 15min 0sec ago
# ERI1: LV1 -> E101D14:
# 1 server down 15min 0sec ago
# WAW1: LV1 -> W16A12:
@unbelauscht
unbelauscht / remote_cert_check.py
Last active January 20, 2021 15:16
icinga check for certificate expiration
#!/usr/bin/env python3
__author__ = "unbelauscht"
__license__ = "GPL"
__version__ = "0.0.1"
__maintainer__ = "unbelauscht"
__status__ = "Development"
from urllib.request import Request, urlopen, ssl, socket
from urllib.error import URLError, HTTPError
from datetime import datetime, timezone
@unbelauscht
unbelauscht / wait_for_deployment.sh
Last active July 15, 2021 11:48
Wait for ECS deployment
#!/bin/bash
count=0
while `aws ecs describe-services --cluster ${CLUSTER_NAME} --services ${SERVICE_NAME} --region ${AWS_REGION} | \
jq -r '.services[].deployments[] | .status' | grep ACTIVE 2>&1 > /dev/null`
do
if ! (( count % 3 )); then
echo "$count: Waiting for deployment task to finish";
fi
let "count=count+1"
@unbelauscht
unbelauscht / terraform_simple_iam_s3_policy.tf
Last active August 5, 2021 14:51
Simple allow all s3 access to specified bucket for IAM user terraform code
resource "aws_iam_user_policy" "bucket_access" {
name = "bucket_access"
user = aws_iam_user.bucket_user.name
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "terraform0",
@unbelauscht
unbelauscht / redirect.tf
Created August 5, 2021 14:54
Redirect URL on AWS LB
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule#path_pattern
resource "aws_lb_listener_rule" "redirect" {
listener_arn = aws_lb_listener.listener.arn
action {
type = "redirect"
redirect {
port = "443"
@unbelauscht
unbelauscht / roleAmazonSSMManagedInstanceCore.tf
Last active November 9, 2021 07:42
Terraform AmazonSSMManagedInstanceCore
resource "aws_iam_instance_profile" "ssm_role" {
name = "ssm_role"
role = aws_iam_role.ssm_role.name
}
resource "aws_iam_role" "ssm_role" {
name = "ssm-role"
assume_role_policy = jsonencode(
{
@unbelauscht
unbelauscht / hosts_aws_ec2.yml
Last active April 25, 2022 09:11
Run Ansible over AWS SSM
plugin: aws_ec2
regions:
- eu-central-1
# filter hosts based on name tag. This was used to provision prometheus instances
filters:
tag:Name: "prometheus.*"
# get nicer hostnames based on the ec2 instance tag
@unbelauscht
unbelauscht / hosts_aws_ec2.yml
Created January 14, 2022 11:19
Ansible aws_ec2 dynamic inventory over SSM
plugin: aws_ec2
regions:
- eu-central-1
# filter hosts based on name tag. This was used to provision prometheus instances
filters:
tag:Name: prometheus.*
# get nicer hostnames based on the ec2 instance tag
@unbelauscht
unbelauscht / website_listener_rule_oidc.tf
Created February 14, 2022 08:13
Terraform example for Google-based OIDC on an AWS Application Loadbalancer (ALB)
resource "aws_lb_listener_rule" "website" {
listener_arn = aws_lb_listener.https.arn
priority = 99
dynamic "action" {
for_each = var.website_enable_sso ? [1] : []
content {
type = "authenticate-oidc"
authenticate_oidc {