Go service infrastructure on AWS

Build a Golang service infrastructure on AWS using CodePipeline, Load Balancer, Auto Scaling Groups, IAM.

This article describes a Golang service infrastructure Incipience template

You can build a production-ready Go service infrastructure with this template using Incipience generator.

Build Go service infrastructure using this template

This template provides an easy-to-deploy pipeline for the development, testing, building and deployment of applications written in Go. Although this example is tailored to Go, it can be easily modified to deploy applications written in other languages too.

Source control

This template will create a repository in your account with source code of the service and of this template.

A pipeline will be configured in AWS CodePipeline. It will automatically monitor the newly created repository for modifications and will push both application and infrastructure changes to staging and then to production through the delivery pipeline.


AWS CodeBuild will be used to:

  • Run any tests included in the project (using go test).
  • Check for code lint errors (using golint).
  • Build your Go application.
  • Archive all build artifacts to S3.
  • Deploy your infrastructure changes
  • Deploy your service code changes

Infrastructure as code

This template uses AWS CloudFormation to deploy a staging and production environments suitable for hosting Go applications on AWS. This is incorporated into the same pipeline as the application development. Infrastructure for the staging and production environments will be automatically deployed as required.

By default, this will configure:

Zero-downtime application deployment (staging/production)

A sample “Hello world” Go application is included that acts as a simple webserver.

When changes are made to the Go application, AWS CodePipeline will automatically take the changes through the deployment pipeline.

AWS CodeBuild will run all tests, build the application, and then archive successful builds to Amazon S3.

AWS CodeDeploy will deploy the new application version to the Auto Scaling group of Amazon EC2 instances. By default, AWS CodeDeploy will use the CodeDeployDefault.OneAtATime deployment strategy. However you can modify the per-environment configuration to use any of the strategies listed here.

Debug service locally

You can debug this service in your favourite IDE.

For example, here is launch configuration for Visual Studio Core:

    "version": "0.2.0",
    "configurations": [
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceFolder}"

When you launch the application, your web service will be running at http://localhost:8000.