Migrate an on-premises Go web application to AWS Elastic Beanstalk by using the binary method - AWS Prescriptive Guidance

Migrate an on-premises Go web application to AWS Elastic Beanstalk by using the binary method

Created by Suhas Basavaraj (AWS) and Shumaz Mukhtar Kazi (AWS)

Environment: PoC or pilot

Source: Applications

Target: Elastic Beanstalk

R Type: Rehost

Technologies: Migration; Web & mobile apps

AWS services: AWS Elastic Beanstalk

Summary

This pattern describes how to migrate an on-premises Go web application to AWS Elastic Beanstalk. After the application is migrated, Elastic Beanstalk builds the binary for the source bundle and deploys it to an Amazon Elastic Compute Cloud (Amazon EC2) instance.

As a rehost migration strategy, this pattern’s approach is fast and requires no code changes, which means less testing and migration time. 

Prerequisites and limitations

Prerequisites 

Product versions

Architecture

Source technology stack  

  • An on-premises Go web application 

Target technology stack

  • AWS Elastic Beanstalk

  • Amazon CloudWatch

Target architecture

Architecture for migrating a Go application to Elastic Beanstalk

Tools

  • AWS Elastic Beanstalk quickly deploys and manages applications in the AWS Cloud without users having to learn about the infrastructure that runs those applications. Elastic Beanstalk reduces management complexity without restricting choice or control.

  • GitHub is an open-source distributed version control system.

Epics

TaskDescriptionSkills required

Create the source bundle for the Go application.

Open the GitHub repository that contains your Go application’s source code and prepare the source bundle. The source bundle contains an application.go source file in the root directory, which hosts the main package for your Go application. If you do not use GitHub, see the Prerequisites section earlier in this pattern for other ways to create your application source bundle.

System Admin, Application Developer

Create a configuration file.

Create an .ebextensions folder in your source bundle, and then create an options.config file inside this folder. For more information, see the Elastic Beanstalk documentation.

System Admin, Application Developer

Create the source bundle .zip file.

Run the following command.

git archive -o ../godemoapp.zip HEAD

This creates the source bundle .zip file. Download and save the .zip file as a local file.

Important: The .zip file cannot exceed 512 MB and cannot include a parent folder or top-level directory.

System Admin, Application Developer
TaskDescriptionSkills required

Choose the Elastic Beanstalk application.

  1. Sign in to the AWS Management Console and open the Elastic Beanstalk console.

  2. From the Regions list, choose your AWS Region.

  3. In the navigation pane, choose Applications, and then choose an existing Elastic Beanstalk application or create one.

For instructions on how to create an Elastic Beanstalk application, see the Elastic Beanstalk documentation.

System Admin, Application Developer

Initiate the Elastic Beanstalk web server environment.

  1. On the application overview page, choose Create a new environment, and then choose Web server environment.

  2. Complete the Environment name and Domain name fields.

  3. Choose Platform version, and select Go as your platform.

System Admin, Application Developer

Upload the source bundle .zip file to Elastic Beanstalk.

  1. In Application code, choose Upload your code, and then choose Local file.

  2. Choose the .zip file that contains your source bundle.

  3. In Version label, give the file a unique name, and then choose Create environment.

System Admin, Application Developer

Test the deployed Go web application.

You will be redirected to the Elastic Beanstalk application's overview page. At the top of the overview, next to Environment ID, choose the URL that ends in elasticbeanstalk.com to navigate to your application. Your application must use this name in its configuration file as an environment variable and display it on the web page.

System Admin, Application Developer

Troubleshooting

IssueSolution

Unable to access the application through an Application Load Balancer.

Check the target group that contains your Elastic Beanstalk application. If it’s unhealthy, log in to your Elastic Beanstalk instance and check the nginx.conf file configuration to verify that it routes to the correct health status URL. You might need to change the target group health check URL.

Related resources