Skip to content

Instantly share code, notes, and snippets.

View iMilnb's full-sized avatar

iMil iMilnb

View GitHub Profile
@iMilnb
iMilnb / tf_debug.log
Created December 6, 2018 14:09
terraform debug for aws_ses_receipt_rule bug report
terraform apply tfplan
2018/12/06 14:44:36 [INFO] Terraform version: 0.11.10 17850e9a55d33c43d7c31fd6ac122ba97a51d899
2018/12/06 14:44:36 [INFO] Go runtime version: go1.11.1
2018/12/06 14:44:36 [INFO] CLI args: []string{"/home/imil/pkg/bin/terraform", "apply", "tfplan"}
2018/12/06 14:44:36 [DEBUG] Attempting to open CLI config file: /home/imil/.terraformrc
2018/12/06 14:44:36 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/12/06 14:44:36 [INFO] CLI command args: []string{"apply", "tfplan"}
2018/12/06 14:44:36 [INFO] command: initializing local backend from plan (not set)
2018/12/06 14:44:36 [DEBUG] checking for provider in "."
2018/12/06 14:44:36 [DEBUG] checking for provider in "/home/imil/pkg/bin"
@iMilnb
iMilnb / bitstamp.go
Created December 21, 2017 22:22
collectd go plugin to fetch Bitstamp prices
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"strconv"
"time"
@iMilnb
iMilnb / README.md
Last active January 18, 2024 08:08
AWS Terraform configuration: Stream CloudWatch Logs to ElasticSearch

Rationale

This snippet is a sample showing how to implement CloudWatch Logs streaming to ElasticSearch using terraform. I wrote this gist because I didn't found a clear, end-to-end example on how to achieve this task. In particular, I understood the resource "aws_lambda_permission" "cloudwatch_allow" part by reading a couple of bug reports plus this stackoverflow post.

The js file is actually the Lambda function automatically created by AWS when creating this pipeline through the web console. I only added a endpoint variable handling so it is configurable from terraform.

@iMilnb
iMilnb / collectd.conf
Last active October 10, 2018 21:33
collectd-python plugin to read data from ethermine.org
<Plugin python>
ModulePath "/home/imil/collectd"
Import "ethermine"
<Module ethermine>
wallet "0xf00f00f00"
interval "300"
url "https://ethermine.org/api/miner_new"
</Module>
</Plugin>
@iMilnb
iMilnb / meta2dict.py
Last active February 9, 2020 02:49
Imports AWS EC2 instance metadata (http://169.254.169.254/latest) into a python dict
#!/usr/bin/env python
import requests
import json
# Converts AWS EC2 instance metadata to a dictionary
def load():
metaurl = 'http://169.254.169.254/latest'
# those 3 top subdirectories are not exposed with a final '/'
@iMilnb
iMilnb / aws_sandbox.md
Last active September 26, 2018 16:30
Custom AWS sandbox using packer, Troposphere / CloudFormation and Ansible

packer template

{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": ""
  },
  "builders": [{
    "type": "amazon-ebs",
@iMilnb
iMilnb / basic_asg.py
Last active April 23, 2017 13:27
Simple ASG (1:1) creation via Troposphere, providing a CloudFormation JSON template
from troposphere import Template, Ref, Parameter, Tags
from troposphere.autoscaling import LaunchConfiguration, AutoScalingGroup, Tag
t = Template()
params = {
'AmiId': 'Baked AMI Id',
'InstanceName': 'Name tag of the instance',
'SecurityGroup': 'Security Group' ,
'KeyName': 'SSH Key Name' ,
@iMilnb
iMilnb / sysctl.conf
Last active October 1, 2016 14:45
sysctl kernel parameters for full gigabit throughput on NetBSD
# documentation
# https://calomel.org/freebsd_network_tuning.html
# https://mail-index.netbsd.org/tech-net/2015/08/03/msg005317.html
# http://proj.sunet.se/E2E/tcptune.html
#
# Warning: this is aimed at a **client** setup, a server with
# many connexions could exhaust its memory with values this high
#
kern.sbmax=16777216
net.inet.tcp.recvbuf_auto=1
@iMilnb
iMilnb / getmonit.py
Last active February 11, 2022 08:24
Fetch monit XML status URL content, transform it to JSON and display a status report
#!/usr/bin/env python
import requests
import xmltodict
import json
import os
import sys
with open('{0}/.getmonitrc'.format(os.path.expanduser('~'))) as f:
cf = json.loads(f.read())
@iMilnb
iMilnb / ddbench.sh
Last active June 5, 2017 22:39
Trivial disk troughput bench using dd(1)
#!/bin/sh
[ $# -lt 1 ] && echo "usage: $0 <path>" && exit 1
bpath=$1
# you might want to change these to suit your setup
bs=32k
count=30000