Skip to content

Instantly share code, notes, and snippets.

View jamtur01's full-sized avatar
💭
I may be slow to respond.

James Turnbull jamtur01

💭
I may be slow to respond.
View GitHub Profile
env TF_LOG=DEBUG terraform get -update
2016/10/15 05:59:20 [INFO] Terraform version: 0.7.6 754bdda8a78b24efab62f1dc24d97c1c02d89fe9
2016/10/15 05:59:20 [INFO] CLI args: []string{"/usr/local/bin/terraform", "get", "-update"}
2016/10/15 05:59:20 [DEBUG] Detected home directory from env var: /Users/james
2016/10/15 05:59:20 [DEBUG] Detected home directory from env var: /Users/james
2016/10/15 05:59:20 [DEBUG] Attempting to open CLI config file: /Users/james/.terraformrc
2016/10/15 05:59:20 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/10/15 05:59:20 [DEBUG] Detected home directory from env var: /Users/james
Get: git::https://github.com/turnbullpublishing/tf_api.git (update)
Get: git::ssh://[email protected]/turnbullpublishing/tf_vpc.git?ref=v0.0.2 (update)
@jamtur01
jamtur01 / pre-commit
Created October 18, 2016 21:54
A Terraform validation and formatting pre-commit hook
#!/usr/bin/env bash
set -e
# Formats any *.tf files according to the hashicorp convention
files=$(git diff --cached --name-only)
for f in $files
do
if [ -e "$f" ] && [[ $f == *.tf ]]; then
#terraform validate `dirname $f`
terraform fmt $f

S3 Bucket

Terraform can also store modules in an S3 bucket. To access the bucket you must have appropriate AWS credentials in your configuration or available via shared credentials or environment variables.

There are a variety of S3 bucket addressing schemes, most are documented in the S3 configuration. Here are a couple of examples:

#!/bin/bash
type terraform >/dev/null 2>&1 || { echo >&2 "I require terraform but it's not installed. Quitting sadly."; exit 1; }
REGION="us-east-1"
BUCKET="remote_state"
ENVIRONMENT=${PWD##*/}
STATE_FILE="terraform.tfstate"
ARGS=$*
* aws_route53_record.riemann_private: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.
Please include the following information in your report:
Terraform Version: 0.8.1
Resource ID: aws_route53_record.riemann_private
Mismatch reason: attribute mismatch: records.1515779551
Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"ttl":*terraform.ResourceAttrDiff{Old:"", New:"300", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "fqdn":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "zone_id":*terraform.ResourceAttrDiff{Old:"", New:"Z2FZI4D6465RDO", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "records.#":*terraform.ResourceAtt
My root partition mounted read only too. To fix, I ran:
blkid
to get the disk's new UUID, and then updated /etc/fstab with the new value:
cp /etc/fstab /run
vim /run/fstab
mount --no-mtab --fstab /run/fstab -o remount,rw /
cp /run/fstab /etc
reboot
Warning - actual ignitition not guaranteed to occur. No Ben's were harmed during the making of this tweet.
@jamtur01
jamtur01 / c4q_techinterview.md
Last active July 9, 2021 12:48
C4Q Technical Interview Slides

Interviewing for Engineering roles


Workshop timetable

  • 15 mins Introduction

Per interview.

#!/opt/puppetlabs/puppet/bin/ruby
# This mini-webserver is meant to be run as the peadmin user
# so that it can call mcollective from a puppetmaster
# Authors:
# Ben Ford
# Adam Crews
# Zack Smith
# Jeff Malnick
require 'rubygems'
export DATADOG_API_KEY="..." to run these tests.
export HIPCHAT_SERVER="..." to run these tests.
export HIPCHAT_API_KEY="..." to run these tests.
export HIPCHAT_ALERT_ROOM="..." to run these tests.
export LIBRATO_METRICS_USER="..." to run these tests.
export LIBRATO_METRICS_API_KEY="..." to run these tests.
export OPSGENIE_SERVICE_KEY="..." to run these tests.
export OPSGENIE_RECIPIENTS="..." to run these tests.
export SLACK_API_KEY="..." to run these tests.
export SLACK_ALERT_ROOM="..." to run these tests.