Codebuild AWS for Golang

Published August 5, 2020

The code from this article can be found at

Build a golang project using AWS CodeBuild

DevOps has been useful almost required to speed up all stages in life cycle software. Following our path in AWS in this post we are going to review AWS CodeBuild. AWS CodeBuild is a managed service to comp ile, test and package software. Benefits of AWS CodeBuild is that as is managed service it scales well and process multiple builds concurrently. This post we are going to use it to create a pipeline with a golang project.

  1. Create a simple go server
package main

import (

func main() {
    http.HandleFunc("/", HelloServer)
    http.ListenAndServe(":8080", nil)

func HelloServer(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
  1. Create a repository in github and upload it. (You can use mine repository golang-codebuild-aws

  2. Create CodeBuild project see documentation

At the moment to write this post the unique way to use gitlab is to create CodeBuild project from console web. see documentation

  1. Create file buildspec.yaml specification
version: 0.2
      golang: 1.13
      - go get -u

      - golint -set_exit_status
      - go test

      - go build -o app

    - app
    - buildspec.yml

With this project configuration each change in your repo will trigger the pipeline.

The code from this article can be found at