TLS Config in Golang

Below is an example of how to generate a private key, private key, and the root CA certificate. Let us become a CA (Certificate Authority) by creating our CA private key, called rootCA.key openssl genrsa -des3 -out rootCA.key 2048 Now using that private key we can create our Root CA Certificate called rootCA.pem openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1825 -out rootCA.pem Let us now create the keys for our client (we will be using the rootCA above to generate these)
Read more

A Few Notes on Go Versioning

Go follows semantic versioning, and on top of that makes a few assumptions based on which version you are on. Semantic Versioning (SemVer) Refresh Semantic Versioning looks like MAJOR.MINOR.PATCH. Eg 1.10.8 , or 2.12.8 Major patch signals a breaking change. For example if you have a package on 1.2.3 and you upgrade to 2.0.0. This signals that the API has changed from major version 1 => 2. You will have to update the way that you are using the package.
Read more

Setting Up Dynamodb For Local Development

The finished project will be a go binary that will live in an AWS EC2 instance and speak to Dynamodb. I will be running my end to end tests locally and for this I want my code to speak to a locally running instance of Dynamodb; instead of speaking to AWS servers. I will accomplish this by using the amazon/dynamodb-local docker image. My application code will live in a scratch image, and will call into the amazon/dynamodb-local container.
Read more

Laravel Middleware and Dependency Injection

TLDR; In Laravel, middleware is bound in a way that you may not access their constructor. The best way I have found is to bind whatever the input you want, to the DI container and add it a parameter to the middlewares __construct() method. The Scenario Disclaimer: This is not the way to do auth. I have created this scenario to closely resemble a situation I came across in real life.
Read more

How I Created a Rate Limiting Proxy Middleware With Go

You have just released your shiny new API. With a cool data set that you intend to share with the world. Have you thought about rate limiting? What is Rate Limiting? Rate Limiting is where you restrict access to your service to a certain number of requests per timeframe, per client. Why Rate Limit? The most important reason is to prevent one user from making too many requests and hogging all the resource.
Read more

Using Self-Signed SSL Certificates with Docker and Nginx

This tutorial is going to go through how I create and install self signed SSL certificates for my nginx docker images The set up Assuming I start with dir following directory structure - ssl-docker-nginx/ - nginx - logs/ - my-site.com.access.log - nginx.conf - site/ - index.html - docker-compose.yml site/index.html looks like… My Site My Site Nginx/nginx.conf looks like… events { worker_connections 4096; ## Default: 1024 } http { server { listen 80; server_name my-site.
Read more

My Modern PHP Development Setup

tl;dr Use a Makefile and make good use of it Run everything in Docker Use CS Fixer To Adhere To Coding Standards Use PHP Stan Syncronise your team IDE’s with .editorconfig Use a Makefile and make good use of it Most developers use Makefiles, but very few use them effectively. Below is an example of my typical Makefile container=app up: docker-compose up -d build: docker-compose rm -vsf docker-compose down -v --remove-orphans docker-compose build docker-compose up -d down: docker-compose down require: docker-compose run {container} composer require require-dev: docker-compose run {container} composer require --dev run: docker-compose run {container} php index.
Read more

Go Concurrency Design Patterns - Generator

For me the biggest challenge in concurrent programming is making sure all the “jobs” have been ran, and that all channels are closed in a respectable manner. To help with this we have design patterns. I will be going through all of the ones frequently implemented in golang. Today is the simplest of the bunch. The Generator. The Generator pattern works best when you have a pre-defined set of “jobs” that need to be ran in a concurrent manner.
Read more

Efficient Logging in AWS Go Lambas

I have been working with Golang Lambdas for around 6 months now and one of the main problems, we have encountered over the development lifecycle is reporting and observability. Lambdas do not run constantly like code on traditional servers. Instead they are only spun up when needed and kept “warm” until they are no longer needed and then spun down. To diagnose problems, it is important that we have plenty of information going into the logs such as unique run ids, and lots of information about which part of your code is getting run.
Read more

How I build Go lambdas

I have been writing go lambdas for about six months and I have learnt a thing or two during that time. Below is an example of a lambda that sends an email, I will attempt to explain some of my design decisions. The architecture of this repo looks like; handler/ handler.go handler_test.go mail/ mail.go mail_test.go vendor/ // dependencies glide.lock glide.yaml main.go Glide for Dependency Management One of the first things I do when beginning work on any kind of go application is to set up glide.
Read more