My New Site

Medium has been going down hill fast. I didn’t notice for a while, since I have been heads down coding, but the other day when I needed to share a post with someone, it didnt even load my blog. I have moved all my blog over to github webpages, using hugo, medium-to-hugo and PaperMod theme. Writing posts and sharing them is very motivating for me and finally medium broke that enough for me to move my decade old blog for the third time. ...

28 June 2026 · Graham Jenson

I Tried to Write a HTTP Service in Zig and Failed

I really like Zig. I have never wanted to write manually memory-managed code before. I don’t like C because it seems opaque and dangerous and I don’t like Rust for purely aesthetic reasons; but Zig is shiny and new and pretty and I can understand it intuitivly. I wanted to write a small HTTP service in Zig (0.15.2) that used SQLite as a data store and could scale up. To do this I used the [http.zig](https://github.com/karlseguin/http.zig) and [zig.sqlite](https://github.com/vrischmann/zig-sqlite) libraries which are pretty stable. I spent a couple weeks on this project, but kind of hit a few walls all at once which has lead me to the decision to abadon the spike. ...

9 March 2026 · Graham Jenson

Being On Call for Type 1 Diabetes with Carer

Managing my 5yo son’s Type 1 Diabetes (T1D) at night is a lot like being on call as a software engineer. Both are absolute shite. Waking up to alarms at all hours, trying to fix something to only make it worse, not understanding why anything is happening, alarm fatigue, lost sleep, burnout, and the constant stress you will sleep through an emergency. It is a bit guff to compare the two. Though, there are a some things that do apply to both, like good tools can reduce the burden. ...

15 July 2025 · Graham Jenson

Sqlite HTTP API: Zig vs Golang

I like shiny new things. Zig is very new, and very shiny, and very fast. I have no experience writing non-garbage collected languages, so I want to test it out and compare Zig with GoLang. Benchmark The benchmark is a HTTP API wrapper around SQLite: ` /write takes a JSON { “name” } and write is to the DB /read returns 100 items ` The SQL: ` – TABLE CREATE TABLE IF NOT ...

1 March 2025 · Graham Jenson

Small, Light, Robust Phones for a Type 1 Diabetic Child

Our 4yo T1D son, Sam, needs to carry a phone everywhere he goes to act as his pancreas. This phone needs to: run Android APS and a few other apps which need Android 11 or above (14 is preferred). have good bluetooth, Wifi and cell signal. It needs to have constant communication with his Omnipod pump, Dexcom G7 and remote systems like NightScout. be sturdy, light and small. It is strapped to a very active 4yo. be easy to use. Clicking the wrong button can be pretty dangerous. be very cheap. Things break, buy a couple phones as backups. The phone doesn’t need fast graphics, large battery, big screen or good camera; the things most phones are marketed on. It just needs to work and not break when a 4yo falls off their bike. ...

13 February 2025 · Graham Jenson

Problems with Predicting Blood Glucose with Regression

I use an app called NightGuard to track my Type 1 Diabetic (T1D) son’s blood glucose levels (BGL) and alert me if he needs some food or insulin. I love NightGuard. It is one of the most important applications I use to manage T1D. One of NightGuard’s best features is its predictive alerts. These alerts use regression models to try predict BGL and notify of future problems. In this post I am going to explore the way NightGuard uses regression and see if I can improve its outcomes. ...

20 June 2024 · Graham Jenson

Using Inkscape to make Individual Puzzle Pieces for Laser Cutting

My Laser Cutter bed is 300mm x 500mm, and I need to make a shape that is about 900m x 750mm. I could just use squares, but then the joinery gets complicated making sure everything lines up properly. Using jigsaw pieces might be a fun way to make such large shapes, so here is how to do that. Install “Lasercut Jigsaw” extension Create the puzzle you want with Extensions > Render > Lasercut Jigsaw ...

21 May 2024 · Graham Jenson

Design: Blood Glucose Levels

I am building a Blood Glucose Display and just wanted to collect a few of other apps examples together to compare and get ideas:#### Dexcom Libre NightGuard Nightscout SugarPixel I don’t 100% like any of them. There are like two ways in which I use this information: As a display to “glance” numbers and to alarm me if something is wrong. Like pull and push information. Using the information to calculate treatments, once something is wrong, or I think something is going wrong I need to work out a remedy. A lot of them contain graphs and other information that I don’t really need for either purpose.This is just a quick post about this to force my ideas into a box.

20 February 2024 · Graham Jenson

Managing a Type 1 Diabetic Preschooler with AndroidAPS

Sam, our 3.5yo T1D, just started preschool. In order to keep Sam safe with his BGL in a good range, reduce our stress and to help the staff at his new preschool we devised a plan that focused on: making a custom Diabetes Action and Management Plans (called 504 plans in the US) Automating with AndroidAPS’s SMB (super-micro-bolus) and Remotely controlling AAPS through SMS commands. This post will go into each briefly to hopefully help anyone else going through similar stress.#### Action and Management Plan ...

18 February 2024 · Graham Jenson

How to implement JavaScript String.length in Golang

I needed to implement JavaScript .length in Golang, the solution was pretty fun so I will tell you how.For some strings Golang’s len function will do, e.g. ` “Hello World!” . length // JS 12 len ( “Hello World!” ) // Golang 12 ` The problems start when you include any unicode characters, e.g. ` “👍” . length // JS 2 len ( “👍” ) // Golang 4 ` This is because JavaScript is implemented in UTF-16 (or UCS-2) and Golang is in UTF-8. ...

14 September 2023 · Graham Jenson

Omnipod Dash + Dexcom G7 + AndroidAPS

I was asked by an Insulet (manufacturers of Omnipod) representative if I would like to share our T1D story with Pharmac (the government organisation that decided which medicines and pharmaceutical products are subsidised) via Diabetes New Zealand. Pharmac recently put out a “Request for Proposals” to fund CGMs and insulin pumps. I love the Omnipod and our Dexcom CGM and wish all New Zealand T1D’s would have access to them. Below is the letter I wrote.To whomever will listen, ...

13 August 2023 · Graham Jenson

GoLang + SQLite on Fly.io with LiteFS: a Quick Benchmark

I am thinking about using GoLang and SQLite for a project. Looking around I found a presentation by Ben Johnson from Fly.io about LiteFS which is working towards a more scalable and reliable SQLite. This post is just about me getting something working with these technologies and stressing them a little. Benchmark I have a simple GoLang app with one route to inserts a row into a SQLite database. I want to test calling this endpoint when: ...

17 July 2023 · Graham Jenson

Moving to Android APS

In this post I am going to discuss moving our Type 1 Diabetic (T1D) 3yo son Sam from CamAPS to AndroidAPS; Why we moved, the logistics of the the change, our current setup, and the results we are seeing. Sam’s Bedroom door with phone mount Note: This is not medical advice or a recommendation, it is just our experience.#### Leaving CamAPS To manage my sons Type 1 Diabetes (T1D) I need data. All the data I can get, and I need it to be accurate and timely. I need to know: ...

6 June 2023 · Graham Jenson

Layered Laser Cut Cardboard Art with Inkscape

I really love art by Martin Tomsky that is created with layers. I wanted to try something similar. The source image: Tui by Matt Binns [source] The goal: These are examples from previous attempts Step 1: Preprocess First we take the source image and use cut out the subject and adjust the colour to be very vibrant. Note: Copy Subject in the photos app and New From Clipboard in macOS preview are useful here. ...

21 December 2022 · Graham Jenson

Automating my Son’s Pancreas with CamAPS and Dana-i Insulin Pump

This is the third post about my 2yo son’s Type 1 Diabetes (T1D). Previously, I wrote about his initial management coming out of the hospital, then his management with a Continuous Glucose Monitor (CGM). This post is about the last three months we have been using the Dana-i insulin pump with the CamAPS Hybrid-Closed-Loop (HCL) algorithm. Obligatory: nothing here is medical advice.### Insulin Pump The pump we chose was the Dana-i pump. I wrote about the reasons we picked that pump here, but basically the Dana-i is small, remotely controllable and can be used with the CamAPS hybrid-closed-loop. ...

3 November 2022 · Graham Jenson

6 Months as a Full Time Pancreas

Managing our Son’s Type 1 Diabetes with Multiple Daily Injections and Dexcom G6 Continuous Glucose Monitor In a previous post, I wrote about my 18 month old son’s (Sam) Type 1 Diabetes (T1D) diagnosis and the first month when we were learning as much as possible and struggling. That post was received with so much love and positivity, I have decided to follow up with a 6 month recap. Sam has now had diabetes for a quarter of his life (18–24 months). We have spent these first 6 months learning to be Sam’s pancreas using Multiple Daily Injections (MDI) and the Dexcom G6 Continuous Glucose Monitor (CGM). This post is about what we are doing and what we are focused on. It will hopefully be helpful for people in a similar situation and to serve as a reminder to ourselves how far we have come managing T1D. ...

27 September 2022 · Graham Jenson

What is HbA1c?

And what is NGSP, IFCC, GMI and eAG? What is HbA1c? Glucose in the bloodstream will sometimes randomly link (glycate) with a red blood cell’s haemoglobin (Hb) creating “Glycated haemoglobin” or HbA1c. The more glucose there is in the bloodstream the more likely this linking will happen. A red blood cell is in circulation for about 120 days, so the amount of HbA1c in the bloodstream can be used to approximate average blood glucose level over that time. ...

19 September 2022 · Graham Jenson

My Awesome Year (+) At Clubhouse

While catching up with some friends in 2021, they nerd sniped me by talking about all the interesting scaling problems they were having at Clubhouse. I quickly found myself in a meeting with the Rohan, Clubhouse’s cofounder, discussing all the other novel challenges that such an ambitious product has. Before I knew it, I was on the infra team at Clubhouse. I joined Clubhouse in June 2021 and have decided to leave in September 2022. This is a quick post about my work there.While at Clubhouse I mostly worked on: ...

10 September 2022 · Graham Jenson

Add a Dexcom Share Follower with curl

This is just a short set of commands that I used to add a dexcom share follower with curl. I am writing this mostly so I remember if I have to do it again, but also if someone else needs it. This is based off the commands that listed here. Note: use _https://share1.dexcom.com_ if you have a US account and _https://shareous1.dexcom.com_ for non-US account.Authenticate SESSION_ID=$(curl -v -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "User-Agent: Dexcom Share/3.0.2.11 CFNetwork/672.0.2 Darwin/14.0.0" \ -X POST \ "https://shareous1.dexcom.com/ShareWebServices/Services/General/LoginPublisherAccountByName" -d '{ "accountName":"<username>", "applicationId":"d8665ade-9673-4e27-9ff6-92db4ce13d13", "password":"<password>" }' | tr -d '"') ...

3 August 2022 · Graham Jenson

Which Insulin Pump to Choose?

A quick guide to pumps available in New Zealand We are tired. Managing our 2 year old son’s (Sam) type 1 diabetes (T1D) with Multiple Daily Injections (MDI) is a lot of work. It’s normal to get up and give food or insulin multiple times a night, and it is necessary to give multiple injections at precise times during meals. We need a better tool! The best tool available is an insulin pump. MDI is coarse, we give 8–10 giant doses of insulin per day. A pump, on the other hand, is fine grained, it can give hundreds of tiny doses a day. ...

3 June 2022 · Graham Jenson

The Unreasonable Math of Type 1 Diabetes

This is not medical advice, don’t base any treatments on this. In January 2022, our 18 month old son, Sam, was diagnosed with Type 1 Diabetes (T1D). This was stressful, sad, and scary as we spent 5 days in hospital with him while he recovered from Diabetic Keto Acidosis (DKA). Within an hour of him being diagnosed a wonderful diabetes nurse gave us a literal backpack filled with books and information we needed to learn to keep him alive. We started to read and try to understand what it takes to manage T1D. Immediately the massive cognitive overhead it takes to just survive with this condition hit us. ...

17 February 2022 · Graham Jenson

My Troubles with Lua

I use Redis and Redis uses Lua as a scripting language. Today was my first day using Lua in anger, and I am still angry.My problem is that in Redis I have many sets of keys, e.g. s1 = {1,2,3} s2 = {3,4} and keys 1=a, 2=b, 3=c, 4=d. I want to return all values of all keys in the union of given sets, e.g. f(s1 s2) = a b c d ...

27 September 2021 · Graham Jenson

Game Of Life: CUDA vs Golang

I got a new graphics card because I want to play around with some machine learning using tensorflow and pytorch. Before I jump into all those high level concepts, with layers and layers of abstractions, I want to understand a little bit more about CUDA and how it works. I usually learn by doing, so I decided to do something pretty easy, implement Game Of Life (GOL) using CUDA. GOL is good use case for CUDA. It is a simple mathematical operation that can be massively parallelised. In this post I get a pretty fast implementation of GOL working in CUDA, and compare it against another implementation in Golang. **TLDR: CUDA wins… by a lot.**CUDA lets you compile code to be run on a graphics card. You write in a C like language two types of functions, one for the CPU (host) and one for graphics card (device). The code starts with a main function executed on the CPU and can call out to device kernel functions declared with __global__. ...

16 August 2021 · Graham Jenson

Get an Email if Someone SSHs into Your Box

There are a couple different types of security; preventative will stop something bad from happening and detective will alert you when something bad does happen. I have box that is SSH accessible on the internet that I want secure. There are lots of good sources for preventative SSH security (e.g. no passwords, tight config…) but not many for detective security. To be more secure (and decrease my paranoia) I want to be notified when someone SSH’s into that box from the wide internet, and I usually read my email.The first part is being able to send an email from a script. I could use any old SMPT server, but using an authorised one will decrease the chance my email goes straight to spam. I use Gmail’s SMTP server since it is pretty easy to setup. ...

19 July 2021 · Graham Jenson

Make Python’s DynamoDB client faster with this one simple trick

AWS DynamoDB is popular because it is super fast & scalable. However, when using the Python client boto3 to fetch a large number of documents we started to noticed some unexplained slowness. This was super annoying as some of our queries were taking 20s to process BUT the actual dynamo query returned in only 6s. So we wanted to find out where that 14s was going.Using dynamodb-local I put 250,000 basic items: with table.batch_writer() as batch: for i in range(250000): batch.put_item(Item={ 'id': i, 'updated_at': i, 'name': "some data", 'status': "some other stuff" }) ...

11 July 2021 · Graham Jenson

Python Decorator to Memoize Instance Methods

For the life of me I could not find a python decorator that memoizes methods on an instance. Something that replaces the pattern: class A: def x(self): if self._x is not None: return self._x self._x = something_difficult() return self._x Sure there is [functools](https://docs.python.org/3.9/library/functools.html) [] (https://docs.python.org/3.9/library/functools.html)`[@cache](https://docs.python.org/3.9/library/functools.html)` [and] (https://docs.python.org/3.9/library/functools.html)`[@cached_property](https://docs.python.org/3.9/library/functools.html)` but these use a global lru_cache for everything. I want the cache to live and die with the instance. I am still pretty new to python, but slowly getting the hang of it. That being said I came up with this: `class memoize: def init(self, func): self.func = func ...

30 June 2021 · Graham Jenson

Calling Golang functions from Python with Bazel

So I have been doing a lot of Python and Django lately, but I miss Go. As an experiment I wanted to see how difficult it would be to directly call Golang functions from Python using my favourite build tool Bazel. I found this post, which explains how to build and connect the two manually: Python and Go : Part II - Extending Python With Go Great now I am like 90% there! ...

20 June 2021 · Graham Jenson

5 Awesome Years at Coinbase

I joined Coinbase March 28th 2016; my last day is April 2nd 2021. This is a quick write up about my experience on joining and working in the infrastructure team for 5 years at Coinbase, growing from 100 to over 1000 employees, from 3.5 million users to more than 40 million, and from trading $3 billion total to now often trading that in a single day. Coinbase in March 2016 ...

3 April 2021 · Graham Jenson

Every Job I Have Had

Everyone has a different path to where they are today. At inflection points in my career I often think back to the jobs that have got me here. I just wanted to list all my paid jobs to reflect on that journey.Candy Mixer at Four Square (1995–96): A family friend owned a dairy (corner store for non-kiwis) and they needed someone to make the pre-packed $1–2 mixed candy bags. Paid $5 an hour and free candy. ...

16 March 2021 · Graham Jenson

How “go build” Works

How does go build compile the simplest Golang program? This post is here to answer that question. The simplest go program (I can think of) is main.go: package main``func main() {} If we run go build main.go it outputs an executable main that is 1.1Mb and does nothing. What did go build do to do create such a useful binary? go build has some args that are useful for seeing how it builds: ...

11 September 2020 · Graham Jenson

Learning to play Asteroids in Golang with NEAT

I am a huge fan of CodeBullet, an educational YouTuber that makes game playing AI bots. That is because computer science education more than just conveying complex ideas, it is also getting people excited using those ideas to solve interesting problems, something CodeBullet does very well. Two years ago CodeBullet showed a bot learning to play Asteroids. I though I wonder if I can do that… in Golang. The first thing was build a desktop app in Golang, then it was to build an asteroids game. Finally, this post is about how I used the goNEAT implementation of NEAT to build an AI that can play my asteroids game. ...

29 August 2020 · Graham Jenson

Making Asteroids Game with Golang, Lorca/Webview and WASM

In my past few posts [1][2] I have written about building a desktop application using Golang with Lorca/Webview to run a WebAssembly (WASM) binary. Now, I want to actually try use these technologies in anger and produce a distributable desktop application. I have chosen to make the game Asteroids (code here). It is reasonably complicated, fun and lets me play and learn more about Golangs [syscall/js](https://golang.org/pkg/syscall/js/) package and algorithms like Separating Axis Theorem (SAT) for collision detection. The goal is using Golang to build a single binary that can be downloaded onto different platforms (macOS, windows, linux) to play a fun game. ...

20 August 2020 · Graham Jenson

GoLang Desktop App with webview/Lorca, WASM and Bazel

On my quest towards building a GoLang Desktop application I found some useful frameworks, Lorca and Webview (which I wrote about in my previous post). These frameworks create a window which GoLang can inject HTML, CSS, and JavaScript to build the UI. But I don’t want to write JavaScript(!) and deal with all the complexities that comes with it like npm, webpack, typescript… Fortunately, I can just compile GoLang to WebAssembly (WASM) and use that in place of JavaScript. WASM is a binary format that can be executed natively in most modern browsers. My previous post showed how to build a WASM web-app with the Bazel. ...

11 August 2020 · Graham Jenson

Golang Desktop App: Webview vs. Lorca vs. Electron

I want to build a local desktop Golang app, there are a few ways to do this: Electron: bundled Node.js and the Chromium browser to create a packaged local web-app. Usable with Golang frameworks like go-app or go-astilectron. Lorca: using the locally installed Chrome driving it using its dev-tools communication protocol. Webview: create a native window with webview and render the app inside it using CGo bindings. I have already written about building a simple electron app, so this post will go into how to build an app using Lorca and Webview, and then compare the three different options. ...

6 August 2020 · Graham Jenson

Building an Electron App with Bazel

I want to build a desktop app with: Electron.js: A framework to build a desktop application using a Node.js and the Chromium browser Bazel: a build system to quickly build, test and run applications They seem like they might go well together, so let’s see. Note: we will be focusing on macOS only for simplicity. All code is located at https://github.com/grahamjenson/bazel-electron The Electron Application An electron app (in macOS) is a folder with the electron binaries (Node.js Chromium, and libraries downloaded from https://github.com/electron/electron/releases) and three application files located at: electron/Electron.app/Contents/Resources/app/ ├── package.json ├── main.js └── index.html ...

31 July 2020 · Graham Jenson

Longest Single Letter .com Domain Name

I was looking for a domain name, got bored at not finding any I liked, so started looking for other, more specific domain names. I tried aaaaaa.com but this was taken, then aaaaaaa.com , then aaaaaaaa.com and so on. I was surprised by how many of these were registered. So I began to wonder how may a’s it would take before there was a domain name that I could register. Then I expanded that to wonder about b and c … ...

22 July 2020 · Graham Jenson

A Web App Using Bazel Golang WASM and Proto

Gary Bernhardt at PyCon 2014 talked about “The Birth and Death of Javascript”. He predicted, among other things, a giant exclusion zone around San Francisco, a world altering event in 2020, and that WASM would eventually take over the web. Let’s ignore the prior two prescient predictions and focus on the third, WASM taking over. So, I want to build a simple web app by joining a bunch of new and fun technologies together: ...

1 April 2020 · Graham Jenson

Bazel: Why people love/hate it

In Bazel you put files into Rules and get files out, e.g: pkg_tar( name = "package", extension = "tar.gz", srcs = [:file1, :file2] ) The pkg_tar rule takes :file1 and :file2 and spits out the tarball :package.tar.gz, which you can pass to another rule as input. So you input files into rules that output files into other rules, that output files into other rules… until eventually you get the file you want. This is a graph that can look like: ...

5 August 2019 · Graham Jenson

Git Log as JSON in Go

For reasons I wanted git log to be parsed in Go and it looks like the easiest way to do that is to output it as JSON and parse into Go structs. First we need to define the format for the JSON (borrowed from here): var GITFORMAT string = –pretty=format:{ “commit”: “%H”, “parent”: “%P”, “refs”: “%D”, “subject”: “%s”, “author”: { “name”: “%aN”, “email”: “%aE”, “date”: “%ad” }, “commiter”: { “name”: “%cN”, “email”: “%cE”, “date”: “%cd” } },`` ...

23 July 2019 · Graham Jenson

How to Digest a Docker Image

Do you want to see something annoying? Create a Dockerfile like this: FROM ubuntu:18.04@sha256:9b1...b3c````RUN echo "Hello World" Now build it without cache twice: $> docker build --no-cache -q . sha256:4e0...20b $> docker build --no-cache -q . sha256:e28...3fa Why are the SHA digests different? They should be exactly the same… right? The file system didn’t change, they are both built in the same environment. To solve this mystery lets take a look inside each of these images: $> docker save sha256:4e0...20b > a.tar $> docker save sha256:e28...3fa > b.tar````$> mkdir a $> mkdir b````$> tar -xzvf a.tar -C a $> tar -xzvf b.tar -C b ...

11 July 2019 · Graham Jenson

CloudFormation S3File and S3Zip Custom Resources

LearnLog 8:00am — CleanUp Last time I was able to get the basics of custom resources in Fenrir working. Today I want to finish: Uploading a S3File with custom resource. Create Custom Resource S3ZipFile which will extract the ZIP file. Also clean up some of the code. Test out multi-account deploys with custom resources. Using the Bifrost standard to build deployers provides a framework for building deployers that can work across AWS accounts by simply creating an assumable role in an AWS account. This make onboarding new accounts super easy. CloudFormation custom resources complicates this a bit because I want to keep this simple onboarding, so I don’t want to deploy a lambda. ...

21 June 2019 · Graham Jenson

CloudFormation Custom Resources in Fenrir

Learnlog 9:50am — Fenrir CloudFormation I am taking today off from learning Bazel and instead I am looking at how to build a CloudFormation static site deployer for Fenrir. Fenrir is a AWS SAM deployer that is basically sam deploy but in a Step Function. I want Fenrir to be able to deploy “full-stack” applications, including front end resources which can sit in S3 as a static assets. This would make it much easier for Coinbase engineering to work with serverless, as currently they have to deploy front end code separately from the serverless API’s that power them. ...

18 June 2019 · Graham Jenson

Bazel Docker Tests

Learnlog 7:30am — What to do today In my previous learnlog I built a tree of docker images able to be changed and rebuilt. What I want to try do today is write a tests on the built containers so that if they don’t meet some constraints the build will fail and their dependents won’t be built. Let’s boot up the previous days project and start reading. 8:30am — Yak Shaving Yak shaved by cleaning up some of the images by copying the build tree of the valid DockerHub images. ...

17 June 2019 · Graham Jenson

Bazel Docker Dependency Tree: LearnLog

Learnlog 9:45 am — What I want What I want to do is use Google’s build tool Bazel to build a tree of Dockerfiles that are FROM each other and use Bazels dependency engine to automatically rebuild docker containers if a container they depend on changes. This is currently a manual job at many companies, and as they grow this becomes more tedious and in need of automating. I already have Bazel installed from a previous failed spike using https://github.com/bazelbuild/rules_docker which are a bit overcomplicated and difficult to use for someone who is just learning (like me). ...

15 June 2019 · Graham Jenson

Introducing Fenrir: How Coinbase is Scaling Serverless Applications

Serverless, specifically AWS Lambda, is awesome. It scales from 0 to near infinity, it costs next to nothing, and it integrates with almost everything. The trouble starts when going from one engineer deploying applications into one account, to lots of engineers deploying into many shared accounts. It’s hard to make sure applications follow the same good naming and security practices to stop everyone from stepping on each other’s toes. Providing a secure and pleasant experience for thousands of developers building and deploying hundreds of serverless applications to dozens of AWS accounts is the goal. To that end we developed and open sourced Fenrir, our AWS SAM deployer. This post is about how we use Fenrir to deploy serverless in a large organization. ...

11 April 2019 · Graham Jenson

YAML Custom Tags in Ruby

I wanted to parse an AWS SAM template file using Ruby. This format uses [intrinsic](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) functions which can be YAML custom tags, e.g. [!Ref](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html) to reference a parameter or resource. How do I parse a YAML custom tag in ruby? There are two options YAML.add_domain_type or YAML.add_tag. Domain types are **** easier: require "yaml"``YAML.add_domain_type("", "Ref") do |type, value| value.upcase end``out = YAML.safe_load("test: !Ref value")``puts out # {“test”=>”VALUE”} puts out.to_yaml # test: VALUE ...

6 February 2019 · Graham Jenson

Hello SAM: AWS Golang Quickstart

Pre-Req: Must have Docker for Mac installed I wanted to play with AWS SAM to understand how it works and compare to other tech like serverless. Install and Test SAM Use brew to install the aws-sam-cli: ``brew upgrade brew update brew tap aws/tap brew install aws-sam-cli sam –version SAM CLI, version 0.10.0`` Now init a go SAM project: cd $GOPATH/src/github.com/grahamjenson/ sam init --runtime go --name hello-sam cd hello-sam This creates a folder with: hello-sam/ ├── Makefile <-- Make to automate build ├── README.md <-- This instructions file ├── hello-world <-- Source code for a lambda │ ├── main.go <-- Lambda function code │ └── main_test.go <-- Unit tests └── template.yaml ...

24 December 2018 · Graham Jenson

AWS Step Functions, State Machines, Bifrost, and Building Deployers

AWS Step Functions are hosted state-machines defined according to the Amazon States Language. To execute a Step function you send it JSON data which is given to an initial state to process then pass the output to another state. States are processed until a success or failure state is reached. How a state processes its input and selects the next state depends on its Type. For example, a Task state can use a Lambda function to process the input, and a Choice state can select which state to go to next based on its input. ...

20 November 2018 · Graham Jenson

AWS API to get EC2 Instance Prices

AWS provides an API for everything! This includes the Pricing API to find out how much you can spend via their other APIs. This API can be difficult to use to answer questions like: How much does an EC2 instance cost? The difficulty comes because the API has a single endpoint [GetProducts](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_pricing_GetProducts.html) that returns all prices for every service and product. That is a ton of data that requires lots of filtering to get what you want. You can download all the EC2 price data at once from a file Amazon hosts here. This file is 510Mb! ...

3 November 2018 · Graham Jenson

Assuming Roles in AWS with Go

So your organization has many AWS accounts, but you have services (like monitoring, deploying, security) that require access to resources across many/all of those accounts. There are a few options for these services: Deploy the service in each account: to add an account you need to recreate the entire service with all its resources, and then maintain all of that infrastructure in perpetuity. Deploy the service in one account with access keys to other accounts: each account requires a user with a policy and access key that is given to the service. This can quickly get out of hand as the number of keys explode, both in maintaining the services access to them and security concerns around rolling them. Deploy the service in one account that can assume roles into other accounts: the service requires a user, instance profile, or role that is trusted by roles in the other accounts. The service only needs to know the name of the role and the account ID to work. The latter option has the least surface area to secure, requires the least amount of maintenance, and is the easiest to scale with the number of accounts. This post briefly goes over how to manage the assumed roles in a service written in Go. ...

8 August 2018 · Graham Jenson