Published on: Fri, 31 Jul, 2020
By: Amit Rai
In this tutorial, we are going to build a CI/CD pipeline for deploying a small pre-built sample application. we will use AWS Code Pipeline service to create pipeline to build test and deploy application code whenever there is any change has been committed.
AWS services/ frameworks used
Continuous deployment allows to deploy latest revisions to a production environment automatically, making the entire software release process automated.
Everything done in this tutorial is free tier eligible.
Creating deployment environment on AWS Elastic Beanstalk
We need to create a target environment having virtual servers or instances where application code will be deployed by pipeline. We will use the AWS elastic beanstalk to host the sample web application without needing to launch, configure or manage virtual servers. Elastic Beanstalk automatically provision and manage infrastruture and provide application stack.
Launch Sample PHP application - select PHP as your platform and Single Instance as your environment type. Don't select a key pair since we are not going to login into instance. Elastic Beanstalk will create a sample environment. It will create an Amazon EC2 instance, a security group, an Auto Scaling group, an Amazon S3 bucket, Amazon CloudWatch alarms, and a domain name for your sample application.
Creating a repository for sample code in CodeCommit
Create a repository in AWS CodeCommit as our source repository. On the Create new repository, give repository a name and select create repository. We can retrieve the sample code from the AWS GitHub repository and we can save it to out local computer for any changes, we can upload code base to CodeCommit repository.
In codeCommit console, select the repository and copy the https url link. Run below command to connect your local repository with CodeCommit repo.
Use below link to download the sample code on your local computer
We can use blow git command to upload sample code on CodeCommit repository
Sample web application code will be uploaded on CodeCommit repository
Creating deployment pipeline
We will create and configure an AWS CodePipeline with the locations of your source repository and deployment environment.
Once the pipeline has been created and launched, it will detects the sample application code in our source location, bundles up the files, and then move them to the deploy stage.
To verify the deployed application, Click the URL that appears in AWS Elastic Beanstalk application console.
AWS CodePipeline is a service for continuous deployment so revised the code and commit in our repository will be detected by CodePipeline and CodePipeline will automatically initiate deploying it via Elastic Beanstalk.
Click application url to verify the new changes.
Clean up resources
We will delete all the resources those we have launched throughout this tutorial to avoid future charges
a. First, we need to delete pipeline:
b. Second, delete your Elastic Beanstalk application:
We have successfully created an automated application release pipeline to continuously deploy changes using CodePipeline.