Skip to content

Instantly share code, notes, and snippets.

@daveadams
daveadams / too-old.sh
Created November 15, 2022 20:31
List running EC2 instances with a given tag older than a certain number of hours
# too-old.sh
# Author: David Adams
# License: Public Domain
#
# Provides a bash function for listing EC2 instances with a given tag value older than a
# certain number of hours. This script is not particularly robust to unexpected error
# conditions. This is just a quick example.
#
# PREREQUISITES
#
@daveadams
daveadams / find-latest-ami.sh
Created July 29, 2022 13:04
Find latest Amazon deep learning AMI
#!/usr/bin/env bash
# Find the latest Amazon-created "Deep Learning AMI (Ubuntu 18.04)" AMI image ID
#
# args explanation:
# --region us-east-1
# Specifies the AWS region (you can also specify it in your
# ~/.aws/config or via the `AWS_REGION` or `AWS_DEFAULT_REGION`
# env vars)
#
@daveadams
daveadams / aws-roles-anywhere-request.md
Created July 13, 2022 17:55
AWS Roles Anywhere credential process request transcript

Credential Process Command

$ ./aws_signing_helper credential-process \
    --profile-arn arn:aws:rolesanywhere:us-east-2:123456789012:profile/12345678-90ab-cdef-1234-567890abcdef \
    --role-arn arn:aws:iam::123456789012:role/roles-forever \
    --trust-anchor-arn arn:aws:rolesanywhere:us-east-2:123456789012:trust-anchor/12345678-90ab-cdef-1234-567890abcdef \
    --private-key tls/tls.key \
    --certificate tls/tls.crt \
    --region us-east-2 \

--no-verify-ssl \

@daveadams
daveadams / kuard.yml
Created October 21, 2021 15:09
Simple kuard manifest suitable for Rancher Desktop
apiVersion: v1
kind: Namespace
metadata:
name: kuard
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kuard
labels:
@daveadams
daveadams / limits.sh
Created July 31, 2020 21:13
Scan AWS usage and limits
#!/bin/bash
regions="us-east-1 us-west-2 us-east-2 ca-central-1 eu-west-1 eu-central-1 ap-southeast-1 ap-southeast-2"
acct=$( aws iam list-account-aliases |jq -r .AccountAliases[] )
echo "Account $acct"
echo
echo vCPU Limits: A, C, D, H, I, M, R, T, Z
echo ========================================
@daveadams
daveadams / main.tf
Created July 14, 2017 19:00
Hacky consul-acl Terraform module
variable "name" {}
variable "policy" {}
resource "null_resource" "acl" {
triggers {
name = "${var.name}"
policy = "${var.policy}"
}
provisioner "local-exec" {
#!/usr/bin/env ruby
require 'diplomat'
def die(msg)
STDERR.puts "ERROR: #{msg}"
exit 1
end
def print_usage
# upstart config for consul-replicate
# run this on each consul server. "consul lock" will ensure only one is operating per datacenter
#
description "Consul Replicate"
start on started consul
stop on stopping network-services
respawn
#!/bin/bash
# via: http://askubuntu.com/a/421028
# original: https://bugs.launchpad.net/upstart/+bug/406397/comments/47
# usage: sh /tmp/upstart_fix.sh <pid>
sleep 0.001 &
firstPID=$!
#first lets exhaust the space
#!/bin/bash
echo "Failure mode test suite for bash"
echo " running bash $BASH_VERSION"
try() {
trap 'echo FAILS' EXIT
case $1 in
simple)
printf " %-34s" "simple failed command"