Skip to content

Instantly share code, notes, and snippets.

View nonbeing's full-sized avatar
💭
Busy: may be slow to respond.

Ambar nonbeing

💭
Busy: may be slow to respond.
View GitHub Profile

Using aws-cli and jq

list all instances for all ASGs

aws autoscaling describe-auto-scaling-instances \
  | jq '.AutoScalingInstances[] | {AutoScalingGroupName, InstanceId}'

list instance IDs for a particular ASG

var url = require('url');
var https = require('https');
var querystring = require('querystring');
var webhookID = 'YOUR/WEBHOOK/integration-id';
var webhookURLBase = 'https://hooks.slack.com/services/';
var webhookURL = [webhookURLBase, webhookID].join('');
var slashCommandToken = 'your-slash-command-token';
@nonbeing
nonbeing / CloudWatchAlarmToSlack.js
Last active March 1, 2022 15:02
AWS Lambda Function to handle CloudWatch SNS events for AutoScaling and post notifications to Slack.
var AWS = require('aws-sdk');
var url = require('url');
var https = require('https');
var hookUrl, slackChannel;
hookUrl = 'https://hooks.slack.com/services/ABC/DEF/XYZ'; // Enter your Slack hook URL here
slackChannel = 'MySlackChannel'; // Enter the Slack channel to send a message to
var postMessage = function(message, callback) {
var body = JSON.stringify(message);
@nonbeing
nonbeing / BrewBindInstallAndSetupMacOSX10_10.sh
Created May 13, 2016 12:02 — forked from mpaskalev/BrewBindInstallAndSetupMacOSX10_10.sh
Install and setup bind (named) on Mac OS X 10.10.1 with brew 0.9.5
#!/bin/bash
# Run as root or sudo the commands that need it as you go.
# brew version 0.9.5
# Mac OS X 10.10.1
# A little bit changed version of this:
# http://stackoverflow.com/questions/19538118/osx-mavericks-bind-no-longer-installed-how-to-get-local-dns-server-working
## convert HTML POST data or HTTP GET query string to JSON - sourced from https://forums.aws.amazon.com/thread.jspa?messageID=673012
## get the raw post data from the AWS built-in variable and give it a nicer name
#if ($context.httpMethod == "POST")
#set($rawAPIData = $input.path('$'))
#elseif ($context.httpMethod == "GET")
#set($rawAPIData = $input.params().querystring)
#set($rawAPIData = $rawAPIData.toString())
#set($rawAPIDataLength = $rawAPIData.length() - 1)
#set($rawAPIData = $rawAPIData.substring(1, $rawAPIDataLength))
require 'rubygems'
require 'sinatra'
require 'rdiscount'
require 'haml'
require 'dm-core'
require 'sinatra-authentication'
use Rack::Session::Cookie, 'shhhhhhhhhhhhhhh~'
class Page
@nonbeing
nonbeing / rest-server.py
Last active January 28, 2016 14:38 — forked from miguelgrinberg/rest-server.py
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@nonbeing
nonbeing / s3clonebucket.py
Created December 12, 2015 04:44 — forked from erans/s3clonebucket.py
Clone S3 Bucket
import argparse
import time
from boto.s3.connection import S3Connection
from boto.exception import S3ResponseError
def run(args):
s3_connection = S3Connection(args.aws_access_key, args.aws_secret_access_key)
source_bucket = s3_connection.get_bucket(args.source_bucket)
destination_bucket = None
@nonbeing
nonbeing / ipython_gitprompt.py
Created November 26, 2015 13:16 — forked from mvaled/gitprompt.py
Simple file to be placed in IPython's conf dir to allow prompts to include the git branch and status.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# gitprompt.py
#
# Copyright 2012 Manuel Vázquez Acosta <mva DOT led AT google-mail-address-here.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@nonbeing
nonbeing / amazon_ip_ranges.json
Created November 20, 2015 08:08
Amazon IP Ranges - 20Nov2015 - public info available at https://ip-ranges.amazonaws.com/ip-ranges.json
{
"syncToken": "1447807337",
"createDate": "2015-11-18-01-22-03",
"prefixes": [
{
"ip_prefix": "23.20.0.0/14",
"region": "us-east-1",
"service": "AMAZON"
},
{