In this tutorial, you will learn how to create an automated software release pipeline that deploys a live sample app. We will create the pipeline using AWS CodePipeline, a service that builds, tests, and deploys your code every time there is a code change. We will use our GitHub repository as the source location for the sample app’s code. We will also use AWS Elastic Beanstalk as the deployment target for the sample app. Our completed pipeline will be able to detect changes made to the source repository containing the sample app and then automatically update your live sample app.
Continuous deployment allows you to deploy revisions to a production environment automatically without explicit approval from a developer, making the entire software release process automated.
In continuous deployment, you need a deployment environment which can be either an EC2 server or a Docker container or Elastic Beanstalk . In this case, I am going to use Elastic Beanstalk.
a. Elastic Beanstalk will host web application without the need to launch, configure, or operate. You don’t need to worry about the infrastructure, Elastic Beanstalk will take care of everything. I am going to deploy a PHP application on Elastic Beanstalk. So, let’s create an environment for PHP application with a single instance –
b. Create Web Application and give Application name and choose PHP from platform
c. Elastic Beanstalk will begin creating a sample environment for you to deploy your application to. 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 application.
In this step, you will retrieve a copy of the sample app’s code and choose a source to host the code. The pipeline takes code from the source and then performs actions on it.
if you would like to use your GitHub account:
- Visit our GitHub repository containing the sample code at https://github.com/awslabs/aws-codepipeline-s3-aws-codedeploy_linux.
- Fork a copy of the repository to your own GitHub account by clicking the Fork button in the upper-right corner.
In this step, you will create and configure a simple pipeline with two actions: source and deploy. You will provide CodePipeline with the locations of your source repository and deployment environment.
a. Create pipeline
b. On the Step 1: Name page:
- Pipeline name: enter the name for your pipeline, DemoPipeline.
- Click Next step.
Note: After you create a pipeline, you cannot change its name.
c. On the Step 2: Source page, select the location of the source you selected and follow the steps below:
Source Provider: GitHub
- In the Connect to GitHub section, click Connect to GitHub.
- A new browser window will open to connect you to GitHub. If prompted to sign in, provide your GitHub credentials.
- You will be asked to authorize application access to your account. Choose Authorize application.
Specify the repository and branch:
- Repository: In the drop-down list, choose the GitHub repository you want to use as the source location for your pipeline. Click the forked repository in your GitHub account containing the sample code called aws-codepipeline-s3-aws-codedeploy_linux.
- Branch: In the drop-down list, choose the branch you want to use, master.
- Click Next step.
d. A true continuous deployment pipeline requires a build stage, where code is compiled and unit tested. CodePipeline lets you plug your preferred build provider into your pipeline. However, in this tutorial you will skip the build stage.
- In Step 3: Build page, choose No Build.
- Click Next step.
e. choose Elastic beanstalk and select application name and environment name from drop down and click next
In this step, you will launch your pipeline. Once your pipeline has been created, it will start to run automatically. First, it detects the sample app code in your source location, bundles up the files, and then move them to the second stage that you defined. During this stage, it passes the code to Elastic Beanstalk, which contains the EC2 instance that will host your code. Elastic Beanstalk handles deploying the code to the EC2 instance.
a. In the Step 6: Review page, review the information and click Create pipeline
b. After your pipeline is created, the pipeline status page appears and the pipeline automatically starts to run. You can view progress as well as success and failure messages as the pipeline performs each action
c. Login to elastic beanstalk and your application and Click the URL that appears to view the sample website you deployed.
and you will your website
In this step, you will revise the sample code and commit the change to your repository. CodePipeline will detect your updated sample code and then automatically initiate deploying it to your EC2 instance via Elastic Beanstalk.
a. Visit your own copy of the repository that you forked in GitHub.
- Open index.html
- Select the Edit icon.
b. update content and commit
c. Then again visit your elastic beanstalk application url . Yeahh its worked.
You have successfully created an automated software release pipeline using AWS CodePipeline!