Setting up a Continuous Deployment Pipeline on AWS

Kevin Kiruri
5 min readJul 11, 2023

--

In this article, we will walk through creating a continuous deployment pipeline using AWS Code Pipeline. AWS Code Pipeline builds, tests and deploys code every time there is a change in the source destination. We will use AWS Elastic Beanstalk as the deployment target for our sample application and GitHub as the source location. All the resources used are part of the free tier and thus, won’t incur any charges. Let’s dive right in, shall we?

The deployment will be in 3 parts:

  1. Creating the deployment target
  2. Create the pipeline to link the source code to the deployment target
  1. Creating a Deployment Target

Creating a deployment target involves creating the servers to run your code. AWS provides various ways to do so. You could use EC2 instances to launch the code, however, you will need to manage the servers. To make iot easier for you, AWS provides managed services such as Elastic Beanstalk that would run the code efficienntly without your intervention. AWS would manage all the underlying servers and resources to ensure that the code/app is available at all times.

a. On your AWS Console, search for Elastic Beanstalk and click on it.

b. If you have no applications running, click on “Create application”

In case you already have applications running, a list of of the running applications appears and you can click on “Create application” at the top right of the page.

c. Give the application a Name, description (optional) and Tags(optional) then click “Create”

d. Create an environment for your application, byt cliking on “Create new environment”

e. We will create a web server environment (our app will be a simple web page”, choose “PHP” for the platform and “Sample application” for the Application code and click “Next”

f. Let the rest of the settings maintain on Default and navigate until the last page and click on “Submit”. Elastic Beanstalk will take a minute or so to create your environment.

g. The environment is created and AWS shows a green band at the top when the creation is successful.

h. You can view your sample app by clicking on the Domain link Address

2. Create the pipeline to link the source code to the deployment target

We will now link the source code to the deployment target. The source code could be stored in an S3 bucket or a git repository. For the purposes of our demo, we will be linking the code from GitHub.

a. Search for Code Pipeline on the Search box to get the Code Pipeline service

b. Click on “Create pipeline”

c. Give the Pipeline a name. If you have no service role created for Code Pipeline, select “New service role” to allow Code pipeline to create a new service in your account as the pipeline is created and give it a a name. Click “Next”

d. Add the Source details

i. Source provider — GitHub version 2

ii. Connect to your GitHub account

iii. Repository name — Repository you want to use as the source

iv. Branch name — Name of the repository’s branch that will be used as the source

v. Tick the Check Box to allow Code Pipeline to automatically start the pipeline on every pushed commit. Select he Default for “Output artifact format” and click “Next”

e. We can skip the build stage as we don’t need building in our case by clicking on “Skip build stage” and confirming your choice.

f. For the deploy stage. Select AWS Elastic Beanstalk as the Deploy provider and select the Application name and Environment name we had created earlier. Click “Next”

g. Review your pipeline then click on “Create pipeline”

h. On successful deployment, reload the sample page we had in step (1)(h) to view the changes. Our app consists of a simple html page. You can find it the code here

Now since we have the pipeline working working, let make a change on the code on GitHub and confirm that the page automatically updates.

We will make the following changes then commit the changes:

  1. Make the background red
  2. Make the last line a heading

After a minute or so, you should note that the webpage has changed in appearance

And with that, we could say that we have created a sucessful deployment pipeline.

Thank you and happy development!!!

--

--

No responses yet