Skip to content

Instantly share code, notes, and snippets.

View artburkart's full-sized avatar
💭
why

Arthur Burkart artburkart

💭
why
  • Coinbase
  • somewhere rainy, probably
View GitHub Profile
@artburkart
artburkart / copy_kv.sh
Created June 14, 2017 20:12
backup consul kv store with terraform (used for upgrading consul versions that didn't have backups)
import subprocess
import json
import base64
import os
# Gather all key values
keys = json.loads(subprocess.check_output(['curl', '-sL', 'http://localhost:8500/v1/kv/?keys']))
# Map them to their values
kvs = {}
@artburkart
artburkart / README.md
Created June 14, 2017 03:50
testing terraform tags from data sources

Usage

  1. If you run terraform plan agains the main.tf as-is, you get this output:
+ aws_ebs_volume.ebs_vol
    availability_zone: "us-east-1"
    encrypted:         "<computed>"
    iops:              "<computed>"
    kms_key_id:        "<computed>"
    size:              "40"
@artburkart
artburkart / main.tf
Created June 14, 2017 02:39
aws_security_group test thing
provider "aws" {
region = "us-east-1"
}
variable "cidr" {
# default = "0.0.0.0/0"
default = ""
}
resource "aws_security_group" "dummy" {
@artburkart
artburkart / LambdaFunctionOverHttps.js
Last active August 30, 2018 02:36
testing_localstack_apigateway_lambda
console.log('Loading function');
var AWS = require('aws-sdk');
var dynamo = new AWS.DynamoDB.DocumentClient();
/**
* Provide an event that contains the following keys:
*
* - operation: one of the operations in the switch statement below
* - tableName: required for operations that interact with DynamoDB
@artburkart
artburkart / commands.md
Last active March 27, 2017 02:09
Terraform #12716

Should look like this:

$ tree
.
├── production
│   ├── production.tf
│   └── terraform.tfstate
└── site
    └── main.tf
@artburkart
artburkart / main.tf
Created March 12, 2017 22:45
Test case for aws_route_table data source
provider "aws" {
region = "us-east-1"
}
data "aws_route_table" "art" {
subnet_id = "subnet-########"
}
data "template_file" "art" {
template = "$${rtb_route}"
@artburkart
artburkart / main.tf
Last active March 12, 2017 22:44
Test case for aws_instances data source
provider "aws" {
region = "us-east-1"
}
data "aws_instances" "boxes" {
instance_ids = ["i-########", "i-########"]
}
data "template_file" "boxes" {
template = "$${instance_subnet}"
@artburkart
artburkart / bumpme
Last active November 11, 2016 17:03
bumpme
Fri Nov 11 17:03:17 UTC 2016
@artburkart
artburkart / find_user_by_aws_access_key.sh
Created August 17, 2016 20:16
Find IAM user with given AWS Access Key ID
#!/bin/bash
# Usage: bash find_user_by_aws_access_key.sh SOME_AWS_ACCESS_KEY
# This script finds the user in the account who has a given access key
ACCESS_KEY=$1
for user in `aws iam list-users | jq -r '.Users[].UserName'`; do
USER=`aws iam list-access-keys --user $user | jq '.AccessKeyMetadata[] | select(.AccessKeyId == "'"$ACCESS_KEY"'")'`
if [ -n "$USER" ]; then
echo "$USER"
exit 0
@artburkart
artburkart / sqs_stuff.py
Created July 22, 2016 14:01
Sample boto3 sqs stuff
sqs = boto3.resource('sqs', 'us-east-1') # python code
sqs_queue = sqs.get_queue_by_name(QueueName=queue_name)
msg = json.dumps({'timestamp': time.time(), 'type': 'job', 'data': payload)) # equivalent of JSON.stringify
sqs_queue.send_message(MessageBody=fake_message)