Skip to content

Instantly share code, notes, and snippets.

View my-janala's full-sized avatar

Mezbaur Rahman my-janala

View GitHub Profile
@my-janala
my-janala / lambda_ec2_start
Created November 17, 2016 10:14
creating a simple lambda function to start ec2 instances
import boto3
# Enter the region your instances are in, e.g. 'us-east-1'
region = 'eu-west-1'
# Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX']
instances = ['i-21d32eac', 'i-08a54cc8']
@my-janala
my-janala / amzn-linux-os-type.txt
Created October 17, 2016 09:28
To find out OS tyepf for Amazon Linux, use file /etc/os-release
# cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2015.09"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2015.09"
PRETTY_NAME="Amazon Linux AMI 2015.09"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2015.09:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
@my-janala
my-janala / sqs-read-only-policy.json
Created October 13, 2016 12:29
Creating SQS readonly policy for IAM user
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1470826626000",
"Effect": "Allow",
"Action": [
"sqs:ListQueues",
"sqs:GetQueueAttributes",
"sqs:ReceiveMessage"
@my-janala
my-janala / service-webserver.yml
Created October 13, 2016 10:50
playbook for provision webserver.
---
- hosts: "tag_role_webserver:&tag_env_{{env}}"
become: true
vars_files:
- "../vars/env_{{env}}.yml"
- "../vars/secure_{{env}}.yml"
- "../vars/env_{{env}}_splunk.yml"
vars:
ansible_role: "webserver"
datadog_api_key: "<key>"
$ vim ~/.bashrc
## Ansible
export AWS_ACCESS_KEY_ID='AWS_ACCESS_KEY_ID'
export AWS_SECRET_ACCESS_KEY='AWS_SECRET_ACCESS_KEY'
export ANSIBLE_HOSTS=/<dir>/ec2.py
export EC2_INI_PATH=/<dir>/ec2.ini
export ANSIBLE_CONFIG=/<dir>/ansible.cfg
export ANSIBLE_SSH_CONTROL_PATH='~/.ssh/%%h-%%r'
@my-janala
my-janala / pm2 startup script
Last active October 13, 2016 09:02
Creating auto-startup script using pm2.
$ pm2 startup ubuntu
[PM2] You have to run this command as root. Execute the following command:
sudo su -c "env PATH=$PATH:/opt/node-v4.3.1-linux-x64/bin pm2 startup ubuntu -u jenkins --hp /home/jenkins"
Now run the command as root as it says here http://pm2.keymetrics.io/docs/usage/startup/.
Then run
$ pm2 save
$ vim ~/.ssh/config
###
Host *.sunrise-dev.local
user mezbaur
ProxyCommand ssh -q -A mezbaur@cd_bstn nc %h %p
IdentityFile ~/.ssh/mezbaur
LogLevel QUIET
StrictHostKeyChecking no
@my-janala
my-janala / sqs_example.py
Created September 21, 2016 21:17 — forked from maracuja/sqs_example.py
SQS Playing
# http://boto.readthedocs.org/en/latest/sqs_tut.html
# my aws settings
AWS_ACCESS_KEY_ID=''
AWS_SECRET_ACCESS_KEY=''
# creating my example queue
import boto.sqs
conn = boto.sqs.connect_to_region("eu-west-1", aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
q = conn.create_queue('david-test')
@my-janala
my-janala / 0_reuse_code.js
Created September 21, 2016 21:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console