Set up your Go Lambda and deploy with Terraform
From project structure to build your Lambda to deploying in AWS
Lately I’ve been working with Go. Coming from Javascript it has been a journey to change the mindset in order to code with Go. I’m not going to talk about the pros vs cons of using Go with Lambdas or as a programming language. What I would say is that if you want to try something new, Go is a very accessible programming language to learn, and the performance inside a Lambda function is incredible.
Also if your project relies on threads Go has got you covered.
Assuming you have some basic knowledge of Go, let’s dive into how to deploy your Go Lambda function into AWS using Terraform. If you haven’t installed Go you can follow their official documentation.
On a side note, the Go intro tutorials Get started with Go and Create a Go Module are amazing resources to set up and get up to speed with your Go environment. If you are new to Go I would recommend doing them first.
1. Project structure
We are going to start with our files structure. This is my personal preference so you are welcome to tweak it around, the end result should be the same.