Skip to content

Instantly share code, notes, and snippets.

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

Arbab Nazar arbabnazar

🏠
Working from home
View GitHub Profile
@arbabnazar
arbabnazar / logstash-cloudwatch.yml
Created July 2, 2019 06:56 — forked from callum-p/logstash-cloudwatch.yml
Deploys lambda functions to forward cloudwatch logs to logstash
Description: Deploys lambda functions to forward cloudwatch logs to logstash
Parameters:
coreNetworkingStackName:
Type: String
Resources:
lambdaRole:
Type: "AWS::IAM::Role"
Properties:
@arbabnazar
arbabnazar / websocket-elb.md
Created April 23, 2019 20:23 — forked from zhiguangwang/websocket-elb.md
Configure websockets behind an AWS ELB.
@arbabnazar
arbabnazar / elb-nginx-websockets.md
Created April 23, 2019 20:22 — forked from Likeyn/elb-nginx-websockets.md
How-to websockets through ELB + Nginx reverse proxy

Websockets-through-ELB-to-Nginx-to-another-ELB recap

We need to setup an ELB with SSL termination in front of a Nginx reverse proxy to some already working ELB + project system. IOW: SSL-ELB -> Nginx reverse proxy -> ELB -> project. We'll assume the last ELB + project bit works properly.

Front ELB configuration

  • Configure the listeners to use TCP (80) instead of HTTP to allow the websockets (non-HTTP) to pass through. For HTTPS with SSL termination, simply use SSL (443) -> TCP (80)
@arbabnazar
arbabnazar / elb-nodejs-ws.md
Created April 23, 2019 20:20 — forked from obolton/elb-nodejs-ws.md
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@arbabnazar
arbabnazar / autoscaling_boto.py
Created December 2, 2018 16:04 — forked from numan/autoscaling_boto.py
Example of setting up AWS auto scaling using boto API
"""
The MIT License (MIT)
Copyright (c) 2011 Numan Sachwani
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
@arbabnazar
arbabnazar / MySQL_5-7_macOS.md
Created October 31, 2018 17:34 — forked from robhrt7/MySQL_5-7_macOS.md
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
@arbabnazar
arbabnazar / awc-ecs-access-to-aws-efs.md
Created August 8, 2018 17:55 — forked from duluca/awc-ecs-access-to-aws-efs.md
Step-by-step Instructions to Setup an AWS ECS Cluster

Configuring AWS ECS to have access to AWS EFS

If you would like to persist data from your ECS containers, i.e. hosting databases like MySQL or MongoDB with Docker, you need to ensure that you can mount the data directory of the database in the container to volume that's not going to dissappear when your container or worse yet, the EC2 instance that hosts your containers, is restarted or scaled up or down for any reason.

Don't know how to create your own AWS ECS Cluster? Go here!

New Cluster

Sadly the EC2 provisioning process doesn't allow you to configure EFS during the initial config. After your create your cluster, follow the guide below.

New Task Definition for Web App

If you're using an Alpine-based Node server like duluca/minimal-node-web-server follow this guide:

@arbabnazar
arbabnazar / .bash_aliases
Created July 20, 2018 08:58 — forked from vratiu/.bash_aliases
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@arbabnazar
arbabnazar / simple_args_parsing.sh
Created May 30, 2018 18:12 — forked from jehiah/simple_args_parsing.sh
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@arbabnazar
arbabnazar / get_subnet_route_map.py
Created October 23, 2017 18:47 — forked from halberom/get_subnet_route_map.py
ansible - a really nasty jinja filter to return a public subnet : route table mapping based on az
from jinja2.utils import soft_unicode
def get_subnet_route_map(value, routes, tag_key='Type', tag_value='public'):
# given a list of subnet results from the ec2_vpc_subnet task
# and a list of route results from the ec2_vpc_route_table task
# return a list of dicts of public subnet_id : route_id mapping
# where the public subnet is in the same az as the subnet the
# route is associated with
# assumes all private subnets in a routing table are in the same az!