Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import re
import signal
import sys
import time
@ianblenke
ianblenke / consul_blocking_query.sh
Last active July 23, 2017 09:18
Consul blocking queries using X-Consul-Index via curl
#!/bin/bash
while true; do
INDEX_FILE="$(mktemp -t consul_index_XXX)"
CONSUL_INDEX=$(
curl -isL -H "X-Auth-Token: $CONSUL_TOKEN" \
-H 'X-Consul-Index: 1' \
--cacert /etc/consul/ssl/ca.cert "https://consul.service.consul:8500/v1/event/list?index=$CONSUL_INDEX&wait=1m" | \
tee "$INDEX_FILE" | \
grep X-Consul-Index | \
sed -e 's/^.*: *//' | \
#!/bin/bash
pkcs7=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/pkcs7 | paste -s -d '')
result=$(curl -X POST "http://10.0.1.130:8200/v1/auth/aws-ec2/login" -d '{"role":"myapp","pkcs7":"'"$pkcs7"'","nonce":"vault-client-nonce"}')
token=$( jq -r .auth.client_token <<< "$result" )
policies=$( jq -r .auth.policies[] <<< "$result" )
ami_id=$( jq -r .auth.metadata.ami_id <<< "$result" )
[[ -n $token ]] || exit 1
@murarisumit
murarisumit / aws_powershell_get_all_instance_private_IP.ps1
Created April 6, 2015 03:50
AWS powershell get all instance private IP
$instances = (Get-ec2instance -region us-east-1 ).Instances
$servers = @()
foreach( $instance in $instances) {
$ipAddrs+=$instance.PrivateIpAddress
}
foreach ($ip in $ipAddrs) {
write-host $ip
}
@davidkelley
davidkelley / gist:741c64a3d623e9eaa3a8
Created March 27, 2015 15:43
Determine oldest instance inside AutoScalingGroup using LaunchTime
GROUP=$(ec2-describe-tags --filter "resource-type=instance" --filter "resource-id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" --filter "key=aws:autoscaling:groupName" | cut -f5)
IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $GROUP --query 'AutoScalingGroups[0].Instances[].InstanceId' --output text | sed 's/\t/ /g')
IPS=$(aws ec2 describe-instances --instance-ids $IDS --region us-east-1 --query Reservations[].Instances[].PrivateIpAddress --output text | sed 's/\t/,/g')
LAUNCH_TIME=$(date -d $(aws ec2 describe-instances --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` --query Reservations[].Instances[0].LaunchTime --output text))
LAUNCH_TIMES=$(aws ec2 describe-instances --instance-ids $IDS --region us-east-1 --query Reservations[].Instances[].LaunchTime --output text)
@webstandardcss
webstandardcss / pedantically_commented_playbook.yml
Last active April 23, 2019 06:03 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options.
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@adamstauffer
adamstauffer / delete_ecs_services.py
Last active February 26, 2020 07:55
Delete all services in an ECS cluster using boto3
"""Delete all services in an ECS Cluster using boto3.
Requires listing all services in a cluster, setting their desired tasks to 0,
then deleting the service.
"""
import boto3
CLUSTER_NAME = 'your-cluster-here'
@loverdos
loverdos / mvn-project-version.sh
Created May 20, 2015 10:07
Get maven project version from the shell
mvn help:evaluate -Dexpression=project.version | grep -e '^[^\[]'
#!/bin/bash
set -e
# Those should be JENKINS vars
NAME=nginx-deployment-3
PODS_COUNT=3
CONTAINER_NAME=nginx
DOCKER_IMAGE='nginx:1.8'
# Template can be copied from deploy.tmp.yaml to update jenkins var
@ambakshi
ambakshi / route53-asg-rrdns.sh
Last active July 25, 2021 05:39
Add all instances in an autoscaling group to an equivalently named dns entry.
#!/bin/bash
#
# Get all IPs from an autoscale group and update set the local ip as
# equal weight A entries (round robin dns). Takes autoscale group as
# parameter.
#
# Amit Bakshi
# 10/21/2014
#