Skip to content

Instantly share code, notes, and snippets.

View sairamkrish's full-sized avatar

Sairam Krish sairamkrish

View GitHub Profile
@sairamkrish
sairamkrish / template_operator.py
Created May 18, 2020 16:03
Template operator for Airflow
from airflow.models.baseoperator import BaseOperator
from airflow.utils.decorators import apply_defaults
import re
class TemplateOperator(BaseOperator):
@apply_defaults
def __init__(
self,
template_file_path=None,
@sairamkrish
sairamkrish / lambda_function.py
Created May 2, 2020 18:21
AWS lambda function to start or stop EC2 based on SNS
import boto3
import json
region = 'us-west-2'
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
sns = event['Records'][0]['Sns']
print('Message :' + sns['Message'])
message = json.loads(sns['Message'])
@sairamkrish
sairamkrish / Jenkinsfile
Created May 2, 2020 18:02
Jenkins pipeline to publish AWS SNS message
import groovy.json.JsonOutput
def mapEnvironmentToAWS = [
"Team1": [
ec2InstanceIds: ['i-someEc2Id-1'],
],
"Team2": [
ec2InstanceIds: ['i-someEc2Id-2']
]
],
@sairamkrish
sairamkrish / main.js
Last active June 23, 2022 02:39
Vue JS integration with keycloak
import Keycloak from 'keycloak-js';
...
const keycloakConfig = {
"url": "/auth",
"realm": "your-realm-name",
"clientId": "vue_frontend",
"onLoad": "login-required"
};
const keycloak = Keycloak(keycloakConfig);
@sairamkrish
sairamkrish / docker-compose.yml
Created November 8, 2019 13:25
Docker compose with keycloak and nginx
version: "3.7"
networks:
mynetwork:
name: mynetwork
attachable: true
services:
postgres:
@sairamkrish
sairamkrish / nginx.conf
Last active November 8, 2019 13:42
Nginx configuration to work with Keycloak as Auth layer
server {
listen 80 default_server;
root /opt/nginx/html;
resolver 127.0.0.11 valid=1s ipv6=off;
access_by_lua '
local opts = {
redirect_uri_path = "/redirect_uri",
accept_none_alg = true,
discovery = "http://host.docker.internal:3333/auth/realms/myrealm/.well-known/openid-configuration",
client_id = "nginx",
@sairamkrish
sairamkrish / Dockerfile
Created November 7, 2019 09:30
Openresty based custom Docker
FROM openresty/openresty:alpine-fat
RUN mkdir /var/log/nginx
RUN apk add --no-cache openssl-dev
RUN apk add --no-cache git
RUN apk add --no-cache gcc
RUN luarocks install lua-resty-openidc
ENTRYPOINT ["/usr/local/openresty/nginx/sbin/nginx", "-g", "daemon off;"]
@sairamkrish
sairamkrish / ConvertPropertiesToCfn.java
Last active May 3, 2019 13:15
This class helps to convert a property file entries into cloudformation script to add them as SSM::Parameter
package java_experiments;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
/*
* This class helps to convert a property file entries into cloudformation script to add them as SSM::Parameter
version: "3"
services:
postgres:
image: postgres:11.2-alpine
environment:
POSTGRES_PASSWORD: '!abcd1234'
POSTGRES_USER: purplecow
POSTGRES_DB: purple_cow
volumes:
- ./postgres-data:/var/lib/postgresql/data
docker build -t myapp .