Skip to content

Instantly share code, notes, and snippets.

# The primary network interface
auto eth0
iface eth0 inet dhcp
iface eth0:0 inet static
address 10.9.248.180
#/25 is our VPC subnet.
netmask 255.255.255.128
@bfleming-ciena
bfleming-ciena / gist:75d9e3128b1122d6a4d1
Last active December 1, 2015 23:47
aws describe-tags example --filter option
# Seems impossible to find an example like this. Didn't want to use boto, just wanted to use bash to pull the value of a tag out. Holy crap this is long.
aws ec2 describe-tags --region us-west-2 --filters '[{"name":"resource-id","values":["i-abc12345"]},{"name":"key","values":["MY_TAG"]}]' | jq '.Tags[].Value'
@bfleming-ciena
bfleming-ciena / gist:c1d3e5a5b77a156473a8
Last active September 8, 2018 18:59
Pull estimated AWS charges Billing
#list metrics
aws --profile dev --region us-east-1 cloudwatch list-metrics --namespace "AWS/Billing"
# Estimated charges
aws --region us-east-1 cloudwatch get-metric-statistics --namespace "AWS/Billing" --metric-name "EstimatedCharges" --dimension "Name=Currency,Value=USD" --start-time $(gdate +"%Y-%m-%dT%H:%M:00" --date="-12 hours") --end-time $(gdate +"%Y-%m-%dT%H:%M:00") --statistic Maximum --period 60 --output text | sort -r -k 3 | head -n 1 | cut -f 2
# Marketplace Charges
aws --profile dev --region us-east-1 cloudwatch get-metric-statistics --namespace "AWS/Billing" --metric-name "EstimatedCharges" --dimensions Name=ServiceName,Value=AWSMarketplace Name=Currency,Value=USD --start-time $(gdate +"%Y-%m-%dT%H:%M:00" --date="-12 hours") --end-time $(gdate +"%Y-%m-%dT%H:%M:00") --statistic Maximum --period 60 --output text
# Redshift
@bfleming-ciena
bfleming-ciena / gist:b8be26b7da3b731ba32f
Created September 8, 2015 19:47
iam ec2 tart policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1441741040000",
"Effect": "Allow",
"Action": [
"ec2:StartInstances"
],
"Condition": {
global
log 127.0.0.1:514 local1
defaults
mode http
log global
option httplog
option http-server-close
option dontlognull
option redispatch
@bfleming-ciena
bfleming-ciena / gist:06ab3531a1c30c3b998a
Created February 18, 2015 20:06
Simple example using python scp module to do wildcard scp with progress
from paramiko import SSHClient
from scp import SCPClient
def progress(filename, size, sent):
print filename + " " + str(size) + " " + str(sent)
if __name__ == "__main__":
ssh = SSHClient()
ssh.load_system_host_keys()
@bfleming-ciena
bfleming-ciena / gist:6dd1ef2318b593b0ccb5
Created February 5, 2015 19:11
allow user to switch to role
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::acct:role/S3-Admin"
}
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ProtectTaggedVPC",
"Effect": "Deny",
"Action": [
"ec2:DeleteVpc"
],
"Resource": [
@bfleming-ciena
bfleming-ciena / gist:4a6a2a00b2e685965236
Created February 2, 2015 18:21
example s3-only policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3Only",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
@bfleming-ciena
bfleming-ciena / gist:46a168d7ee56821c87b5
Last active August 29, 2015 14:14
Exhibitor/Zookeeper - My setup that works (note the java RAM usage if you're system doesn't have 4GB)
servers-spec=
zookeeper-data-directory=/zookeeper/data
zookeeper-install-directory=/zookeeper/*
zookeeper-log-directory=
log-index-directory=/zookeeper/log-index
cleanup-period-ms=200000
check-ms=2000
backup-period-ms=600000
client-port=2181
cleanup-max-files=20