Skip to content

Instantly share code, notes, and snippets.

View kmcquade's full-sized avatar

Kinnaird McQuade kmcquade

View GitHub Profile
@kmcquade
kmcquade / keybase.md
Last active April 25, 2018 14:28
keybase.md

Keybase proof

I hereby claim:

  • I am kmcquade on github.
  • I am kmcquade (https://keybase.io/kmcquade) on keybase.
  • I have a public key whose fingerprint is C50D 6568 07A1 84AA 1C91 AD99 CB96 8886 7C80 622E

To claim this, I am signing this object:

@kmcquade
kmcquade / test-cloud-init-run.sh
Created June 7, 2018 20:46 — forked from maoueh/test-cloud-init-run.sh
Small script to test changes made to cloud init config without rebooting
rm -rf /var/lib/cloud/instance && rm -rf /var/lib/cloud/instances/* && rm -rf /var/lib/cloud/sem/*
cloud-init init && cloud-init modules --mode config && cloud-init modules --mode final
@kmcquade
kmcquade / kms-vault
Created July 25, 2018 15:29 — forked from hassy/kms-vault
Encrypt/decrypt files using AWS KMS
#!/usr/bin/env bash
# License: MIT - https://opensource.org/licenses/MIT
#
# Usage:
#
# Encrypt a file:
# kms-vault encrypt My-Key-Alias some-file-i-want-encrypted.txt > topsecret.asc
#
@kmcquade
kmcquade / iam-terraform-create-policy.tf
Created July 31, 2018 02:11 — forked from arsdehnel/iam-terraform-create-policy.tf
AWS IAM policies for running Terraform from an EC2 instance.
resource "aws_iam_policy" "terraform_create_policy" {
name = "terraform_create_policy"
path = "/"
policy = "${data.aws_iam_policy_document.terraform_create_policy.json}"
}
data "aws_iam_policy_document" "terraform_create_policy" {
statement {
sid = "1"
actions = [
@kmcquade
kmcquade / grow-root.service
Created August 26, 2018 21:56 — forked from jdeathe/grow-root.service
CentOS-7 Systemd Unit File to Grow the Root LVM Disk on AWS EC2 Instances with an ext4 File System.
# To install:
# sudo cat grow-root.service > /etc/systemd/system/grow-root.service
# sudo systemctl daemon-reload
# sudo systemctl enable -f grow-root.service
#
# Start (auto disables after first successful expansion):
# sudo systemctl start grow-root.service
#
# Debugging:
# sudo systemctl status grow-root.service
@kmcquade
kmcquade / gist:a536053660a1933640b142f15c8a8db4
Created October 13, 2018 23:20 — forked from serkanh/gist:64c91898187e2ab03ae9cdc5e1d81114
to get decoded user data from ec2 instances
#/bin/bash
trap exit INT
INSTANCES=$( aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId[]' | sed -e 's/\[//g' -e 's/\]//g')
SUM=0
echo $INSTANCES
for i in $( echo $INSTANCES | sed -e 's/"//g' -e 's/,//g' -e 's/\[//g' -e 's/\]//g' ) ;do
echo "---------------------------$i-------------------------------\n"
aws ec2 describe-instances --instance-ids $i --query 'Reservations[].Instances[].Tags[?Key==`Name`].Value' --output text
aws ec2 describe-instance-attribute --instance-id $( echo $i | sed -e 's/"//g' -e 's/,//' -e 's/\[//g' -e 's/\]//g' ) --attribute userData \
| jq '.UserData.Value' | sed 's/"//g' | base64 --decode
@kmcquade
kmcquade / restricted-psp.yaml
Created October 30, 2018 14:20 — forked from tallclair/restricted-psp.yaml
Restricted PodSecurityPolicy
apiVersion: extensions/v1beta1
kind: PodSecurityPolicy
metadata:
name: restricted
annotations:
seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default'
apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default'
seccomp.security.alpha.kubernetes.io/defaultProfileName: 'docker/default'
apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default'
spec:
@kmcquade
kmcquade / README.md
Created November 21, 2018 00:04 — forked from nathanielks/README.md
These scripts are for use with https://github.com/humanmade/cf-to-tf.

CloudFormation -> Terraform Import Helpers

I wrote these scripts to help faciliate batch import of our CloudFormation templates into Terraform Configuration.

region-batch.sh

This script is a light wrapper around batch.sh. It simply iterates over the list of regions provided, exports expected variables, creates required directories, and calls batch.sh.

BASE_DIR=/path/to/dir EXCLUDE_REGEX="(some-stack-production|some-stack-staging)" ./region-batch.sh us-east-1 us-west-1
@kmcquade
kmcquade / _aws_scripts.md
Created September 9, 2018 19:56
Miscellaneous useful scripts with AWS

List:

  • export-aws-creds.py
    • Simple script that parses the ~/.aws/credentials file and creates the export command needed for pumping your AWS creds to command line

aws-secrets-send.sh and aws-secrets-get.sh

  • Used for grabbing secrets from S3 encrypted at the object level with KMS.
  • Easy to copy + paste or include in your repo when you have to use Ec2 userdata + IAM roles to download KMS-encrypted objects from S3
  • Based on this github repo but without the built-in options to create buckets and keys. This limits the capabilities of the script in a good way.
@kmcquade
kmcquade / cloud-config.yml
Created December 24, 2018 22:49 — forked from justinsoliz/cloud-config.yml
Terraform definition for Jenkins with ECS, EFS, CoreOS
#cloud-config
write-files:
- path: /etc/conf.d/nfs
permissions: '0644'
content: |
OPTS_RPC_MOUNTD=""
coreos:
units:
- name: update-engine.service