An example on how easily push and run serverless GO code in AWS 🚀

Image for post
Image for post
Photo by 贝莉儿 DANIST on Unsplash

If you read my previous posts you can see that I am working with Golang and AWS a lot, so in this one, I will present how I deploy a serverless API in AWS Lambda with an API Gateway to access it.

I will write the API using GO and go-chi/chi to handle the http routing layer.

TL;DR

All the sources are available in thomaspoignant/cdk-golang-lambda-deployment repository

Create a serverless API in GO

So the first things we will do is creating an API using go-chi and the aws-lambda-go SDK, so we need to import these dependencies:

go get github.com/aws/aws-lambda-go
go get github.com/awslabs/aws-lambda-go-api-proxy
go get github.com/go-chi/chi go get…


Use CloudFormation custom resources with CDK

Candle next to laptop on table
Candle next to laptop on table
Photo by Priscilla Du Preez on Unsplash.

Since I started using AWS CDK, I’ve been trying to use it for everything related to infrastructure. But I wanted to go a bit further and also manage my monitoring with it.

To achieve this, I am extending CloudFormation with the help of custom resources.

“Custom resources enable you to write custom provisioning logic in templates that AWS CloudFormation runs anytime you create, update (if you changed the custom resource), or delete stacks. For example, you might want to include resources that aren’t available as AWS CloudFormation resource types. You can include those resources by using custom resources. That way…


Boost your productivity with all the tools you need in one place

Assortment of tools
Assortment of tools
Photo by Todd Quackenbush on Unsplash.

I love working with Go because it is easy to code and easy to build.

But like with all other programming languages, you have to deal with a lot of tooling. To have easy access to these tools, I put everything in a makefile so I can build, lint, and run everything from a single place.

After building a lot of services, I now always use the same kind of makefile to help me properly build my projects. In this article, I will share what targets I use and why they are useful.

Note: Most of the targets use Docker…


Let’s improve the performance of our web applications

Assorted items on a coffee table
Assorted items on a coffee table
Photo by Jess Bailey on Unsplash.

A cache that periodically refreshes in the background is a common pattern that is used in several use cases, but how can we achieve this in Go? In this article, I will guide you through the concepts behind the implementation to help you understand how it works.


Your back end is a simple YAML file

Image for post
Image for post
Photo by Karim MANJRA on Unsplash

I absolutely don’t think human/manual QA gates should be involved in between the writing of code and its being live. To avoid breaking things every time and to have an early cutoff system, you should use feature flags.

There are a lot of systems available on the market to manage your flags, like LaunchDarkly or UNLEASH, that have Golang support — but this option is expensive, and you have to host a server somewhere to manage your flags.

From this starting point, I came up with the idea to create a simple library with only one file in the back…


Ship infrastructure like you ship your code

Image for post
Image for post
Photo by EJ Strat on Unsplash

AWS Cloud Development Kit, better known as CDK, is changing the way we do infrastructure as code by using a proper programming language to build your infra.

Since we are building infra with dev tools, we should have a CI/CD for our CDK stack code that looks like any other project. If you look online, AWS explains how to do CI/CD with code build/code pipeline, but these probably aren’t the tools you are using in your day-to-day.

In this article, I will present to you the deployment pipeline I’m using to deploy my CDK stack based on GitHub and TravisCI.


Help your software team to save time by not redoing the same things again and again

Modern building
Modern building
Photo by Tobias Keller on Unsplash.

On my team, we recently introduced the principle of Architecture Decision Records.

An architectural decision record (ADR) is a document that captures an important architectural decision made along with its context and consequences.

This is an awesome and super-simple way to track our decisions, and it makes our product and team more future-proof.

TL;DR

The ADR framework is an awesome tool that helps new hires to understand how your team makes decisions and why your software looks the way it does.

You should write an ADR for almost everything that impacts the work of your engineers (large new decisions, undocumented team…


What I wanted to know before starting to use it

Image for post
Image for post

Some months ago I joined a new team, they were on AWS and using cloudformation for some stuff and, a lot of changes were made directly in the console.

After some discussion we’ve decided to start fresh on a new infrastructure code, with some constraint in mind:

  • We are not an OPS team but we are managing the infrastructure by our self.
  • We want no manual action in the AWS console.
  • The languages we are using in the team are GO for the backend and scala/python for data.

We have considered to re-work with Cloudformation and also with Terraform, but…


How to connect your user and infra visions

Image for post
Image for post
Honeycomb markers of your datadog alerts.

Observability and monitoring is a key tool to know how your product is going. There are thousands of good products to get this data and to evaluate these, but my favorites are datadog and honeycomb.io they are both super great in their expertise domain.

We are using datadog to monitor our infrastructure and to collect our logs and we are using honeycomb for tracing, so honeycomb has the user vision when datadog has the infrastructure vision.

We have one problem here is that these 2 visions are not connected, so sometimes it is hard to understand what we see in…


Image for post
Image for post
Photo by Henning Kesselhut on Unsplash

A bastion host is a server whose purpose is to provide access to a private network from an external network, such as the Internet. With the public cloud era, this is one of the favorite ways to access your private resources.

Let’s say you want to SSH your EC2 instance in your private subnet you can use the bastion which is in a public subnet to forward your traffic to your EC2 without to open public access to the EC2.

Thomas Poignant

Techlead and cloud architect, I like to build great apps and deploy them on the cloud ☁️ ☁️ ☁️ #aws #go #java ☕️ #typescript #cicd

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store