Skip to content

Instantly share code, notes, and snippets.

View Prajithp's full-sized avatar
🏠
Working from home

Prajith Prajithp

🏠
Working from home
View GitHub Profile
@Prajithp
Prajithp / schema.py
Last active June 24, 2021 14:32
terraform variables to json schema
#!/usr/bin/python3
import hcl2
import sys, os
import re
import json
import ast
from typing import Any, Dict, List, Optional, TypeVar, Union
@Prajithp
Prajithp / 100_base.conf
Created May 20, 2021 14:46 — forked from danackerson/100_base.conf
using nginx + lua + redis for redirects and rewrites
# using such a setup requires `apt-get install lua-nginx-redis` under Ubuntu Trusty
# more info @ http://wiki.nginx.org/HttpLuaModule#access_by_lua
http {
lua_package_path "/etc/nginx/include.d/?.lua;;";
lua_socket_pool_size 100;
lua_socket_connect_timeout 10ms;
lua_socket_read_timeout 10ms;
server {
@Prajithp
Prajithp / config.toml
Created May 15, 2021 15:15
gitlab-runner
concurrent = 3
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "awsbastian"
limit = 10
url = "https://gitlab.zzzz/"
@Prajithp
Prajithp / wigeguard_setup.md
Created April 19, 2021 11:56 — forked from atomlab/wigeguard_setup.md
Wireguard setup on Ubuntu 18.04

Wireguard setup on Ubuntu 16.04/18.04

Install

# sudo add-apt-repository ppa:wireguard/wireguard
# sudo apt-get update
# sudo apt-get install wireguard

Generate keys

kubectl get po --all-namespaces -o custom-columns=name:.metadata.name,status:.status.phase,image:'.spec.containers[0].image'
kubectl get po -o json --all-namespaces | jq '.items | group_by(.spec.nodeName) | map({"nodeName": .[0].spec.nodeName, "count": length}) | sort_by(.count)'
^(?:[a-zA-Z0-9]{1,4})[\/\-:](?:[a-zA-Z0-9]{1,4})[\/\-:](?:[a-zA-Z0-9]{1,4})(?:[T\s:]?)(?:\d{1,2}[:\-]\d{1,2}[:\-]\d{1,4})?(?:(?:[.,])\d+)?
# https://regex101.com/r/fPDuZy/3
@Prajithp
Prajithp / nginx.conf
Created July 8, 2020 11:21 — forked from shortjared/nginx.conf
AWS API Gateway Nginx Reverse Proxy
# NOTE
#
#
# Use sed on the instance up to replace the INSTANCE_ID and DNS_RESOLVER with the following commands
#
####################################################################################################
# Fetch the private IP for resolving DNS dynamically in nginx
# We also need to escape the `.` from it for usage in later sed
#
# DNS_RESOLVER=`grep nameserver /etc/resolv.conf | cut -d " " -f2 | sed 's/\./\\./g'`
@Prajithp
Prajithp / aws_rotate_keys.py
Created October 6, 2019 16:22 — forked from ruanbekker/aws_rotate_keys.py
Python Script to Rotate AWS Access Keys and Update them in their Credential Provider
#!/usr/local/bin/python
"""
Requires Boto3 and AWSCLI configured
- accepts argument of profile name that needs to be rotated
- updates config upon aws access key rotation
"""
import boto3
import argparse
@Prajithp
Prajithp / boto3_iam_access_key_rotation.py
Created October 6, 2019 16:22 — forked from andymotta/boto3_iam_access_key_rotation.py
Rotate AWS IAM access keys for every Boto profile on host (Compliance)
## Meant to be scheudled on a cron/timer of 90 days (CIS Benchmark)
## The target keys need permissions to rotate themselves
import boto3
from botocore.exceptions import ClientError
import os
from datetime import datetime
import shutil
from ConfigParser import SafeConfigParser
@Prajithp
Prajithp / clean_up.sh
Last active March 19, 2019 11:15
clean_up.sh
#!/bin/bash
_previous_day=$(date -d "1 day ago" '+%Y-%m-%d')
_common_logs_dir=("/var/log/" "/usr/share/nginx/logs" "/usr/share/tomcat/logs")
for log_dir in ${_common_logs_dir[@]}; do
if [[ -d ${log_dir} ]]; then
find ${log_dir} -type f -regex ".*\.gz$" -delete
find ${log_dir} -type f -iname "*${_previous_day}*" -delete
fi