Deploying Code to AWS Beanstalk Using Git & CodePipeline

Introduction

In this article, We will see code deployment on AWS Beanstalk using git and AWS CodePiepline.

So we are going to use AWS CodePipeline and git repository here because our requirement is to achieve Continuous Integration and Continuous Deployment.

Prerequisite

  • AWS Account
  • Git Account / Git Repository

After login in AWS, search for Elastic Beanstalk and click on Create Application.

Create Application

After clicking on Create Application and selecting Web server environment in Environment tier, and under Application information, enter your Application Name. It can be anything.

Web server environment

No need to change anything in Environment information. It will take the environment name according to your Application Name by adding -env at the end.

Emvironment information

Now, in the Platform tab, just select the Managed platform radio button and choose your code language and version and all.

Platform

For now, leave the Application code and Presets tab as it is and click on the Next button.

Application

In Service access, select the existing user, and if you don't have any user, you can go with Create and use a new service role and click on the Next button.

Service access

To make it simple, just leave the Set up networking, database, and tags - optional page and click on Skip to review.

After reviewing all the configurations, Submit the application and wait for its publication. It may take a few minutes.

Now we have to configure our AWS CodePipeline to make it CI/CD using the Git repository. Search for the CodePipeline in AWS and click on Create pipeline.

Create Pipeline

After clicking on Create Pipeline, you will see Choose Pipeline settings page. Enter any Pipeline name and Service role as a New service role and click on the Next button.

Pipeline settings

In Add Source stage page, select the Source provider as GitHub (Version 2) because we are using Git here. Simply click on Connect to github and after providing your git hub credentials, you will be able to see the connection string in Connection. In the Repository name, select your desired repo and branch as well, and click on the Next button.

Add source stage

onnect

Just for now, skip the Add Build stage page.

On Add Deploy stage page, fill in the deployment information as shown in the below image. Don't forget to select your Beanstalk application with the environment and click on the Next button.

Deploy

After reviewing the configurations, simply click on Create pipeline button.

On successful creation of Beanstalk, you will get the domain url to access your web application.