Skip to content

Instantly share code, notes, and snippets.

View tristanmorgan's full-sized avatar
⌨️
tappity tap.

Tristan Morgan tristanmorgan

⌨️
tappity tap.
View GitHub Profile
@tristanmorgan
tristanmorgan / gen-aws-keys.sh
Last active April 8, 2024 22:29
Generate fake AWS creds for testing using awskeyring and aws(ruby)cli
#!/bin/sh
TEMP_KEY=$(aws sts generate-fake-key)
AWS_ACCESS_KEY_ID=$(jq -r .access_key.access_key_id <<< $TEMP_KEY)
echo export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
echo export AWS_SECRET_ACCESS_KEY=$(jq -r .access_key.secret_access_key <<< $TEMP_KEY)
echo export AWS_ACCOUNT_ID=$(awskeyring decode $AWS_ACCESS_KEY_ID)
@tristanmorgan
tristanmorgan / .terraformrc
Last active March 15, 2024 05:42
Terraform Cloud Token Helper (save into macOS keychain)
disable_checkpoint = true
credentials_helper helper {
args = []
}
# save this in home.
@tristanmorgan
tristanmorgan / alpine-img.pkr.hcl
Last active August 3, 2023 04:32
Packer file to build an Alpine Linux image for Qemu
packer {
required_plugins {
qemu = {
source = "github.com/hashicorp/qemu"
version = "~> 1"
}
}
}
source "qemu" "alpine" {
@tristanmorgan
tristanmorgan / aws-key-gen.rb
Created April 28, 2023 04:14
Generate an AWS access key ID and secret that passes the regex in AWSKeyring.
#!/usr/bin/env ruby
require 'securerandom'
puts "AKIA#{Array.new(16){[*"A".."Z", *"2".."7"].sample}.join}"
puts SecureRandom.base64(30)
@tristanmorgan
tristanmorgan / 10.in-addr.arpa
Created March 6, 2022 23:47
Use Consul DNS for ".consul" and reverse IP lookups on macOS
# /etc/resolver/10.in-addr.arpa
nameserver 127.0.0.1
port 8600
@tristanmorgan
tristanmorgan / ssh-config
Last active October 28, 2022 03:00
ssh/config with proxy environment switch.
Host *
StrictHostKeyChecking no
ServerAliveInterval 60
FingerprintHash md5
VisualHostKey yes
ControlPath /tmp/%r@%h:%p
IdentityFile ~/.ssh/id_rsa
Host github.com
ControlMaster auto
@tristanmorgan
tristanmorgan / hashup.sh
Last active October 28, 2022 02:51
Quick script to download latest HashiCorp binaries. (for arm mac)
#!/bin/sh
set -e
export CHECKPOINT_DISABLE=1
download() {
echo checking $1
TF_TAGS_FEED="https://api.releases.hashicorp.com/v1/releases/$1/latest"
RELEASE_JSON=$(curl -s -H "Cache-Control: no-cache" "$TF_TAGS_FEED")
LATEST_VERSION=$(echo ${RELEASE_JSON} | jq -r .version )
$ TF_LOG=debug terraform apply -auto-approve -no-color
2021-12-22T15:49:42.089+1100 [INFO] Terraform version: 1.1.2
2021-12-22T15:49:42.089+1100 [INFO] Go runtime version: go1.17.2
2021-12-22T15:49:42.089+1100 [INFO] CLI args: []string{"terraform", "apply", "-auto-approve", "-no-color"}
2021-12-22T15:49:42.089+1100 [DEBUG] Attempting to open CLI config file: /Users/tristanmorgan/.terraformrc
2021-12-22T15:49:42.089+1100 [INFO] Loading CLI configuration from /Users/tristanmorgan/.terraformrc
2021-12-22T15:49:42.090+1100 [DEBUG] checking for credentials in "/Users/tristanmorgan/.terraform.d/plugins"
2021-12-22T15:49:42.090+1100 [DEBUG] found credentials "terraform-credentials-keychain_v1.0.0"
2021-12-22T15:49:42.090+1100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021-12-22T15:49:42.090+1100 [DEBUG] will search for provider plugins in /Users/tristanmorgan/.terraform.d/plugins
@tristanmorgan
tristanmorgan / lib-vault-api-auth.rb
Created August 10, 2017 07:08
An attempt at calling Hashicorp Vault IAM Auth backend in Ruby
# Authenticate via the AWS EC2 authentication method (IAM method). If authentication is
# successful, the resulting token will be stored on the client and used
# for future requests.
#
# @example
# Vault.auth.aws_ec2_iam("dev-role-iam", "vault.example.com") #=> #<Vault::Secret lease_id="">
#
# @param [String] role
# @param [String] iam_auth_header_value
#
@tristanmorgan
tristanmorgan / vault-token-helper.sh
Last active February 22, 2021 03:25
HashiCorp Vault Token Helper (save into macOS keychain)
#!/bin/sh
set -e
[ -z "$VAULT_ADDR" ] && VAULT_ADDR="https://127.0.0.1:8200"
case $1 in
store)
security add-generic-password -U -a "VAULT-$USER" -c "hvlt" -C "hvlt" -D "Hashicorp Vault" -s "$VAULT_ADDR" -w "$(cat)"
;;
get)