Skip to content

Instantly share code, notes, and snippets.

View atward's full-sized avatar

Adam Ward atward

  • Melbourne, Australia
View GitHub Profile
@atward
atward / aws-console
Last active August 8, 2022 02:10
AWS Web console login via boto credentials (IAM access token/profile)
#!/usr/bin/env python
import boto3
import json
import sys
import urllib2
import webbrowser
from urllib import urlencode
@atward
atward / source_tfvars.sh
Last active July 13, 2021 11:48
Rudimentary parsing of terraform tfvars in bash
#!/bin/bash
# source: https://gist.github.com/atward/7a2eb1b4a78fbaebe585
# here be dragons: this is as dangerous as it looks
## terraform variable defaults
# takes *.tf and assigns env=default (if any)
# - map not supported (obvious reasons)
# - Tested on Darwin sed(1) only
function source_tfdefaults() {
eval "$(
@atward
atward / example-gcp-lb-http2.tf
Last active April 1, 2021 00:38
Example Terraform GCP Global HTTP LB with HTTP/2 backend instance group
module "http_lb" {
source = "GoogleCloudPlatform/lb-http/google"
version = "~> 4.5"
project = var.project_id
name = "demo"
http_forward = false
ssl = true
private_key = tls_private_key.example.private_key_pem
@atward
atward / example-dev-memcache.tf
Created March 12, 2021 03:11
Example Terraform GCP org with Memcache in service project
# add memcache (Memorystore) example to development
resource "google_memcache_instance" "cache_dev" {
provider = google-beta
project = google_project.development.project_id
name = "cache-dev"
region = var.region
authorized_network = google_service_networking_connection.private_service_connection.network
node_config {
cpu_count = 1
# theme based off https://github.com/magicmonty/bash-git-prompt/blob/a2182bb646987ebca978a655a5deb18bcc65dbe1/themes/Single_line_Solarized.bgptheme
define_helpers() {
:
}
# Get git relative path
function prompt_callback {
if [[ -e "$repo" ]]; then
GitBaseName="${repo##*/}"
@atward
atward / fix_terragrunt_state.py
Created May 1, 2019 06:41
Attempts to fix inconsistencies with terragrunt local tfstate, s3 backend state and dynamodb lock state
#!/usr/bin/env python3
import os
import json
from pprint import pprint
import boto3
@atward
atward / safeget.py
Created May 1, 2019 05:24 — forked from WTFox/safeget.py
Perfect for handling nested dictionaries where values might not exist.
def safeget(dct, *keys):
dct = dict(dct)
for key in keys:
try:
dct = dct[key]
except (KeyError, AttributeError, TypeError) as e:
return None
return dct
@atward
atward / github_get
Created March 5, 2019 23:31
Script to download asset file from tag release using GitHub API v3
#!/usr/bin/env bash
# Script to download asset file from tag release using GitHub API v3.
# See: http://stackoverflow.com/a/35688093/55075
# Check dependencies.
set -e
type curl grep sed tr >&2
# Validate settings.
[ "$GITHUB_API_TOKEN" ] || { echo "Error: Please define GITHUB_API_TOKEN variable." >&2; exit 1; }
#cloud-init
# https://docs.chef.io/packages.html#enterprise-linux
# vendor chef-repo to /var/lib/chef with cookbooks in /var/lib/chef/cookbooks
yum_repos:
chef-stable:
name: chef-stable
baseurl: https://packages.chef.io/stable-yum/el/7/\$basearch/
enabled: true
failovermethod: priority
@atward
atward / keybase.md
Created January 4, 2019 07:04
keybase.md

Keybase proof

I hereby claim:

  • I am atward on github.
  • I am atward (https://keybase.io/atward) on keybase.
  • I have a public key whose fingerprint is DCF7 1D93 BE2C E24D CC64 62AD 5795 E6B4 8B33 50F2

To claim this, I am signing this object: