Skip to content

Instantly share code, notes, and snippets.

View mafonso's full-sized avatar

Miguel Afonso mafonso

View GitHub Profile
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
@mafonso
mafonso / list-all-access-keys.sh
Last active October 10, 2023 05:19
List Access Keys for all IAM users
for user in $(aws iam list-users --output text --no-cli-pager | awk '{print $NF}'); do
aws iam list-access-keys --user $user --output text --no-cli-pager
test $? -gt 128 && exit
done
@mafonso
mafonso / cluster.conf
Last active August 27, 2015 20:40
RedHat Cluster Suite Postgres
<?xml version="1.0"?>
<cluster config_version="7" name="pgcluster">
<clusternodes>
<clusternode name="10.39.30.11" votes="1" nodeid="1">
<fence/>
</clusternode>
<clusternode name="10.39.30.12" votes="1" nodeid="2">
<fence/>
</clusternode>
</clusternodes>
@mafonso
mafonso / gist:b34cfa7a81a3f7cdec62
Created November 12, 2015 15:48
Consul template to scan all services
# Consul Services
{{range services}}
backend {{.Name}}
balance roundrobin
option redispatch
option forwardfor
{{range service .Name}} server {{.Name}} {{.Address}}:{{.Port}}
{{end}} {{end}}
#End Consul services
@mafonso
mafonso / ssh_commands
Last active December 1, 2015 15:28
Random SSH commands
# Generate public key from private
ssh-keygen -f id_rsa -y > id_rsa.pub
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
export AWS_ACCESS_KEY_ID=${aws_access_key_id}
export AWS_SECRET_ACCESS_KEY=${aws_secret_access_key}

Keybase proof

I hereby claim:

  • I am mafonso on github.
  • I am mafonso (https://keybase.io/mafonso) on keybase.
  • I have a public key whose fingerprint is F54B 0FC9 3669 51F1 8E73 27FD 9838 2820 11FD 662C

To claim this, I am signing this object:

2016/12/06 14:31:58.477298 [INFO] consul-template v0.16.0
2016/12/06 14:31:58.477321 [INFO] (runner) creating new runner (dry: false, once: false)
2016/12/06 14:31:58.477615 [DEBUG] (runner) final config (tokens suppressed):
{
"Path": "/usr/local/consul-template/config/nginx.hcl",
"Consul": "172.17.0.1:8500",
"Token": "",
"ReloadSignal": 1,
"DumpSignal": 3,
On Vault:
$ vault auth-enable aws-ec2
Successfully enabled 'aws-ec2' at 'aws-ec2'!
Error applying plan:
1 error(s) occurred:
* module.postgres.aws_db_instance.instance: aws_db_instance.instance: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.
Please include the following information in your report:
Terraform Version: 0.9.2
Resource ID: aws_db_instance.instance