Skip to content

Instantly share code, notes, and snippets.

View burdandrei's full-sized avatar
👻

Andrei Burd burdandrei

👻
View GitHub Profile
@burdandrei
burdandrei / lambda_scale_ecs_service.js
Created January 20, 2016 10:40
Template for Lambda ECS scale
console.log('Loading event');
var aws = require('aws-sdk');
exports.handler = function(event, context) {
var ecsService = 'sample-webapp';
var ecsCluster = 'sample-cluster';
var ecsRegion = 'us-west-2';
var maxCount = 2;
var ecs = new aws.ECS({region: ecsRegion});
@burdandrei
burdandrei / nameservers.rb
Created January 25, 2016 17:16
Ohai dns(nameserves) Plugin
require 'json'
Ohai.plugin(:Nameservers) do
provides "network/nameservers"
depends "network"
collect_data do
Ohai::Log.debug('Parsing resolv.conf for nameservers.')
nameservers = []
@burdandrei
burdandrei / ECS_Consul_UserData.sh
Last active March 15, 2016 15:41
User data for starting consul on node start
#!/bin/bash
#
# Bring ECS Agent config and start consul
DC=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone/ | rev | cut -c 2- | rev)
ADVERTISE_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
ECS_CLUSTER='example'
yum install -y aws-cli
aws s3 cp s3://ops-yotpo/docker/ecs/ecs.config /etc/ecs/ecs.config
@burdandrei
burdandrei / telegraf.conf
Last active August 20, 2021 10:01
Receive consul and nomad telemetry in influx in usable form
# Templates are updated to be compatible with nomad > 0.7.1
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "3s"
precision = ""
@burdandrei
burdandrei / ec2-check-reserved-instances.py
Created January 16, 2017 21:09
AWS Check reserved instances usage
#!/usr/bin/python
import boto3
import logging
import argparse
from pprint import pformat,pprint
parser = argparse.ArgumentParser(description='Cross reference existing ec2 reservations to current instances.')
parser.add_argument('--log', default="WARN", help='Change log level (default: WARN)')
parser.add_argument('--region', default='us-east-1', help='AWS Region to connect to')
@burdandrei
burdandrei / DescribeInstances_IAM_role.json
Last active December 5, 2017 12:21
IAM policy needed for Consul AWS discovery
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": [
@burdandrei
burdandrei / consul-nomad-client-systemd-docker-dnsmasq-userdata-bootstrap.sh
Created December 5, 2017 12:15
UserData Script for bootstrapping Consul and Nomad servers in AWS, connect them with AWS auto discovery and run using systemd
#!/bin/bash
#
# This script is intendent to install both Consul and Nomad clients
# on Ubuntu 16.04 Xenial managed by SystemD
# including docker and DnsMasq for *.service.consul DNS resolving
#
# Script assume that instance is running in AWS and have "ec2:DescribeInstances" permissions in IAM Role
set -x
export TERM=xterm-256color
@burdandrei
burdandrei / consul-nomad-server-systemd-dnsmasq-userdata-bootstrap.sh
Created December 5, 2017 12:17
UserData Script for bootstrapping Consul and Nomad clients in AWS, connect them with AWS auto discovery and run using systemd
#!/bin/bash
#
# This script is intendent to install both Consul and Nomad servers
# on Ubuntu 16.04 Xenial managed by SystemD
# including DnsMasq for *.service.consul DNS resolving
set -i
export TERM=xterm-256color
export DEBIAN_FRONTEND=noninteractive
export DATACENTER_NAME="example"
@burdandrei
burdandrei / nginx_logformat_json.conf
Created December 5, 2017 13:23
Nginx JSON stype logformat ready to be sent Logstash/Graylog/Splunk
log_format json escape=json
'{ "msec": "$msec", '
'"remote_addr": "$remote_addr", '
'"request_method": "$request_method", '
'"request_uri": "$request_uri", '
'"status": "$status", '
'"body_bytes_sent": "$body_bytes_sent", '
'"http_referer": "$http_referer", '
'"http_user_agent": "$http_user_agent", '
'"request_time": "$request_time" , '
@burdandrei
burdandrei / gist:376b8974a22efd0a180d75c62011f331
Created February 6, 2018 13:51
Resque cleanup workers without heartbeat
Resque.workers.each do |w|
w.unregister_worker if w.heartbeat.nil?
end