Skip to content

Instantly share code, notes, and snippets.

@brainsik
brainsik / b2-cp.md
Created Mar 15, 2021
Upload a file to B2 Cloud Storage using SSE-C (customer managed key)
View b2-cp.md

Generate key

dd if=/dev/random of=keyfile count=1 bs=32

Upload file

Endpoint is found in the bucket details via console.

@brainsik
brainsik / minimal-infra.md
Last active Mar 5, 2021
Minimalist Infrastructure
View minimal-infra.md

Minimalism

Minimalist infrastructure is the practice of building only what you need with the fewest number of resources. This is a philosophy, not a religion, you shouldn't build bad infrastructure to achieve a minimalist design. A minimalist design should lead to good infrastructure by reducing the amount of resources under management and the complexity of the design.

Avoid state

When designing your system, avoid storing additional state. Often the data you want to store is already available in the system. Using the system as the source of truth can avoid the difficult business of ensuring data consistency.

As an example, let's say you want to be able to rollback a Fargate deploy if the new task definition results in a service that won't become healthy. One option would be store the working task definition in something like DynamoDB (or git or any number of bad choices). However, your ECS service already has this information: the previous, healthy service is still running. Instead of managing a

@brainsik
brainsik / install-terraform-provider-aws.sh
Created Jan 22, 2021
Installs the AWS Terraform provider to your local plugins directory
View install-terraform-provider-aws.sh
#!/bin/sh
set -eu -o pipefail
set -x
version=$1
cd terraform-provider-aws
git fetch
git checkout .
@brainsik
brainsik / dotdict.py
Created Jun 11, 2011
Override Python's dict with this for JS style dot notation access :-)
View dotdict.py
# encoding: utf-8
class DotDict(dict):
def __init__(self, *a, **kw):
dict.__init__(self, *a, **kw)
for key in self:
self._validate_key(key)
def _validate_key(self, key):
@brainsik
brainsik / color_log.py
Created Sep 24, 2011
ANSI colored Python logging
View color_log.py
import logging
from termcolor import colored
class ColorLog(object):
colormap = dict(
debug=dict(color='grey', attrs=['bold']),
info=dict(color='white'),
warn=dict(color='yellow', attrs=['bold']),
@brainsik
brainsik / install-tf-11-14.sh
Created May 23, 2019
How to install an older version of a Homebrew forumla
View install-tf-11-14.sh
brew uninstall terraform
brew extract --version 0.11.14 terraform homebrew/cask
brew install terraform@0.11.14
@brainsik
brainsik / cidrs.tf
Last active Nov 16, 2018
Takes a list of VPC names and outputs their ID and CIDR
View cidrs.tf
data "aws_vpc" "found" {
count = "${length(var.vpc_names)}"
filter {
name = "tag:Name"
values = ["${element(var.vpc_names, count.index)}"]
}
}
output "vpc_id" {
View terraform-debug.txt
2018/07/24 15:01:38 [INFO] Terraform version: 0.11.7
2018/07/24 15:01:38 [INFO] Go runtime version: go1.10.1
2018/07/24 15:01:38 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.11.7/bin/terraform", "validate"}
2018/07/24 15:01:38 [DEBUG] Attempting to open CLI config file: /Users/jeremy.avnet/.terraformrc
2018/07/24 15:01:38 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/07/24 15:01:38 [INFO] CLI command args: []string{"validate"}
2018/07/24 15:01:38 [DEBUG] checking for provider in "."
2018/07/24 15:01:38 [DEBUG] checking for provider in "/usr/local/Cellar/terraform/0.11.7/bin"
2018/07/24 15:01:38 [DEBUG] checking for provider in ".terraform/plugins/darwin_amd64"
2018/07/24 15:01:38 [DEBUG] found provider "terraform-provider-aws_v1.28.0_x4"
@brainsik
brainsik / stubby.yml
Created Nov 20, 2017
Stubby config for Quad9
View stubby.yml
upstream_recursive_servers:
- address_data: 9.9.9.9
tls_auth_name: "dns.quad9.net"
tls_pubkey_pinset:
- digest: "sha256"
value: MujBQ+U0p2eZLTnQ2KGEqs+fPLYV/1DnpZDjBDPwUqQ=